I am using an Altaro backup server for my HyperV backups and I’d like to monitor the event logs to see if backup was successful or not. I want PRTG to notify me, especially when backup fails. Is there a sensor that I can use?
How can I monitor my Altaro HyperV backup event logs and make PRTG notify me?
Votes:
0
11 Replies
Votes:
1
Altaro HyperV Backup Monitoring with PRTG
The following PowerShell script creates a sensor that allows you to monitor your Altaro server backups by checking the corresponding event logs. Please use the following script with an EXE/Script sensor.
Click here to enlarge.
What the Script Does
Basically, it takes into account a certain number of event log entries that occurred during a certain period of time (here: the last 10 entries in the last 24 hours) and checks them. It also
- checks local and offsite backups
- looks for the corresponding event IDs (here: 5000 for local and 5005 for offsite)
- makes the sensor go into an alarm status (red) when the backup type is other than local or offsite, and when no events having the defined event ID (here: 5000 or 5005) can be found
- additionally checks the VM name
What You Can Set Individually
- You can adjust all the parameter values of this script according to your needs. For example, if you like the last 15 entries to be checked, cancel “10” and write “15” in the “[int]$LimitEntries =” line.
- If you want the sensor not to go into an alarm state (red) when backup fails, but in a warning state (yellow) instead, substitute “exit 2” with “exit 1” in the code.
- Choose how you want to be notified in the sensor’s Notifications Settings: via email, SMS, push notification or ticket.
This is the Script
# Altaro Backup Monitoring #------------------- # Description: Modified script by Robert # Original script: (c) 2014 Stephan Linke | Paessler AG # Parameters: # -VM: VM Name # -BackupType: local or offsite # -MaxAge: Maximum age of the log entry to be considered checking (in hours) # -LimitEntries: Maximum number of entries to check # -Loglevel: The numerical level of the log file # -ProviderName: Provider of the Log file # -EventId: The ID of the Event # ------------------ param( [string]$VM, [string]$BackupType, [int]$MaxAge = 24, [int]$LimitEntries = 10, [string]$LogName = "Application", [string]$ProviderName = "Altaro Hyper-V Backup" ) if ($BackupType -eq 'local') { $EventID = 5000 } elseif ($BackupType -eq 'offsite'){ $EventID = 5005 } else { Write-Host "0:Specified BackupType not local or offsite, quitting"; exit 2; } try { $Events = (Get-WinEvent -FilterHashTable @{ProviderName=$ProviderName;LogName=$LogName;ID=$EventID;StartTime=(get-date).AddHours(-$MaxAge)} -MaxEvents $LimitEntries) } catch [Exception] { Write-Host "0:Can't find anything for $ProviderName in your $LogName eventlog. Please check Log name, Provider, Log ID, EventID, ComputerName and Credentials" exit 2; } foreach ($i in $Events) { if ($Events.Message -match 'Guest VM Name: '+$VM) { Write-Host "0:$($BackupType) Backup $VM completed in last $MaxAge hours"; Exit 0; } } Write-Host "2:$($BackupType) Backup $VM failed in last $MaxAge hours"; Exit 2;
This script is a custom script. Please understand that we cannot provide support for it. Thanks to Robert for sharing it!
Note: This script is a modified version of the script from Stephan Linke (Paessler) which you can find in How can I monitor my historic windows events.
Created on May 19, 2015 11:58:15 AM by
Martina Wittmann [Paessler Support]
Last change on Sep 23, 2015 12:47:41 PM by
Martina Wittmann [Paessler Support]
Votes:
0
My probe (and so my ps1 Altoro monitor script) is running on another machine then the server i want to monitor. The result is that a add a line to the original script: Invoke-Command -ComputerName $host [hyper-v] Where hyper-v is the machine that needs to be monitored. The remote powershell execution is working on this machine.
The output gives 1 error i can't tackle. The error is:
PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE> C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE\Altaro-monitor.ps1 At C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE\Altaro-monitor.ps1:20 char:31 + [string]$BackupType= local, + ~ Missing argument in parameter list. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingArgument
Altaro Backup Monitoring script in use #------------------- # Description: Modified script by Robert # Original script: (c) 2014 Stephan Linke | Paessler AG # Parameters: # -VM: VM Name # -BackupType: local or offsite # -MaxAge: Maximum age of the log entry to be considered checking (in hours) # -LimitEntries: Maximum number of entries to check # -Loglevel: The numerical level of the log file # -ProviderName: Provider of the Log file # -EventId: The ID of the Event # ------------------ Invoke-Command -ComputerName $host [hyper-v] param( [string]$VM, [string]$BackupType= local, [int]$MaxAge = 24, [int]$LimitEntries = 10, [string]$LogName = "Application", [string]$ProviderName = "Altaro Hyper-V Backup" ) if ($BackupType -eq 'local') { $EventID = 5000 } elseif ($BackupType -eq 'offsite'){ $EventID = 5005 } else { Write-Host "0:Specified BackupType not local or offsite, quitting"; exit 2; } try { $Events = (Get-WinEvent -FilterHashTable @{ProviderName=$ProviderName;LogName=$LogName;ID=$EventID;StartTime=(get-date).AddHours(-$MaxAge)} -MaxEvents $LimitEntries) } catch [Exception] { Write-Host "0:Can't find anything for $ProviderName in your $LogName eventlog. Please check Log name, Provider, Log ID, EventID, ComputerName and Credentials" exit 2; } foreach ($i in $Events) { if ($Events.Message -match 'Guest VM Name: '+$VM) { Write-Host "0:$($BackupType) Backup $VM completed in last $MaxAge hours"; Exit 0; } } Write-Host "2:$($BackupType) Backup $VM failed in last $MaxAge hours"; Exit 2;Host "2:$($BackupType) Backup $VM failed in last $MaxAge hours"; Exit 2;
Created on Oct 13, 2019 8:52:40 PM
Last change on Oct 14, 2019 9:00:21 AM by
Dariusz Gorka [Paessler Support]
Votes:
0
Good Morning,
could you help me with this custom sensor please? After follow your guide, the result is:
0:Specified BackupType not local or offsite, quitting
Thanks in advance, regards.
Votes:
0
What result do you get when you run it manually?
Votes:
0
Hello,
same result as PRTG sensor: 0:Specified BackupType not local or offsite, quitting
It's needed to replace something in script?
Thanks.
Votes:
0
Then you're likely not passing the correct parameters here. Did you enter the VM name in the Script at the very beginning? It's *null* by default, so it may error if you don't pass them correctly.
Votes:
0
Yes, that's how it's supposed to look. Just to make sure, does the script perhaps need to run on the actual backup server (i.e. on a remote probe on the backup server)?
Votes:
0
Hello, yes, I'm running script on Backupserver device on PRTG. But fails on powershell too. Should be I'm writting wrong shometing... I tried with many different combinations but always fails. Do you have an example for check it with names instead variables please? Thanks in advance.
Votes:
0
When you filter the given event log for the name of the configured virtual machine, do you get any results?
Votes:
0
Hello,
I can't run successfully this script... is working correctly for you?
Thanks in advance, regards.
Votes:
0
What error do you get when you run it manually with the same parameters? Did you follow our Guide for PowerShell based custom Sensors for the installation?
Add comment