From e261ce37e0c3e527773049e8856b9698d8e65f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1ll=20Gu=C3=B0j=C3=B3n=20Sigur=C3=B0sson?= Date: Mon, 20 Sep 2010 11:16:24 +0000 Subject: [PATCH] exchange checks added to nsclient config --- nsclient/trunk/NSC.ini | 4 ++++ nsclient/trunk/scripts/check_exchange/MailboxHealth.ps1 | 6 ++++-- .../trunk/scripts/check_exchange/ReplicationHealth.ps1 | 8 +++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/nsclient/trunk/NSC.ini b/nsclient/trunk/NSC.ini index 6330b0f..1643f7a 100755 --- a/nsclient/trunk/NSC.ini +++ b/nsclient/trunk/NSC.ini @@ -45,6 +45,10 @@ check_eva=cmd /c scripts\check_eva\check_eva.exe [External Alias] [NRPE Handlers] +check_mailbox_health=cmd /c echo Scripts\check_exchange\MailboxHealth.ps1 | PowerShell.exe -Command - +check_public_folders=cmd /c echo Scripts\check_exchange\PublicFoldersMounted.ps1 | PowerShell.exe -Command - +check_replication=cmd /c echo Scripts\check_exchange\ReplicationHealth.ps1 | PowerShell.exe -Command - + [NRPE Client Handlers] diff --git a/nsclient/trunk/scripts/check_exchange/MailboxHealth.ps1 b/nsclient/trunk/scripts/check_exchange/MailboxHealth.ps1 index 2688a12..cdd5a99 100644 --- a/nsclient/trunk/scripts/check_exchange/MailboxHealth.ps1 +++ b/nsclient/trunk/scripts/check_exchange/MailboxHealth.ps1 @@ -30,14 +30,14 @@ # # On the check_nrpe command include the -t 20, since it takes some time to load # the Exchange cmdlet's. -Write-Host "Test" Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 $NagiosStatus = "0" $NagiosDescription = "" - +$LongOutput = "" ForEach ($DataBase in Get-MailboxDatabase) { ForEach ($Status in Get-MailboxDatabaseCopyStatus -Identity $DataBase.Name) { + $LongOutput = $LongOutput + $Status.Name + " is " + $Status.Status + "`n" switch ($Status.Status) { "Failed" { $NagiosStatus = "2" @@ -99,5 +99,7 @@ if ($NagiosStatus -eq "2") { } else { Write-Host "OK: All Mailbox Databases are mounted and healthy." } +Write-Host $LongOutput exit $NagiosStatus + diff --git a/nsclient/trunk/scripts/check_exchange/ReplicationHealth.ps1 b/nsclient/trunk/scripts/check_exchange/ReplicationHealth.ps1 index 60f89ef..50a040f 100644 --- a/nsclient/trunk/scripts/check_exchange/ReplicationHealth.ps1 +++ b/nsclient/trunk/scripts/check_exchange/ReplicationHealth.ps1 @@ -35,11 +35,10 @@ Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 $NagiosStatus = "0" $NagiosDescription = "" - +$LongOutput = "" ForEach ($Type in Test-ReplicationHealth -Identity $env:computername) { - # Look for failed replications - if ($TypeResult -like "*FAILED*") { + if ($Type.Result -like "*FAILED*") { # Format the output for Nagios if ($NagiosDescription -ne "") { $NagiosDescription = $NagiosDescription + ", " @@ -65,6 +64,7 @@ ForEach ($Type in Test-ReplicationHealth -Identity $env:computername) { $NagiosStatus = "1" } } + $LongOutput = $LongOutput + $Type.Result + " on " + $Type.Check + "`n" } # Output, what level should we tell our caller? @@ -76,5 +76,7 @@ if ($NagiosStatus -eq "2") { Write-Host "OK: All replication tests passed." } +Write-Host $LongOutput exit $NagiosStatus +