What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Monitor copy file from one to another server

Votes:

0

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

batch file prtg sensor

Created on Dec 15, 2015 7:56:48 AM

Last change on Dec 15, 2015 8:12:44 AM by  Torsten Lindner [Paessler Support]



1 Reply

Votes:

7

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%

Created on Dec 16, 2015 5:19:58 AM

Last change on Dec 16, 2015 8:39:33 AM by  Daniel Zobel [Product Manager]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.