What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

HTTP XML/Rest vaule sensor Input ":" character to XML Node

Votes:

0

Hi Paessler

I have a http url which would return the below json file. Just want to setup a sensor that would check the value of name2:389/monitor if it's equal "available". I tried with HTTP XML/Rest vaule sensor but it could not pick up the node value as name2:389/monitor. The error it returning is "389/monitor' has an invalid token.", I believe this might be because of the ":" character.

Could you please advise if there is a way to work around this?

{
  "name1:389": {
    "admin": "enabled", 
    "connections": 14, 
    "ip": "1.1.1.1.1.1.1", 
    "monitor": "available"
  }, 
  "name2:389": {
    "admin": "enabled", 
    "connections": 9, 
    "ip": "1.1.1.1.1.1.1", 
    "monitor": "available"
  }, 
  "name3:389": {
    "admin": "enabled", 
    "connections": 12, 
    "ip": "1.1.1.1.1.1", 
    "monitor": "available"
  }, 
  "up": 3
} 

Thanks and regards

http-xml-rest-value-sensor json special-characters

Created on Mar 24, 2017 6:25:07 AM



5 Replies

Accepted Answer

Votes:

0

You can't do string comparisons in this sensor. Simply use the following: //*[name()='name2:389']/monitor[text()='available']

...and the following lookup:

<?xml version="1.0" encoding="UTF-8"?>
  <ValueLookup id="prtg.standardlookups.xml.monitor" desiredValue="1" undefinedState="None">
    <Lookups>
      <SingleInt state="Ok" value="1">
        Monitor available!
      </SingleInt>
      <SingleInt state="Error" value="0">
        Monitor unavailable!
      </SingleInt>
    </Lookups>
  </ValueLookup>

Created on Mar 24, 2017 11:32:14 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hi Stephan,

Thank you for your help, I'm able to get the sensor to return a value. However, I'm not sure if it's working properly as it return value 0 (or "Monitor unavailable" base on the look up file) even though the value is available.

Node //*[name()='toyent01.389']/monitor[text()='available'] holds value available.

I'm guessing [text()='available'] is where it try to match the value?

So I tried changing the node to see the return int value

//*[name()='toyent01.389']/monitor[text()='notavailable']

and got the below message

Node //*[name()='toyent01.389']/monitor[text()='notavailable'] not found in xml result.

Could you please advise if I'm missing? If this is not possible to achieve with this sensor, is there any other out-of-the-box options that I can set this up? or would it be better to write a custom exe for this?

Created on Mar 24, 2017 1:44:50 PM



Votes:

0

My bad - did you actually set the setting "Sensor Value" to
Use the number of occurrences of the selected XML node or its children/siblings? Then my attempt will work :)

Created on Mar 27, 2017 6:50:55 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hi Stephan,

Sorry for the late response, it's working now after I change the "Sensor Value" as you advised.

Thanks you very much for your help

Created on May 18, 2017 1:08:50 AM



Votes:

0

You're welcome! :)

Created on May 18, 2017 10:44:38 AM by  Stephan Linke [Paessler Support]




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.