Site icon Franky's Web

Exchange 2010 Monitoring via PRTG

I set PRTG for monitoring of my systems, the monitoring options are manifold. PRTG even comes with a whole set of sensors for Exchange.

At first glance, you will be overwhelmed by the over 100 sensors that PRTG provides for a single Exchange server. But after I pruned the sensors a little, I realized that some important information was missing.

For example, no DAG is monitored, and the status of the databases is also not monitored directly. However, PRTG can also be used to create its own sensors, so PRTG is able to obtain the information that the admin wants to see via a script. I have therefore created my own script which sends the status of the databases to PRTG.

# www.FrankysWeb.de

$servername = „Exchange.domain.local“

#—————————————
$pssession = new-pssession -configurationname „Microsoft.Exchange“ -connectionuri „http://$servername/Powershell“ -Authentication Kerberos
$startsession = import-pssession -session $pssession -allowclobber -WarningAction SilentlyContinue | out-null

$dbstatus = get-mailboxdatabasecopystatus
$dbcount = (Get-MailboxDatabaseCopyStatus).count

$prtg = ‚<?xml version=“1.0″ encoding=“Windows-1252″ ?>
<prtg>

foreach ($db in $dbstatus)
{
$dbname = $db.Name
$dbstate = $db.Status
$dbvalue = „10“
if ($dbstate -match „Mounted“)
{
$dbvalue = „1“
}
if ($dbstate -match „Dismounted“)
{
$dbvalue = „2“
}
if ($dbstate -match „Healthy“)
{
$dbvalue = „3“
}

$prtg +=“ <result>
$dbname
$dbvalue
1
1
Absolute
</result>
"
}

$prtg +=“<text>Anzahl der Datenbanken: $dbcount</text>
</prtg>“
remove-pssession -session $pssession
$prtg

The script returns an XML output which can be processed via PRTG

Using the program/script sensor, you can display all the information that is of interest. For example, there are RoundTrip sensors that monitor whether a mail is being sent. However, as I have no influence on my provider's mail server, I only use this script to check whether a mail has been delivered to the target mailbox

# www.FrankysWeb.de

$servername = „SMAIL01.frankysweb.local“
$from = „prtg@frankysweb.de“
$to = „frank@frankysweb.de“

#—————————————
$pssession = new-pssession -configurationname „Microsoft.Exchange“ -connectionuri „http://$servername/Powershell“ -Authentication Kerberos
$startsession = import-pssession -session $pssession -allowclobber -WarningAction SilentlyContinue | out-null

$subject = get-date -Format ddMMyyyyHHmm
Send-MailMessage -from $from -To $to -Subject „$subject“ -SmtpServer $servername

$mail = Get-MessageTrackingLog -MessageSubject $subject -EventId Deliver

$mailstatus = $mail.EventId
if ($mailstatus -match „Deliver“)
{
$state = „1“
}
else
{
$state = „0“
}

$prtg = ‚<?xml version=“1.0″ encoding=“Windows-1252″ ?>‘
$prtg +=“<prtg>“
$prtg += “
<result>
Internal mail dispatch
$state
1
1
Absolute
</result>“
$prtg +=“</prtg>“
remove-pssession -session $pssession
$prtg

The possibilities are manifold. The scripts only return a status code, this status code can be output in PRTG itself in meaningful values, for example 0 for OK, 1 for warning, 2 for error.

Those who familiarize themselves with the subject matter will certainly enjoy it

msXfaq also provides great scripts for PRTG:

http://www.msxfaq.net/tools/prtgexchange.htm

By the way: There is a small PRTG version available free of charge, but it is limited to a few sensors.

Exit mobile version