sus42

A Blog on Wndows Server and Microsoft Exchange by Thomas Pätzold

Monitoring Microsoft Exchange 2010 with NAGIOS

with 2 comments


If you want to monitor your Microsoft Exchange 2010 environment you have to choose a client which communicates with the NAGIOS Server. A popular client application is NSCLIENT++. If you want to monitor your Exchange System it is necessary to write your own monitoring script which is executed on the monitored system. In order to do so you can use the NRPE (Nagios Remote Plugin Executor) Plugin which is supported by NSCLIENT++.

Each output of the script will be displayed by NAGIOS. So the first challenge is to start the Exchange Shell without any status output. After this you can script your monitoring algorithm. At the end of the script you have to exit this script with the exit code.

value description
0 no error
1 Warning
2 Error

The following script monitors the status of a mailbox database. If the status isn´t healthy or mounted the script will return an error and NAGIOS itsself will display this Service as not available or red.

# initialisiere Exchangeumgebung
$s = new-pssession -configurationname microsoft.exchange -connectionuri http://mbx.aixtest.de/PowerShell/ -authentication Kerberos
$warningpreference = "SilentlyContinue"
Import-PSSession $s 2>&1 | out-null

##### MAIN #####
# variabledeklaration
[system.string]$errortext=""
[system.Byte]$errorvalue=0
[System.string]$mounted=""
[System.string]$healthy=""

$MailboxDatabases = Get-MailboxDatabaseCopyStatus
foreach ($mailboxdatabase in $mailboxdatabases) {
	switch ($mailboxdatabase.Status) {
		Healthy {$healthy += " " + $mailboxdatabase.Identity}
		Mounted {$mounted += " " + $mailboxdatabase.Identity}
		Default {$errorvalue=2;	$errortext += "Not Mounted or Healthy: " + $mailboxdatabase.Identity}
	}
}
if ($mounted.length -eq 0) {$mounted="-"}
if ($healthy.length -eq 0) {$healthy="-"}
$errortext += "Mounted: "+$mounted + "Healthy: "+$healthy
write-output $errortext
exit $errorvalue
Advertisements

Written by Thomas Pätzold

January 6, 2011 at 9:31 pm

2 Responses

Subscribe to comments with RSS.

  1. This specific posting, “Monitoring Microsoft Exchange 2010 with NAGIOS � sus42” illustrates that
    u really fully understand what precisely u r
    talking about! I really thoroughly agree with your blog.
    Thanks a lot -Laurene

    Laurence

    January 17, 2013 at 3:57 am

  2. It seems like u truly know plenty with regards to this issue and it shows thru this
    specific blog, given the name “Monitoring Microsoft
    Exchange 2010 with NAGIOS � sus42”. Many thanks
    ,Mildred

    Mildred

    January 9, 2013 at 11:33 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: