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?
Article Comments
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;
Oct, 2019 - Permalink
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.
Aug, 2020 - Permalink
Hello,
same result as PRTG sensor: 0:Specified BackupType not local or offsite, quitting
It's needed to replace something in script?
Thanks.
Aug, 2020 - Permalink
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.
Aug, 2020 - Permalink
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)?
Aug, 2020 - Permalink
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.
Sep, 2020 - Permalink
When you filter the given event log for the name of the configured virtual machine, do you get any results?
Sep, 2020 - Permalink
Hello,
I can't run successfully this script... is working correctly for you?
Thanks in advance, regards.
Nov, 2020 - Permalink
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?
Nov, 2020 - Permalink
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
What You Can Set Individually
This is the Script
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.
May, 2015 - Permalink