D
D
Dmitry2016-01-18 11:18:05
PowerShell
Dmitry, 2016-01-18 11:18:05

How to create powershell sensor PRTG Network Monitor for Microsoft Exchange?

Greetings!
I am creating a sensor for PRTG Network Monitor to monitor the status of databases.
There is such a powershell / xml script, everything works.
How to make PRTG Network Monitor count:
When False states are OK
When Active states are Error
Now in both states PRTG considers OK.

$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

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2016-01-19
@dukedizel

I finally found the correct format:

<result> 
        <channel>$dbname</channel> 
        <value>$dbvalue</value> 
        <showChart>1</showChart> 
        <showTable>1</showTable> 
        <limitmode>1</limitmode>
        <LimitMinError>2</LimitMinError>
        <LimitMaxError>2</LimitMaxError>
        <LimitMinWarning>10</LimitMinWarning>
        <LimitMaxWarning>10</LimitMaxWarning>
        <LimitErrorMsg>Your error message</LimitErrorMsg>
        <LimitWarningMsg>Your Warning message</LimitWarningMsg>
  </result>

A
Alexander Nikitin, 2016-01-19
@padla2k

Swap the values ​​(False - 2, Active - 1) and use <LimitMinError>1</LimitMinError>(do not forget to also enable <LimitMode>1<LimitMode>.
And also, after changing the sensor, you need to recreate it (or enable limits manually for already created sensors) - limits are not included via xml after sensor creation (only While creating).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question