
Others
check_veeam_backups
Description:
This is a Nagios Plugin destined to check the last status and last run of Veeam Backup & Replication job passed as an argument.
Current Version
1.0
Last Release Date
2012-11-13
Compatible With
- Nagios 3.x
- Nagios XI
Owner
Website
License
GPL
Project Files
File | Description |
---|---|
check_veeam_backups.ps1 |
Project Notes
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
(9)
Add a Review
Great script, helped quite a bit here. I am using VBR 9, so I haven't attempted to work anything on v10 yet. I did however fork the project and create a separate script for backup copies. Both are working in my environment. Feedback is appreciated.
https://github.com/rich568117/check_veeam_backup_copy
https://github.com/rich568117/check_veeam_backup_copy
Hi,
Here are some edits to be compatible with v10.0. Get-VBRJobSchedule and also GetScheduleOptions() returns data from an outdated location.
Replace
---
if ($status -eq "None"){
$status = (Get-VBRBackupSession -Name $job.name | sort -Descending)[1].Result
}
---
by
---
if ($status -eq "None"){
$status = (Get-VBRBackupSession -Name ($job.name.ToString()+'*') | sort -Descending)[1].Result
}
---
In v10 the BackupSession's name parameter includes the type of run (incremental / Full).
Replace
---
$last = $job.GetScheduleOptions()
$last = $last -replace '.*Latest run time: [', ''
$last = $last -replace '], Next run time: .*', ''
$last = $last.split(' ')[0]
---
by
---
$last = $job.LatestRunLocal.ToString()
$last.Split(' ')[0]
---
Here are some edits to be compatible with v10.0. Get-VBRJobSchedule and also GetScheduleOptions() returns data from an outdated location.
Replace
---
if ($status -eq "None"){
$status = (Get-VBRBackupSession -Name $job.name | sort -Descending)[1].Result
}
---
by
---
if ($status -eq "None"){
$status = (Get-VBRBackupSession -Name ($job.name.ToString()+'*') | sort -Descending)[1].Result
}
---
In v10 the BackupSession's name parameter includes the type of run (incremental / Full).
Replace
---
$last = $job.GetScheduleOptions()
$last = $last -replace '.*Latest run time: [', ''
$last = $last -replace '], Next run time: .*', ''
$last = $last.split(' ')[0]
---
by
---
$last = $job.LatestRunLocal.ToString()
$last.Split(' ')[0]
---
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)
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)
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
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
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.
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
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
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
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 -
Add a Review
You must be logged in to submit a review.
Thank you for your review!
Your review has been submitted and is pending approval.
Recommend
To:
From:
Thank you for your recommendation!
Your recommendation has been sent.
Page Sections
Project Stats
Rating
4.3 (11)
Favorites
1
Views
85,095