Last weekend I was playing around with Paessler PRTG Network Monitor and asked myself how hard can it be to monitor a Veeam Backup Job status. Well this proved to be a bit more difficult than I thought… The reason why is because I also need to see the date of the Backup Job somewhere in the message of the sensor, otherwise you can’t see when the last time was that the backup job has run. And this part was a little bit tricky to get to work, but after some PowerShell voodoo I got the result I was looking for :
And when there is a Backup Job warning the status changes and the Backup Job date remains visible :
Prerequisites :
PowerShell Script with DB on the same host as the Veeam Backup Server :
Save the following script to the file backup_status.ps1 in the directory : C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
#Get Backup Job Name from arguments $BackupJobName = $args[0] $VeeamBackupServer = fillinyourveeambackupservername #Setting up and start remote session $PSSession = New-PSSession -ComputerName $VeeamBackupServer #Invoke remote commands $PRTGstring = Invoke-Command -Session $PSSession -ScriptBlock { #Passing Backup Job Name variable param($BackupJobName) #Adding the Veeam Powershell SnapIn Add-PSSnapin -Name VeeamPSSnapIn -WarningAction SilentlyContinue -ErrorAction SilentlyContinue #Get the Backup History from the Backup Job $Job = Get-VBRJob -Name $BackupJobName -WarningAction SilentlyContinue #Get the information from the latest Backup Job $BackupSession = Get-VBRBackupSession -WarningAction SilentlyContinue | ?{$_.JobId -eq $Job.Id} | Sort -Descending -Property "CreationTime" | Select -First 1 #Create PRTG string If($BackupSession.Result -eq "Success"){ $PRTGstring = "0:"+$BackupSession.CreationTime.ToString("dd-MM-yyyy HH:mm") } ElseIf($BackupSession.Result -eq "Warning"){ $PRTGstring = "1:"+$BackupSession.CreationTime.ToString("dd-MM-yyyy HH:mm") } ElseIf($BackupSession.Result -eq "Failed"){ $PRTGstring = "2:"+$BackupSession.CreationTime.ToString("dd-MM-yyyy HH:mm") } #Exit the remote session Exit-PSSession #Return PRTG string return $PRTGstring } -Args $BackupJobName #Format exitcode $exitcode = $PRTGstring -split(':') #Print string for PRTG write-host $PRTGstring #Exit script exit $exitcode[0] |
Read More

