In the company I work, we use the command Robocopy in a bat file with the Windows Task Scheduler to run some backups, every backup creates a log file with the name following the pattern: Full_"%date:/=_%".txt . I would like to know how is the best way to monitor the backups status.
How to monitor robocopy logs with PRTG
Votes:
0
12 Replies
Votes:
8
Hi
I think that depends on what you want to monitor. I use the folder sensor to check if there is a new file in a specific folder and check the age. I also use a filecontent sensor on a specific file to check if it has any string with "error" or "unsusccessful" in it.
I think the folder sensor would be ok for you. You can tell the sensor to check for file ages. But you have to move "older" logfiles to a subfolder. I would integrated a move command in the robocopy batch to move all old logfiles in to a subfolder before starting a new one. Then it is quite easy to manage with the folder sensor
regards Thomas
Created on Aug 4, 2015 6:54:47 AM
Last change on Aug 4, 2015 7:51:51 AM by
Luciano Lingnau [Paessler]
Votes:
0
Thanks for your reply.
I'll add the folder sensor, but the file sensor I think will not be aplicable in my case, because the log's file name is variable, and I need to verify if the backup was successfull.
Votes:
1
The sensor can be turned into a Custom EXE/Script sensor that supports wildcards in the filename rather easily:
- Copy C:\Program Files (x86)\PRTG Network Monitor\Sensor System\LogfileReader.exe to the C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE directory.
- Create a new EXE/Script sensor using the LogfileReader.exe. Set the parameters like this:
-f="C:\logs\robocopy*.log" -s="asn1telinitialisatiebevestiging" -id=%sensorid -t
- Make sure the path to the logfile is correct and save the sensor
- Click the small gear in the value channel, enable limites, and set them like this:
- Upper warning limit: 0
- Upper error limit: 1
- Save
Note that you can also use -r instead of -s and use regular expressions for searching. The sensor will go into a down state if the string is found initially for one scanning interval. After one scanning interval it will be in a warning state. This means that the string exists in the file, but there hasn't been a new one since the last scanning. It will go into a down state once there's a new occurence.
Votes:
0
Thanks for the feedback, Stephan.
I did as you told, but it didnt work.
It follows an screenshot: https://lh3.googleusercontent.com/e3KUOy-HpVjA5KzLkofFOda8ecuOwkKjdW4h42RsdSQ=w1372-h979-no
I used the -r parameter as you told.
What did I did wrong?
Votes:
0
Could you try using C:\Backup\Log\*.txt as path?
Votes:
0
Votes:
0
I think you set the limits in the wrong channel. Not the xecution time is supposed to have limits, it's the value channel that's important. The sensor should turn green when you remove the limit from the execution time channel :)
Votes:
0
Well, I removed the limit but is still alarming. There is only 2 channels: Execution Time and Downtiime:
https://lh3.googleusercontent.com/BLspsyoVrYHkTGIwAUayg8HKwFD99QjC3p8102DmKm4=w1540-h353-no
Votes:
0
Is that folder located on the PRTG server or a monitored server? If its the latter, you'll have to use UNC paths instead of local paths for the f parameter.
Votes:
0
Of course, I dont know how I didnt think it before!
It worked. Thank you!
Votes:
0
Phew, that was my last resort :D Glad it works now :)
Votes:
9
This script works for me:
$logFile_path = "[myLogFile].log" #write-host $content[1] -b Yellow # 10 last lines $content = gc $logFile_path -tail 10 # split with pregmatch whitespace $dir = $content[1] -split "\s+" # value directory mismatch and error $mismatch_dir = $dir[6] $failed_dir = $dir[7] # value files mismatch and error $file = $content[2] -split "\s+" $mismatch_file = $file[6] $failed_file = $file[7] $result= "<?xml version=`"1.0`" encoding=`"Windows-1252`" ?>`r`n" $result+="<prtg>`r`n" $result+=" <result>`r`n" $result+=" <channel>Mismatch File</channel>`r`n" $result+=" <Unit>Count</Unit>`r`n" $result+=" <value>$mismatch_file</value>`r`n" $result+=" </result>`r`n" $result+=" <result>`r`n" $result+=" <channel>Mismatch Directory</channel>`r`n" $result+=" <Unit>Count</Unit>`r`n" $result+=" <value>$mismatch_dir</value>`r`n" $result+=" </result>`r`n" $result+=" <result>`r`n" $result+=" <channel>Failed File</channel>`r`n" $result+=" <Unit>Count</Unit>`r`n" $result+=" <value>$failed_file</value>`r`n" $result+=" </result>`r`n" $result+=" <result>`r`n" $result+=" <channel>Failed Directory</channel>`r`n" $result+=" <Unit>Count</Unit>`r`n" $result+=" <value>$failed_dir</value>`r`n" $result+=" </result>`r`n" $result+=" <text>OK</text>`r`n" $result+="</prtg>`r`n" $result
Add comment