I have a XML/REST Value sensor working fine, unfortunately, the XML return value is a string, not a numeric value. We would like to receive the string, and use a custom lookup to convert translate to the PRTG state.
Something like this, within the lookup .ovl file -
<SingleInt state="OK" value="Up"> Service is UP </SingleInt>
Is there a way to do this with the XML/REST value sensor, or should I use a different sensor?
Article Comments
Ok, thanks. I had a feeling that might be the case.
I have been working on a custom SSH script that pulls the JSON encoded data, parses it, then returns a prtg-readable result. Looks like I'm on the right track.
Thanks!
Oct, 2014 - Permalink
Note that we also have a XML/REST available, it also works with JSON:
https://www.paessler.com/manuals/prtg/http_xmlrest_value_sensor.htm
Maybe you can use this one before you put any work into that script :)
Nov, 2014 - Permalink
Hi Stephan.
Yes, that is where I started. But that sensor does not process string (text) values. Only numeric values. Note that I'm looking to process a value of "UP". This is not something the XML/REST sensor can do. At least not yet.
Nov, 2014 - Permalink
Hi Paesler Team , was there a way to solve the same problem without the use of additional scripts, add-ons of the sensor, or by changing the custom lookup ?
Oct, 2018 - Permalink
Hi there,
You could take a look at the Rest Custom Sensor of PRTG which offers you more options. For example to check if the Value "Up" is found in a specific node you could use:
{ "prtg": { "text": $.some.node, "result": [ { "channel": "Total", "value": lookup($.some.node, "Up"), "limitmode": 1, "LimitMinError": 0, "LimitErrorMsg": "The value for 'node' is not 'Up'!" } ] } }
Best regards.
Oct, 2018 - Permalink
I am completely confused in the sensor REST Custom. I ask you to help. I do not quite have a standard response from the device I want to monitor, when requested "http://1.1.1.1:2222/default/en_US/status.xml" (GoIP GSM-gateway)
I get such an answer
<status> <l1_module_status_gsm>1</l1_module_status_gsm> <l1_module_title_gsm/> <l1_module_status><a href="?type=list&down=1&line=1">Y</a></l1_module_status> <l1_module_title>Click to shut down module</l1_module_title> <l1_gsm_sim>Y</l1_gsm_sim> <l1_gsm_status>Y</l1_gsm_status> <l1_status_line>Y</l1_status_line> <l1_line_state>IDLE</l1_line_state> <l1_sms_login/> <l1_smb_login><font color="#FF0000">N</font></l1_smb_login> <l1_gsm_signal>19</l1_gsm_signal> <l1_gsm_cur_oper>MegaFon</l1_gsm_cur_oper> <l1_gsm_cur_bst/> <l1_lac/> <l1_sim_remain>NO LIMIT</l1_sim_remain> <l1_nocall_t>0</l1_nocall_t> <l1_acd>95</l1_acd> <l1_asr>18</l1_asr> <l1_callt>2118m</l1_callt> <l1_callc>1827/10575</l1_callc> <l1_rct>2018-09-06 04:00:46</l1_rct> <l1_sms_count>NO LIMIT</l1_sms_count> <l1_call_count>NO LIMIT</l1_call_count> <l2_module_status_gsm>2</l2_module_status_gsm> <l2_module_title_gsm/> <l2_module_status><a href="?type=list&down=1&line=2">Y</a></l2_module_status> <l2_module_title>Click to shut down module</l2_module_title> <l2_gsm_sim>Y</l2_gsm_sim> <l2_gsm_status>Y</l2_gsm_status> <l2_status_line>Y</l2_status_line> <l2_line_state>IDLE</l2_line_state> <l2_sms_login/> <l2_smb_login><font color="#FF0000">N</font></l2_smb_login> <l2_gsm_signal>25</l2_gsm_signal> <l2_gsm_cur_oper>MegaFon</l2_gsm_cur_oper> <l2_gsm_cur_bst/> <l2_lac/> <l2_sim_remain>NO LIMIT</l2_sim_remain> <l2_nocall_t>0</l2_nocall_t> <l2_acd>85</l2_acd> <l2_asr>17</l2_asr> <l2_callt>1509m</l2_callt> <l2_callc>1280/7861</l2_callc> <l2_rct>2018-09-06 04:00:46</l2_rct> <l2_sms_count>NO LIMIT</l2_sms_count> <l2_call_count>NO LIMIT</l2_call_count> </status>
I need only these lines
<l1_gsm_sim>Y</l1_gsm_sim> <l1_gsm_status>Y</l1_gsm_status> <l1_status_line>Y</l1_status_line> <l1_gsm_signal>19</l1_gsm_signal>
The status "Y" is good, the status "N" is an accident, but in the event of an accident the next line comes
<l1_gsm_sim><font color="#FF0000"></font></l1_gsm_sim> <l1_gsm_status><font color="#FF0000">N</font></l1_gsm_status> <l1_status_line><font color="#FF0000">N</font></l1_status_line> <l1_gsm_signal>0</l1_gsm_signal>
It is desirable in one sensor, with the ability to turn on the alarm when the status changes.
Oct, 2018 - Permalink
Hi there,
Unfortunately, the above "XML"-structure cannot be monitored as is it not an XMl structure. It looks more like HTML mixed with a XML-like structure, which the parser we use is not able to parse because of these lines:
<l1_module_status><a href="?type=list&down=1&line=1">Y</a></l1_module_status> |
<l2_module_status><a href="?type=list&down=1&line=2">Y</a></l2_module_status> |
And later because of the following within the "<l1_gsm_sim>"-node:
<font color="#FF0000"></font> |
Maybe there is another API available that also outputs JSON or a clean XML structure?
Best regards.
Oct, 2018 - Permalink
PRTG lookups can only interpret numeric values. We have reversal lookups on our wishlist, but this may take a while. Please bear with us one this one.
In the meantime, you might need a custom PowerShell that does the evalution of the values :)
Oct, 2014 - Permalink