I've arranged a powershell script made for vRanger to Veeam.
You can check your job status with nagios/centreon.
It contains min max job duration and min and max job interval:
Code: Select all
#VEEAM BACKUP CHECK JOB
##########################################################################
# Quest Vranger Nagios check
# For monitoring duration and run interval of backup jobs
# 12/2013 Simon Meggle <simon.meggle@consol.de>
# warn/crit for "duration": maximum allowed run time
# warn/crit for "interval": maximum age of the last backup (e.g. for a daily backup,
# set warning to 24h + 1h, crit to 24h + 4h)
###########################################################################
# NSC.ini:
# check_veeam_vm= cmd /c echo scripts\check_veeam_job.ps1 -JobName "Backup" -duration_warning 4 -duration_critical 5 -interval_warning 25 -interval_critical 28 ; exit($lastexitcode) | powershell.exe -command -
# Specifies command parameter required for requesting the backup job name.
Param (
[parameter(Mandatory = $true)][string] $JobName,
[parameter(Mandatory = $true)][single] $duration_warning,
[parameter(Mandatory = $true)][single] $duration_critical,
[parameter(Mandatory = $true)][single] $interval_warning,
[parameter(Mandatory = $true)][single] $interval_critical
);
function getState ($state) {
switch ($State)
{
0 {return "OK"}
1 {return "WARNING"}
2 {return "CRITICAL"}
3 {return "UNKNOWN"}
}
}
function getStateID($val,$w,$c) {
if ($val -gt $c) {
return 2;
} else {
if ($val -gt $w) {
return 1
} else {
return 0
}
}
}
$output = "";
$NagiosState = 0;
if (-not (asnp VeeamPSSnapin -ErrorAction SilentlyContinue))
{
asnp VeeamPSSnapin > $null
}
$Template = Get-VBRJob -Name $JobName;
if ($Template -eq $null) {
Write-Host "UNKNOWN: Could not find any matching job template!";
exit 3;
}
$Job = Get-VBRBackupSession | ?{$_.JobName -eq $jobName} | Select -Last 1
if ($Job -eq $null) {
Write-Host "UNKNOWN: Could not find any matching job!";
exit 3;
}
#Write-Host ($Job | Format-List | Out-String);
$today = Get-Date;
# Interval exceeded?
$interval_diff = New-TimeSpan $Job.CreationTime $today;
$interval_diff_hours = [math]::Round( ($interval_diff).hours + ($interval_diff).minutes / 60,1);
$interval_stateID = getStateID $interval_diff_hours $interval_warning $interval_critical;
switch ($interval_stateID)
{
0 { $output = "Backup interval ok."; }
1 {
Write-Host "WARNING: Last backup job ""$JobName"" was started "$interval_diff_hours "hours ago. (warn at" $interval_warning"h, crit at" $interval_critical"h).";
exit $interval_stateID;
}
2 {
Write-Host "CRITICAL: Last backup job ""$JobName"" was started "$interval_diff_hours "hours ago. (warn at" $interval_warning"h, crit at" $interval_critical"h).";
exit $interval_stateID;
}
}
# Job successful?
if ($Job.Result -ne "Success") {
Write-Host "CRITICAL: Backup job ""$JobName"" within interval, but completed on "$Job.EndTime "with errors!";
exit 2;
}
# Duration
$duration_diff = New-TimeSpan $Job.CreationTime $Job.EndTime;
$duration_diff_hours = [math]::Round( ($duration_diff).hours + ($duration_diff).minutes / 60,1);
$duration_stateID = getStateID $duration_diff_hours $duration_warning $duration_critical;
switch ($duration_stateID)
{
0 { $output = "OK: Backup job ""$JobName"" completed in "+$duration_diff_hours+" hours (warn at " + $duration_warning + "h, crit at " + $duration_critical + "h) at "+$Job.EndTime+"."; }
1 { $output = "WARNING: Backup job ""$JobName"" completed in "+$duration_diff_hours+" hours (warn at " + $duration_warning + "h, crit at " + $duration_critical + "h) at "+$Job.EndTime+"."; }
2 { $output = "CRITICAL: Backup job ""$JobName"" completed in "+$duration_diff_hours+" hours (warn at " + $duration_warning + "h, crit at " + $duration_critical + "h) at "+$Job.EndTime+"."; }
default { Write-Host "UNKNOWN: Could not check Backup job state of "$JobName"."; exit 3;}
}
$output = $output + "|time="+$duration_diff_hours+";"+$duration_warning+";"+$duration_critical;
Write-Host $output;
exit $NagiosState;