Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

check_veeam_backups

Current Version
1.0
Last Release Date
2012-11-13
Compatible With
  • Nagios 3.x
  • Nagios XI
Owner
License
GPL
Hits
66053
Files:
FileDescription
check_veeam_backups.ps1check_veeam_backups.ps1
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
This is a Nagios Plugin destined to check the last status and last run of Veeam Backup & Replication job passed as an argument.
Powershell needs to be installed on the Nagios box.

The plugin takes 2 arguments:

- Veeam Backup & Replication job name
- Number of days that have to elapse since the last job run before it's assumed to be in critical state

It checks both last job status and last job run date. If the number of days that have elapsed since the last job run date is greater than the second argument the job is assumed to be in critical state. If no, last job status is checked. Based on the status then plugin returns the following exit codes:

Error - 2: critical
non Error / non Success - 1: warning
Success - 0: ok

It has been successfully tested on Veeam Backup & Replication 6.0.0.153

Usage:
check_veeam_backups.ps1 [job name] [number of days]

Reviews (7)
bynarfight, September 4, 2017
to be compatible with the jobs "backup copy"

Add this after "$status = $job.GetLastResult()" :
if ($status -eq "None")
{
$status = (Get-VBRBackupSession -Name $job.name | sort -Descending)[1].Result
}



(Source : https://forums.veeam.com/powershell-f26/result-value-from-backup-copy-jobs-is-always-none-t20512.html#p186505)
bydiego.quaglio, May 31, 2017
Hi
script return me this error: Snap-in not installed...
instead "asnp VeeamPSSnapin" i use "Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue" and it works.
Thanks
Diego
If you upgrade your Veeam to V9, you have a little action to enable powershell console-in :

Reference : helpcenter.veeam.com/backup/powershell/getting_started.html

Enable Powershell :
PS C:check_nagios> Add-PSSnapin VeeamPSSnapin

Exec Powershell command :
PS C:check_nagios> Get-VBRJob -Name *Citrix* FreeBackupImpl : IsFree : False UserCryptoKey : Id : ab7b260e-699f-47dc-916c-xxxxxxxxxxx Info : Veeam.Backup.Model.CDbBackupJobInfo JobType : Backup SourceType : VDDK JobTargetType : Backup TargetType : Other TypeToString : VMware Backup Description : Created by XXXXXXXXXX at 27/11/2015 15:39. Name : Citrix_XXXXX BackupPlatform : EVmware TargetHostId : 00000000-0000-0000-0000-000000000000 TargetDir : \10.xx.xx.xxXXXXXX TargetFile : Citrix_XXXXX
bypitw, February 27, 2015
There's a missing bracket in Line 61.

This one works perfectly - also with B&R 8:

if((Get-Date $now) -gt (Get-Date $last))
byladinek, January 15, 2015
Excellent script. During attemps to get it up and running, I encountered two problems.
1. There is a bug at line 56 - missing opening bracket.
Good:
if((Get-Date $now) -gt (Get-Date $last))
Wrong:
if(Get-Date $now) -gt (Get-Date $last))

Second, I have Windows 2012 server as my Veeam box. Locales are Czech. From some unknown reason, all functions like Get-Date return date in English format (even more confusing, when you try the same from command line, the locales _are_ taken into account). However, the GetScheduleOptions call returns date with proper locale, so after this attempt to convert it to date results in format error. Even I donĀ“t understand exact nature of this problem, I found fix (this is for Czech format date):
The section of the code looks like this:
...
$last = $last -replace '\], Next run time: .*', ''

$fmt="d. M. yyyy H:mm:ss"
$last = [datetime]::ParseExact($last,$fmt, $null)

if((Get-Date $now) -gt (Get-Date $last))
...

Hope this will somebody save some time.
Mostly works out the box, cheers. I found a couple of bugs which might help someone else:

Firstly line 13 threw an error about the SnapIn already being added - fix was to comment it out:

13: #asnp VeeamPSSnapin

Secondly, the date comparison really didn't work, so I changed it from:

56: if ($now -gt $last)

to

56: if(Get-Date $now) -gt (Get-Date $last))

Which seemed to do the job quite nicely. :-)

If that inadvertently cocks up something else, then whoops - this is the first and hopefully only time I've had to deal with powershell. Give me bash any day...

Thanks
byfgranat, December 20, 2012
Hi,
I tested that script on my Veaam Backup server and nothing seems to happen as you can see below :

PS C:Program FilesNSClient++scripts> cmd /c echo check_veeam_backups.ps1 "[BKUP]-SALAG" 3; exit($lastexitcode) | powershell.exe -command -
check_veeam_backups.ps1 [BKUP]-SALAG 3

The job [BKUP]-SALAG ended successfuly yesterday evening.
Do you have any explanation ?

Rgds,

Frederic
Owner's reply

@fragnat:

What exact version of Veeam Backup & Replication do you use? Please, try to download my latest update of the plugin.

Also, please try double quotation of job name as on an example below:

check_veeam_backups1 = cmd /c echo scriptscheck_veeam_backups.ps1 ""0 - CRITICAL - backup level"" 1; exit $LastExitCode | powershell.exe -command -