# Nagios Exchange 2010 Backup Monitoring Script # Author: Andy Grogan # Version 1.0 # www.telnetport25.com # ---------------------------------------- # Compatibility: # ---------------------------------------- # Nagios Version: 3.x # Exchange Version: 2010 # Powershell Version: 2.0 # NSClient++ Version: 3.x # ---------------------------------------- Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 $localServerName = Get-WmiObject -Class Win32_ComputerSystem | Select Name $ThreshHold = 2 $Results = Get-MailboxDatabase -Server $localServerName.Name -Status | Select Identity,Server,LastFullBackup | where {$_.Server -eq $localServerName.Name} foreach($itm in $Results){ if($itm -eq $null){ $Output = "OK: No Databases are active on this host" $NagiosResult = 0 }else{ if($itm.LastFullBackup -eq $null){ $lastBackupSeed = 9999 }else{ $lastBackupSeed = New-TimeSpan $($itm.LastFullBackup) $(Get-Date) } if($lastBackupSeed.days -gt $ThreshHold -or $lastBackupSeed -eq 9999){ $Res = "CRITICAL: Database Backup out of Schedule: " + $itm.Identity $Output += $Res + " " $statFlag = 1 }else{ $Output += "OK: Database: " + $itm.identity + " has a recent backup" + " " } } } Write-Host $Output if($statFlag -eq 1){ exit 2 }else{ exit 0 }