This article applies as of PRTG 22
Can I create a sensor to alert the PRTG system admin if the number of Down, Paused, or Unknown sensors exceeds a specific threshold, essentially warning when too many errors are detected?
Monitoring sensors with a specific status via the REST Custom sensor
To monitor the number of sensors in a specific status, for example Paused or Unknown sensors, add a REST Custom sensor to your PRTG installation.
PRTG comes with a REST configuration template. This template retrieves a .json file via the PRTG API and parses it. The .json file contains the current number of all sensor states. Additionally, you can define sensor limits depending on your needs. Set up the sensor as follows:
Sensor setup
- Add a REST Custom sensor to your PRTG installation. Since we want to monitor PRTG itself, it makes sense to add the sensor to the probe device of the local probe (127.0.0.1).
- In the Add Sensor dialog, make sure to set the Request Protocol to the protocol you use to access PRTG (HTTP or HTTPS).
- Under Certificate Acceptance, select Accept all certificates.
- Provide the following URL in the REST Query:
/api/table.json?id=1&content=sensorxref&noraw=1&filter_basetype=probe&columns=totalsens=textraw,upsens=textraw,downsens=textraw,partialdownsens=textraw,warnsens=textraw,pausedsens=textraw,unusualsens=textraw,undefinedsens=textraw,downacksens=textraw&username=<USERNAME>&passhash=<PASSHASH>
Note: You need to replace the <USERNAME> and <PASSHASH> in the URL above with your own credentials for authentication. You can find the passhash under Setup | Account Settings | My Account | Passhash. - Under REST Configuration, select prtg-sensor-stats.template.
- Leave all other settings unchanged.
- Click Create to create the sensor.
- Define limits for warnings and alarms in the sensor’s channel settings.
This sensor now monitors the number of sensors in the defined status and shows the Warning or Down status depending on the defined limits.
Alternative Approach
I would suggest to use customized web page template for the PRTG webserver, that displays the number of sensors in paused/warning/OK etc. status, plus a HTTP content sensor, that monitors this value.
Step 1: Creating your own API function
- Create a new textfile "getsensorsbystate.htm" in the \website\api folder of your PRTG installation. Note: As of PRTG Network Monitor 13.2.3, the folder is \webroot\api. See this article for details.
- Edit the file in a text editor, paste the following code, and save the file:
[<#graph graphcontent="statusoverview" show="textraw">]
Step 2: Creating a HTTP Content sensor to monitor the value
Create a new HTTP Content sensor and enter the following URL:
http://yourprtgserver.ip/api/getsensorsbystate.htm?name=downsens&username=xyz&password=abc
This URL will display the total number of sensors which are in Error state (red), shown as a number between brackets [].
[8]
Please note: If there is no sensor in error state, the brackets will only contain a whitespace:
[ ]
The HTTP Content sensor reads this information and uses it as sensor values. Now your can use limits and triggers to send notifications.
The possible values for the "name" parameter are:
Name | Description |
---|---|
upsens | Up sensors |
downsens | Down sensors |
downacksens | Acknowledged Down alarms |
warnsens | Warning sensors |
unusualsens | Unusual sensors |
pausedsens | Paused sensors |
undefinedsens | Unknown sensors |
totalsens | Total sensors |
You can only request one value per request/sensor. So in order to monitor unknown and error sensors you need to set up two HTTP Content sensors.
For more information about using the HTTP API, have a look at the API documentation: How can I use the PRTG application programming interface (API)?
More
Disclaimer:
The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.