I like to monitor, if the access from any server to a file share is still accessible. Our customer wants a monitor and have proof, which shows them, that the access to certain file shares are working fine.

Following batch I found on the net, but it is not working as I hoped.

The issue is that even I cannot copy the file due to "Access is denied" to the share, the sensor is still green "OK" and shows me a time how long it took to copy the file, which in reality, no file was copied.

I need a sensor, which tells me, the file was copied (green ok) or not copied (red down), the time is secondary and actual not needed.

@echo off
 
FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Second /Format:table ^| findstr /r "."') DO (
 set Milisecond=%time:~9,2% 
 set Day=%%A
 set Hour=%%B
 set Minute=%%C
 set Second=%%D
)
set /a Start=%Day%*8640000+%Hour%*360000+%Minute%*6000+%Second%*100+%Milisecond%
 
net use \\server-a\c$\temp password /user:domain\user

copy c:\temp\test-file.txt \\server-a\c$\temp
 
FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Second /Format:table ^| findstr /r "."') DO (
 set Milisecond=%time:~9,2% 
 set Day=%%A
 set Hour=%%B
 set Minute=%%C
 set Second=%%D
)

set /a End=%Day%*8640000+%Hour%*360000+%Minute%*6000+%Second%*100+%Milisecond%
set /a Diff=%End%-%Start%

echo %Diff%:ok

Thanks for any advice in advance


Article Comments

I might found a simple solution and it seems to be working.

@echo off

Net use \\server\availability-test$ “password” /user:domain\user
Del \\server\availability-test$\prtg-test.txt
Copy c:\temp\prtg-test.txt \\server\availability-test$

IF %ERRORLEVEL%==0 (
set Message=100
) ELSE (
set Message=0
)

@echo %Message%:OK

Edit Channel of the Value (ID 2)

  • Unit = %
  • Enable Limits
  • Lower Error Limit (#) = 100 or any number below 100
  • Error Limit Message = File not copied

Now if I can copy the File it is 100% and if not it is0%


Dec, 2015 - Permalink