New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


HTTP Data Advanced - JSON response formatting

Votes:

0

Your Vote:

Up

Down

How should the XML response:

<prtg>
<result>
<channel>name</channel>
<value>1</value>
</result>
</prtg>

be formatted in JSON. My first guess was to do it like:

{"prtg": {
    "result": {
        "channel": "name",
        "value": "1"
    }
   }
}   

but it does not seem to work

api custom-sensor http-data-advanced json xml

Created on Sep 28, 2015 4:20:49 PM by  mcomspm (0) 1

Last change on Sep 6, 2016 12:01:53 PM by  Luciano Lingnau [Paessler Support]



Best Answer

Accepted Answer

Votes:

0

Your Vote:

Up

Down

For reference, this is an multi-channel example XML response supported by the HTTP Data Advanced sensor:

<?xml version="1.0" encoding="utf-8" ?>
<prtg>
	<result>
		<channel>Channel 1 (float)</channel>
		<value>12.3456</value>
		<float>1</float>
		<unit>custom</unit>
		<customunit>celsius</customunit>
	</result>
	<result>
		<channel>Channel 2 (integer)</channel>
		<value>42</value>
		<limitmode>1</limitmode>
		<limitmaxwarning>50</limitmaxwarning>
		<limitmaxerror>60</limitmaxerror>
	</result>
	<result>
		<channel>Channel 3 (lookup)</channel>
		<value>1</value>
		<valuelookup>prtg.standardlookups.exchangedag.yesno.stateyesok</valuelookup>
	</result>
	<result>
		<channel>Channel 4 (delta)</channel>
		<value>123456</value>
		<mode>difference</mode>
		<unit>bytesbandwidth</unit>
	</result>
	<text>The sensor's message</text>
</prtg>

And the same response in JSON for reference:

{
  "prtg": {
    "result": [
      {
        "channel": "Channel 1 (float)",
        "value": "12.3456",
        "float": "1",
        "unit": "custom",
        "customunit": "celsius"
      },
      {
        "channel": "Channel 2 (integer)",
        "value": "42",
        "limitmode": "1",
        "limitmaxwarning": "50",
        "limitmaxerror": "60"
      },
      {
        "channel": "Channel 3 (lookup)",
        "value": "1",
        "valuelookup": "prtg.standardlookups.exchangedag.yesno.stateyesok"
      },
      {
        "channel": "Channel 4 (delta)",
        "value": "123456",
        "mode": "difference",
        "unit": "bytesbandwidth"
      }
    ],
    "text": "The sensor's message"
  }
}

There are several online XML<->JSON converter tools, for instance:
http://www.utilities-online.info/xmltojson/


Best Regards,
Luciano Lingnau [Paessler Support]

Created on Sep 6, 2016 11:54:17 AM by  Luciano Lingnau [Paessler Support]

Last change on Jan 17, 2018 10:10:49 AM by  Luciano Lingnau [Paessler Support]



5 Replies

Votes:

0

Your Vote:

Up

Down

Hi,
are you referring to the output for an EXE Script Advanced sensor? If so, what is the error message when using JSON? Apart from that, the JSON looks correctly and should be picked up by PRTG.

Created on Sep 30, 2015 1:27:31 PM by  Konstantin Wolff [Paessler Support]



Votes:

0

Your Vote:

Up

Down

I am referring to HTTP advanced data sensor returning JSON not XML. We found a format that seems to work:

{
    "prtg": {
        "result": [
            {
                "channel": "name",
                "value": "1"
            }
        ]
     
    }
}

Ie it seems that 'channel' result objects must be placed in an array even if there is only one channel

Created on Sep 30, 2015 4:09:41 PM by  mcomspm (0) 1

Last change on Oct 2, 2015 11:14:33 AM by  Luciano Lingnau [Paessler Support]



Accepted Answer

Votes:

0

Your Vote:

Up

Down

For reference, this is an multi-channel example XML response supported by the HTTP Data Advanced sensor:

<?xml version="1.0" encoding="utf-8" ?>
<prtg>
	<result>
		<channel>Channel 1 (float)</channel>
		<value>12.3456</value>
		<float>1</float>
		<unit>custom</unit>
		<customunit>celsius</customunit>
	</result>
	<result>
		<channel>Channel 2 (integer)</channel>
		<value>42</value>
		<limitmode>1</limitmode>
		<limitmaxwarning>50</limitmaxwarning>
		<limitmaxerror>60</limitmaxerror>
	</result>
	<result>
		<channel>Channel 3 (lookup)</channel>
		<value>1</value>
		<valuelookup>prtg.standardlookups.exchangedag.yesno.stateyesok</valuelookup>
	</result>
	<result>
		<channel>Channel 4 (delta)</channel>
		<value>123456</value>
		<mode>difference</mode>
		<unit>bytesbandwidth</unit>
	</result>
	<text>The sensor's message</text>
</prtg>

And the same response in JSON for reference:

{
  "prtg": {
    "result": [
      {
        "channel": "Channel 1 (float)",
        "value": "12.3456",
        "float": "1",
        "unit": "custom",
        "customunit": "celsius"
      },
      {
        "channel": "Channel 2 (integer)",
        "value": "42",
        "limitmode": "1",
        "limitmaxwarning": "50",
        "limitmaxerror": "60"
      },
      {
        "channel": "Channel 3 (lookup)",
        "value": "1",
        "valuelookup": "prtg.standardlookups.exchangedag.yesno.stateyesok"
      },
      {
        "channel": "Channel 4 (delta)",
        "value": "123456",
        "mode": "difference",
        "unit": "bytesbandwidth"
      }
    ],
    "text": "The sensor's message"
  }
}

There are several online XML<->JSON converter tools, for instance:
http://www.utilities-online.info/xmltojson/


Best Regards,
Luciano Lingnau [Paessler Support]

Created on Sep 6, 2016 11:54:17 AM by  Luciano Lingnau [Paessler Support]

Last change on Jan 17, 2018 10:10:49 AM by  Luciano Lingnau [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Try this: json formatter https://jsonformatter-online.com

Created on Aug 30, 2017 3:56:36 AM by  jones888 (0)



Votes:

0

Your Vote:

Up

Down

I use this tool to convert xml to json. https://jsonformatter.org/xml-to-json and this for formatting JSON https://jsonformatter.org

Created on Nov 20, 2017 7:52:41 AM by  irisp (0)



Please log in or register to enter your reply.


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.