mirror of
https://github.com/opinkerfi/nagios-plugins.git
synced 2026-02-06 07:05:17 +01:00
This commit is contained in:
BIN
nsclient/trunk/scripts/check_exchange/Exchange2010.zip
Normal file
BIN
nsclient/trunk/scripts/check_exchange/Exchange2010.zip
Normal file
Binary file not shown.
103
nsclient/trunk/scripts/check_exchange/MailboxHealth.ps1
Normal file
103
nsclient/trunk/scripts/check_exchange/MailboxHealth.ps1
Normal file
@@ -0,0 +1,103 @@
|
||||
# Test Mailbox Database Health
|
||||
#
|
||||
# This script will look at all mailbox databases
|
||||
# and determine the status of each.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# Originally created by Jeff Roberson (jeffrey.roberson@gmail.com)
|
||||
# at Bethel College, North Newton, KS
|
||||
#
|
||||
# Revision History
|
||||
# 5/10/2010 Jeff Roberson Creation
|
||||
#
|
||||
# To execute from within NSClient++
|
||||
#
|
||||
#[NRPE Handlers]
|
||||
#check_mailbox_health=cmd /c echo C:\Scripts\Nagios\MailboxHealth.ps1 | PowerShell.exe -Command -
|
||||
#
|
||||
# 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 = ""
|
||||
|
||||
ForEach ($DataBase in Get-MailboxDatabase) {
|
||||
ForEach ($Status in Get-MailboxDatabaseCopyStatus -Identity $DataBase.Name) {
|
||||
switch ($Status.Status) {
|
||||
"Failed" {
|
||||
$NagiosStatus = "2"
|
||||
if ($NagiosDescription -ne "") {
|
||||
$NagiosDescription = $NagiosDescription + ", "
|
||||
}
|
||||
$NagiosDescription = $NagiosDescription + $Status.Name + " is " + $Status.Status
|
||||
}
|
||||
|
||||
"Dismounted" {
|
||||
$NagiosStatus = "2"
|
||||
if ($NagiosDescription -ne "") {
|
||||
$NagiosDescription = $NagiosDescription + ", "
|
||||
}
|
||||
$NagiosDescription = $NagiosDescription + $Status.Name + " is " + $Status.Status
|
||||
}
|
||||
|
||||
"Resynchronizing" {
|
||||
if ($NagiosStatus -ne "2") {
|
||||
$NagiosStatus = "1"
|
||||
}
|
||||
if ($NagiosDescription -ne "") {
|
||||
$NagiosDescription = $NagiosDescription + ", "
|
||||
}
|
||||
$NagiosDescription = $NagiosDescription + $Status.Name + " is " + $Status.Status
|
||||
}
|
||||
|
||||
"Suspended" {
|
||||
if ($NagiosStatus -ne "2") {
|
||||
$NagiosStatus = "1"
|
||||
}
|
||||
if ($NagiosDescription -ne "") {
|
||||
$NagiosDescription = $NagiosDescription + ", "
|
||||
}
|
||||
$NagiosDescription = $NagiosDescription + $Status.Name + " is " + $Status.Status
|
||||
}
|
||||
|
||||
"Mounting" {
|
||||
if ($NagiosStatus -ne "2") {
|
||||
$NagiosStatus = "1"
|
||||
}
|
||||
if ($NagiosDescription -ne "") {
|
||||
$NagiosDescription = $NagiosDescription + ", "
|
||||
}
|
||||
$NagiosDescription = $NagiosDescription + $Status.Name + " is " + $Status.Status
|
||||
}
|
||||
|
||||
"Healthy" {}
|
||||
"Mounted" {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Output, what level should we tell our caller?
|
||||
if ($NagiosStatus -eq "2") {
|
||||
Write-Host "CRITICAL: " $NagiosDescription
|
||||
} elseif ($NagiosStatus -eq "1") {
|
||||
Write-Host "WARNING: " $NagiosDescription
|
||||
} else {
|
||||
Write-Host "OK: All Mailbox Databases are mounted and healthy."
|
||||
}
|
||||
|
||||
exit $NagiosStatus
|
||||
@@ -0,0 +1,58 @@
|
||||
# Test to see if the Public Folders database is mounted on this server
|
||||
#
|
||||
# The error handling is a little muddled coming back from the cmdlet
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# Originally created by Jeff Roberson (jeffrey.roberson@gmail.com)
|
||||
# at Bethel College, North Newton, KS
|
||||
#
|
||||
# Revision History
|
||||
# 5/10/2010 Jeff Roberson Creation
|
||||
#
|
||||
# To execute from within NSClient++
|
||||
#
|
||||
#[NRPE Handlers]
|
||||
#check_publicfolders_mounted=cmd /c echo C:\Scripts\Nagios\PublicFoldersMounted.ps1 | PowerShell.exe -Command -
|
||||
#
|
||||
# On the check_nrpe command include the -t 20, since it takes some time to load
|
||||
# the Exchange cmdlet's.
|
||||
|
||||
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
|
||||
|
||||
$NagiosResult = "0"
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
$Result = Get-PublicFolder -Server $env:computername -ErrorAction Stop
|
||||
Write-Host "OK: Public folders are mounted."
|
||||
}
|
||||
catch [System.Management.Automation.ActionPreferenceStopException]
|
||||
{
|
||||
Throw $_.exception
|
||||
}
|
||||
catch
|
||||
{
|
||||
Throw $_.exception
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Host "CRITICAL: Public Folders Database is dismounted."
|
||||
$NagiosResult = "2"
|
||||
}
|
||||
|
||||
exit $NagiosResult
|
||||
80
nsclient/trunk/scripts/check_exchange/ReplicationHealth.ps1
Normal file
80
nsclient/trunk/scripts/check_exchange/ReplicationHealth.ps1
Normal file
@@ -0,0 +1,80 @@
|
||||
# Test Replication Health
|
||||
#
|
||||
# This script will execute the Test-ReplicationHealth command
|
||||
# and look for warnings for failed replication attemtps
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# Originally created by Jeff Roberson (jeffrey.roberson@gmail.com)
|
||||
# at Bethel College, North Newton, KS
|
||||
#
|
||||
# Revision History
|
||||
# 5/10/2010 Jeff Roberson Creation
|
||||
#
|
||||
# To execute from within NSClient++
|
||||
#
|
||||
#[NRPE Handlers]
|
||||
#check_replication_health=cmd /c echo C:\Scripts\Nagios\ReplicationHealth.ps1 | PowerShell.exe -Command -
|
||||
#
|
||||
# On the check_nrpe command include the -t 20, since it takes some time to load
|
||||
# the Exchange cmdlet's.
|
||||
|
||||
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
|
||||
|
||||
$NagiosStatus = "0"
|
||||
$NagiosDescription = ""
|
||||
|
||||
ForEach ($Type in Test-ReplicationHealth -Identity $env:computername) {
|
||||
|
||||
# Look for failed replications
|
||||
if ($TypeResult -like "*FAILED*") {
|
||||
# Format the output for Nagios
|
||||
if ($NagiosDescription -ne "") {
|
||||
$NagiosDescription = $NagiosDescription + ", "
|
||||
}
|
||||
|
||||
$NagiosDescription = $NagiosDescription + $Type.Check + $Type.Result
|
||||
|
||||
# Set the status to failed.
|
||||
$NagiosStatus = "2"
|
||||
|
||||
# Look for warnings in replication
|
||||
} elseif ($Type.Check -like "*Warn*") {
|
||||
# Format the output for Nagios
|
||||
if ($NagiosDescription -ne "") {
|
||||
$NagiosDescription = $NagiosDescription + ", "
|
||||
}
|
||||
|
||||
$NagiosDescription = $NagiosDescription + $Type.Check + $Type.Result
|
||||
|
||||
# Don't lower the status level if we already have
|
||||
# a failed attempt
|
||||
if ($NagiosStatus -ne "2") {
|
||||
$NagiosStatus = "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Output, what level should we tell our caller?
|
||||
if ($NagiosStatus -eq "2") {
|
||||
Write-Host "CRITICAL: " + $NagiosDescription
|
||||
} elseif ($NagiosStatus -eq "1") {
|
||||
Write-Host "WARNING: " + $NagiosDescription
|
||||
} else {
|
||||
Write-Host "OK: All replication tests passed."
|
||||
}
|
||||
|
||||
exit $NagiosStatus
|
||||
|
||||
1
nsclient/trunk/scripts/check_exchange/test.bat
Normal file
1
nsclient/trunk/scripts/check_exchange/test.bat
Normal file
@@ -0,0 +1 @@
|
||||
start powershell c:\program files\nsclient++\scripts\check_exchange\MailboxHealth.ps1
|
||||
Reference in New Issue
Block a user