Each of the systems need a special tool to display this information. On Mac OS you can use „Geeklets“ it is free and easy to install. On Linux you can use „conky“.
Both tools are easy to use with a big community behind. To display values on your desktop you have to do a couple of things on your PRTG.
This is maybe not best practise, but for me it is the easiest way to handle.
- Create a new User in PRTG (maybe name him “monitor“)
- give him rights to see all the sensors
- test it by passing this URL to your browser, if you get information, you are right ;) ('https://<<PRTG-Server-Name>>/api/getstatus.htm?id=0&username=<<username / monitor>> &password=<<password>> )
Till now the tutorial is only for Mac OS, but you can use this „snippet“ to conky on linux, too.
Create a new „Shell“ object and take him this command:
#!/bin/bash
getapi=$(curl 'https:// ://<<PRTG-Server-Name>>/api/getstatus.htm?id=0&username=<<username / monitor>> &password=<<password>>')
NewAlarms=$( echo $getapi | sed -e 's/[{}]/''/g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | grep "NewAlarms" | awk '{print $2}' | awk -F'[""]' '{print $2}')
if [ $NewAlarms -ne "0" ]; then
NewAlarms=$(printf "\e[41mNeue Alarme: "$NewAlarms)
echo -e $NewAlarms "\033[0m"
else
NewAlarms=$(printf "Neue Alarme: "$NewAlarms)
echo -e $NewAlarms "\033[0m"
fi
Fill out the information in the „<<>>“ ;).
First you will get the JSON-Object from PRTG-API. Than you form the object to the value you need (yes this could be easier, but this is how to understand the way ;)). With „grep“ we will match the line we want to get (in this example „NewAlarms“) and take it to the „If-Else“. If the value is „-ne“ (not equal) to „0“ than the Sensor is grey without warn status. If the value didn’t matches, than the output is red with warning.
You can do it with every value you want.
API-Documentation: https://www.paessler.com/manuals/prtg/application_programming_interface_api_definition
Example:
Maybe this was helpful to you ☺
Best
Sascha
Add comment