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

How to monitor robocopy logs with PRTG

Votes:

0

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.

backup prtg robocopy

Created on Aug 3, 2015 8:10:58 PM



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

Manual: 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.

Created on Aug 4, 2015 3:58:07 PM



Votes:

1

The sensor can be turned into a Custom EXE/Script sensor that supports wildcards in the filename rather easily:

  1. 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.
  2. 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
  3. Make sure the path to the logfile is correct and save the sensor
  4. Click the small gear in the value channel, enable limites, and set them like this:
    • Upper warning limit: 0
    • Upper error limit: 1
  5. 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.

Created on Aug 4, 2015 5:43:44 PM by  Stephan Linke [Paessler Support]



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?

Created on Aug 13, 2015 6:55:22 PM



Votes:

0

Could you try using C:\Backup\Log\*.txt as path?

Created on Aug 14, 2015 10:15:43 AM by  Stephan Linke [Paessler Support]




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 :)

Created on Aug 17, 2015 11:40:21 AM by  Stephan Linke [Paessler Support]



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

Created on Aug 17, 2015 2:39:14 PM



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.

Created on Aug 18, 2015 8:31:45 AM by  Stephan Linke [Paessler Support]



Votes:

0

Of course, I dont know how I didnt think it before!

It worked. Thank you!

Created on Aug 18, 2015 1:27:03 PM



Votes:

0

Phew, that was my last resort :D Glad it works now :)

Created on Aug 18, 2015 5:44:10 PM by  Stephan Linke [Paessler Support]



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

Created on Jun 8, 2016 5:11:29 AM




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.