################################################################################# ################################################################################# #################### Made by Tytus Kurek on September 2012 #################### ################################################################################# ################################################################################# ### This is a Nagios Plugin destined to check the last status and last run ### ### of Symantec Backup Exec 2012 job passed as an argument. ### ################################################################################# ################################################################################# # Adding required SnapIn Import-Module BEMCLI # Global variables $name = $args[0] $period = $args[1] # Symantec Backup Exec 2012 job status check $job = Get-BEJob -Name $name if ($job -eq $null) { $name = "'" + $name + "'" Write-Host "UNKNOWN! No such a job: $name." exit 3 } $status = Get-BEJobHistory -Name $name -FromLastJobRun | Select JobStatus $status = $status -replace '@{JobStatus=', '' $status = $status -replace '}', '' if ($status -eq "Error") { $name = "'" + $name + "'" Write-Host "CRITICAL! Errors were encountered during the backup process of the following job: $name." exit 2 } if ($status -ne "Succeeded") { $name = "'" + $name + "'" Write-Host "WARNING! Job $name didn't fully succeed." exit 1 } # Symantec Backup Exec 2012 job last run check $now = (Get-Date).AddDays(-$period) $now = $now.ToString("yyyy-MM-dd") $last = Get-BEJobHistory -Name $name -FromLastJobRun | Select StartTime $last = $last -replace '@{StartTime=', '' $last = $last -replace '}', '' $last = $last.split(' ')[0] $name = "'" + $name + "'" if ($now -gt $last) { Write-Host "CRITICAL! Last run of job: $name more than $period days ago." exit 2 } else { Write-Host "OK! Backup process of job $name completed successfully." exit 0 }