Mit Hilfe des REST Custom BETA Sensor möchte ich den Status von id 0 bis 5 monitoren. Der Statuswert wird mit "UP" bzw. "DOWN" zurückgegeben. Mit dem Template, abgeleitet aus https://kb.paessler.com/en/topic/81363-create-custom-configuration-template-file-for-rest-custom-sensor soll der Rückgabewert übersetzt werden.
Dies scheint auch zu funktionieren, solange alle Werte auf "UP" stehen. Ist der Wert von Index 2 wie im Beispiel auf "DOWN", erscheint im Sensor-Resultat "502 Service Unavailable" und der gesammte Sensor geht auf Fehler. Wie hat das Template auszusehen, damit "UP" als OK und "DOWN" als ERROR dargestellt werden kann - oder noch besser - "UP" als OK und alle anders lauteneden Werte als ERROR?
Abfrage URL - status der id 2 ist "DOWN"
{ "checks": [{ "id": "Osv", "status": "UP", "data": { "Enabled": true, "Cron": "0 0 4 1/1 * ? *", "Server1": "http://172.18.250.20:8767/cgi-bin/soapServer", "Server2": "http://172.18.253.20:8767/cgi-bin/soapServer", "Running": false } }, { "id": "KMS_NEDI", "status": "UP", "data": { "Enabled": true, "Cron": "0 44 5 1/1 * ? *", "IpRegex": "(?i)\\b172\\.18\\..*?\\b", "UrlKms": "https://www.zi.uzh.ch/cl/dl/dn/exports/tas/kms.csv", "UrlNedi": "https://www.zi.uzh.ch/cl/dl/dn/exports/tas/nedi.csv", "RunningKms": false, "RunningNedi": false } }, { "id": "Events", "status": "DOWN", "data": { "Queued": "#Events 3", "Enabled": true, "Cron": "0 5,35 9,10,11,12,13,14,15 1/1 * ? *" } }, { "id": "Database", "status": "UP", "data": { "URL": "jdbc:mysql://mariadb.uzh.ch:3312/tas?autoReconnect=true&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Europe/Zurich", "Connection": "#DB rows 11" } }, { "id": "Xpression", "status": "UP", "data": { "Enabled": true, "Cron": "0 30 4 1/1 * ? *", "ImportPath": "/data/import/xpression", "DonePath": "/data/import/xpression/done", "PhonePrefix": "+414463", "Running": false } }, { "id": "Application", "status": "UP", "data": { "Version": "1.4.1", "Revision": "be0f6d1751a1da94baa19ac92a880567731ddfab", "BuildTime": "12-12-2019 16:56:43", "Port": 15200, "API": "ORDER/V1" } }], "outcome": "DOWN" }
Result Sensor
{ "prtg": { "Error": "1", "Text": "Cannot load endpoint http://idtasappl1.uzh.ch:15200/health: expected status 200 OK but got 503 Service Unavailable." } }
Abfrage URL - status aller ids sind "UP"
{ "checks": [{ "id": "Osv", "status": "UP", "data": { "Enabled": true, "Cron": "0 5 4 1/1 * ? *", "Server1": "http://172.18.250.20:8767/cgi-bin/soapServer", "Server2": "http://172.18.253.20:8767/cgi-bin/soapServer", "Running": false } }, { "id": "KMS_NEDI", "status": "UP", "data": { "Enabled": true, "Cron": "0 49 5 1/1 * ? *", "IpRegex": "(?i)\\b172\\.18\\..*?\\b", "UrlKms": "https://www.zi.uzh.ch/cl/dl/dn/exports/tas/kms.csv", "UrlNedi": "https://www.zi.uzh.ch/cl/dl/dn/exports/tas/nedi.csv", "RunningKms": false, "RunningNedi": false } }, { "id": "Events", "status": "UP", "data": { "Queued": "#Events 0", "Enabled": true, "Cron": "0 7,37 9,10,11,12,13,14,15 1/1 * ? *" } }, { "id": "Database", "status": "UP", "data": { "URL": "jdbc:mysql://mariadb.uzh.ch:3312/tas_test?autoReconnect=true&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Europe/Zurich", "Connection": "#DB rows 11" } }, { "id": "Xpression", "status": "UP", "data": { "Enabled": true, "Cron": "0 35 4 1/1 * ? *", "ImportPath": "/data/import/xpression", "DonePath": "/data/import/xpression/done", "PhonePrefix": "+414463", "Running": false } }, { "id": "Application", "status": "UP", "data": { "Version": "1.4.1", "Revision": "4225963007b4c3928f6180a165a11ad107992daa", "BuildTime": "19-12-2019 18:59:59", "Port": 15200, "API": "ORDER/V1" } }], "outcome": "UP" }
Result Sensor
{ "prtg": { "result": [ { "channelid": 0, "Value": 5, "Unit": "TimeResponse", "ShowChart": 0, "ShowTable": 0 }, { "channel": "OSV", "Value": 0, "LimitMinError": 0, "LimitErrorMsg": "The value for 'node' is not 'Up'!", "LimitMode": 1 }, { "channel": "KMS_Nedi", "Value": 0, "LimitMinError": 0, "LimitErrorMsg": "The value for 'node' is not 'Up'!", "LimitMode": 1 }, { "channel": "Events", "Value": 0, "LimitMinError": 0, "LimitErrorMsg": "The value for 'node' is not 'Up'!", "LimitMode": 1 }, { "channel": "Database", "Value": 0, "LimitMinError": 0, "LimitErrorMsg": "The value for 'node' is not 'Up'!", "LimitMode": 1 }, { "channel": "Xpression", "Value": 0, "LimitMinError": 0, "LimitErrorMsg": "The value for 'node' is not 'Up'!", "LimitMode": 1 }, { "channel": "Application", "Value": 0, "LimitMinError": 0, "LimitErrorMsg": "The value for 'node' is not 'Up'!", "LimitMode": 1 } ] } }
Verwendetes Template (ageleitet von Topic 81363)
{ "prtg": { "result": [ { "channel": "OSV" , "value": lookup ($.checks[0].status, "UP"), "limitmode": 1, "LimitMinError": 0, "LimitErrorMsg": "The value for 'node' is not 'Up'!" }, { "channel": "KMS_Nedi" , "value": lookup ($.checks[1].status, "UP"), "limitmode": 1, "LimitMinError": 0, "LimitErrorMsg": "The value for 'node' is not 'Up'!" }, { "channel": "Events" , "value": lookup ($.checks[2].status, "UP","DOWN"), "limitmode": 1, "LimitMinError": 0, "LimitErrorMsg": "The value for 'node' is not 'Up'!" }, { "channel": "Database" , "value": lookup ($.checks[3].status, "UP"), "limitmode": 1, "LimitMinError": 0, "LimitErrorMsg": "The value for 'node' is not 'Up'!" }, { "channel": "Xpression" , "value": lookup ($.checks[4].status, "UP"), "limitmode": 1, "LimitMinError": 0, "LimitErrorMsg": "The value for 'node' is not 'Up'!" }, { "channel": "Application" , "value": lookup ($.checks[5].status, "UP"), "limitmode": 1, "LimitMinError": 0, "LimitErrorMsg": "The value for 'node' is not 'Up'!" } ] } }
Kanal Werte-Lookup -> prtg.standardlookups.aws.status.ovl
<?xml version="1.0" encoding="UTF-8"?>
<ValueLookup id="prtg.standardlookups.aws.status" desiredValue="0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd">
<Lookups>
<Boolean state="Ok" value="0">
Ok
</Boolean>
<Boolean state="Error" value="1">
Failed
</Boolean>
</Lookups>
</ValueLookup>
Add comment