# Get Exchange Database Status # # This script will execute the "MailboxDatabaseCopyStatus" command and look for a failed Content Index State # # Revision History # 12/02/2015 Willion van Es [willion@netdata.nl] 1.0 code initial created # 12/02/2015 Robin Smit [info@robinsmit.nl] 1.0 test & instruction # To execute from within NSClient++ # #[NRPE Handlers] #check_exchange_databae_mount=cmd /c echo C:\Scripts\check_database_mount.ps1 | PowerShell.exe -Command - # # On the check_nrpe command include the -t 20, since it takes some time to load # the Exchange cmdlet's. if ( (Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction:SilentlyContinue) -eq $null) { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 } $customer = "WFM People" $DBStatus = Get-MailboxDatabaseCopyStatus $customer | Select Name,Status $NagiosStatus = "0" $NagiosDescription = "" #$db = Get-MailboxDatabase -Status $customer | select name #$dbs = Get-MailboxDatabase -Status $customer | select Databasesize #$DBsize = $dbs.DatabaseSize.ToGB() #Get-MailboxDatabaseCopyStatus | Select Name,Status #Write-Host "DB Name, Size (MB)" -ForegroundColor Yellow IF($DBstatus.Status -eq "Mounted"){ $NagiosStatus = 0 }elseIF($DBstatus.Status -eq "Dismounted"){ $NagiosStatus = 2 }else{ $NagiosStatus = 1 } if ($NagiosStatus -eq "2") { Write-Host "CRITICAL: Exchange database "$DBstatus.name" is Dismounted" #$NagiosStatus = "0" #$NagiosDescription = "" } if ($NagiosStatus -eq "1") { Write-Host "WARNING: De status van Exchange database "$DBstatus.name" is niet beschikbaar" #$NagiosStatus = "0" #$NagiosDescription = "" } if ($NagiosStatus -eq "0") { Write-Host "OK: Database "$DBstatus.name" is gemount" #$NagiosStatus = "0" #$NagiosDescription = "" } exit $NagiosStatus