Hello! I'm copy/write powershell xml script for monitoring Exchange DB Status.
$servername = "servermbx" $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 | select name,ActiveCopy $dbcount = (Get-MailboxDatabaseCopyStatus).count $prtg = '<?xml version="1.0" encoding="Windows-1252" ?> <prtg>' foreach ($db in $dbstatus) { $dbname = $db.Name $dbstate = $db.ActiveCopy $dbvalue = "10" if ($dbstate -match "False") { $dbvalue = "1" } if ($dbstate -match "Active") { $dbvalue = "2" } $prtg +=" <result> <channel>$dbname</channel> <value>$dbvalue</value> <showChart>1</showChart> <showTable>1</showTable> <mode>Absolute</mode> </result> " } $prtg +="<text>The number of databases: $dbcount</text> </prtg>" remove-pssession -session $pssession $prtg
How i can edit this script or this:
When state of database False - sensor OK, state of database - Active - Sensor Error.
Now, in both cases state False or Active PRTG monitor say what sensor is Ok.
Article Comments
Could you give me example on my script? I try add <Error>2</Error> but it's not work.
Jan, 2016 - Permalink
Dear dukedizel
An example output is
<prtg> <error>1</error> <text>Your error message</text> </prtg>
Please find the full documentation in the API manual which is integrated into the PRTG webinterface: Setup | PRTG API, tab "Custom Sensors".
Jan, 2016 - Permalink
My sensor:
<?xml version="1.0" encoding="Windows-1252" ?>
<prtg>
<result>
<channel>Moscow VIP Users\SRVMBX250</channel>
<value>2</value>
<showChart>1</showChart>
<showTable>1</showTable>
<mode>Absolute</mode>
<error>2</error>
<text>Your error message</text>
</result>
<text>The number of databases: 3</text>
</prtg>
limits do not work ... I create a new sensor but the sensor configured channel limits are not settable.
what am I doing wrong?
Jan, 2016 - Permalink
Dear dukedizel
If you open the sensor channel configuration by clicking on its gauge, you should be able to enable and set the limits. Please clarify in which sense the limits are not settable.
Jan, 2016 - Permalink
I form this:
<?xml version="1.0" encoding="Windows-1252" ?>
<prtg>
<result>
<channel>Moscow VIP Users\SRVMBX250</channel>
<value>2</value>
<showChart>1</showChart>
<showTable>1</showTable>
<mode>Absolute</mode>
<error>2</error>
<text>Your error message</text>
</result>
<text>The number of databases: 3</text>
</prtg>
I see this sensor in PRTG but Limits not settable automatically. Parameters <error>2</error> are not taken from the file. I have to put limits manually.
Jan, 2016 - Permalink
The error limits must be defined in the XML output and are only read when the sensor created (i.e. they can't be changed after created). The following XML values have to be present:
<limitmode>1</limitode> <!-- mandatory !--> <LimitMinError>10</LimitMinError> <LimitMaxError>10</LimitMaxError> <LimitMinWarning>10</LimitMinWarning> <LimitMaxWarning>10</LimitMaxWarning> <LimitErrorMsg>Your error message</LimitErrorMsg> <LimitWarningMsg>Your Warning message</LimitWarningMsg>
Set the Limit tags according to your needs :) Further information can be found on
http://<your-prtg-server>/api.htm?tabid=7
Jan, 2016 - Permalink
Log:
<?xml version="1.0" encoding="Windows-1252" ?> <prtg> <result> <channel>Moscow VIP Users\SRVMBX250</channel> <value>2</value> <showChart>1</showChart> <showTable>1</showTable> <limitmode>1</limitode> <LimitMinError>2</LimitMinError> <LimitMaxError>2</LimitMaxError> <LimitMinWarning>10</LimitMinWarning> <LimitMaxWarning>10</LimitMaxWarning> <LimitErrorMsg>Your error message</LimitErrorMsg> <LimitWarningMsg>Your Warning message</LimitWarningMsg> </result> <text>The number of databases: 3</text> </prtg>
Error
Jan, 2016 - Permalink
Whoops, typo - my bad:
<limitmode>1</limitmode>
Forgot the m in </limitmode> :)
Jan, 2016 - Permalink
Dear dukedizel
There are two options to set a sensor to an error status
The latter approach allows to also return monitoring values, even though the sensor is in the alarm state.
Jan, 2016 - Permalink