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

Can I consume Restful XML/HTTP APIs with PRTG (i.e. use their results as sensor values)?

Votes:

0

I would like to use a value - which is available as XML file and accessible using a GET URL - as the value of a sensor in PRTG.

How can I do this?

api custom-exe custom-script-exe custom-sensor http restful xml

Created on Nov 10, 2010 9:57:18 AM by  Dirk Paessler [Founder Paessler AG] (11,025) 3 6

Last change on Mar 19, 2015 4:03:56 PM by  Martina Wittmann [Paessler Support]



8 Replies

Accepted Answer

Votes:

1

Important: The custom sensor which is described below is now an integrated part of PRTG (as of version 8.3).

Please see PRTG Manual: HTTP XML/REST Value Sensor for details.


There is a custom sensor that requests data from an HTTP or HTTPS URL (using GET), parses the XML results and uses selected data from the XML as sensor value in PRTG.

With this technique you can import data from many APIs into PRTG, as long as they are offering an interface that works with simple HTTP GETs and replies with XML data.

Services like these are often called “REST APIs or RESTful APIs”. This type of API is becoming more and more common, PRTG's own API is a RESTful API, too.

Please note that this sensor will not be able to access SOAP based APIs.

Preparing the sensor

Step-by-Step

  • 0. If you have PRTG 8.3 or later simply select the "HTTP XML/REST Value" sensor from the sensor menu, then skip to the next heading.
  • 1. Download the "XMLValue" sensor from http://code.google.com/p/prtg-addons/wiki/PTF_Custom_Sensors
  • 2. Place the "xmlvalue.exe" file from your download into the folder PRTG Network Monitor\custom sensors\EXE of your PRTG installation (or into the same folder on your remote probe, if you want to use the sensor on a remote probe)
  • 3. Create a new custom EXE sensor and select "xmlvalue.exe" as the exe file
  • 4. Supply the necessary URL parameters for the sensor

The last step is obviously the most complex and requires a good knowledge of the API and the XML output. We have compiled some samples below.

Note: Please understand that we can not support this "unofficial" feature as we do with all "official" features of PRTG, but we will try to do our best.

Parameter Documentation of XMLValue Custom Sensor

Here are the URL parameters of this sensor:

Required parameters:

ParameterDescriptionSample
-u=urlURL to call, with all parameters-url=https://www.paessler.com
-n=nodenameXML node to use the data from-n=mydata
or
-n="nodename propertyname"use a property value of the XML node-n="mydata myproperty"

Optional parameters:

ParameterDescriptionSample
-t=xxTimeout in seconds (default is 15s)-t=60
-ccount the number of nodes with the name given in -n parameter-c
-cccount the number of childnodes of the xml node.-cc
-cscount the number of sibbelings of the xml node.-cs
-rc=charcharacters to remove from the xml value (i.e. to remove a thousands seperator from the result use -rc=,)-rc=.
-cm="%1 value"a custom message to be displayed (i.e. -cm="There are %1 tickets in our ticketing system." where %1 will be replaced with the xml value).

Sample Setups for the XMLValue Custom EXE Sensor

Sample Screenshot

Monitoring Outdoor Temperatures using Free Data from Weather Websites

Using an undocumented URL from Google

Using the following URL you can get weather data from Google (it seems to be a part of iGoogle):

http://www.google.com/ig/api?weather=yourcity

Important: This is an unofficial API. We have not found any usage terms that govern the use of this interface. So we are using this just as an example. If you use it, you are doing so at your own risk. It may disappear or break without notice.

The result of the URL is:

<xml_api_reply version="1">
<weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0">
<forecast_information>
<city data="Nuremberg, Bavaria"/>
<postal_code data="nuernberg"/>
<latitude_e6 data=""/>
<longitude_e6 data=""/>
<forecast_date data="2010-11-10"/>
<current_date_time data="2010-11-10 11:20:00 +0000"/>
<unit_system data="SI"/>
</forecast_information>
<current_conditions>
<condition data="Meistens bewölkt"/>
<temp_f data="50"/>
<temp_c data="10"/>
<humidity data="Feuchtigkeit: 71 %"/>
<icon data="/ig/images/weather/mostly_cloudy.gif"/>
<wind_condition data="Wind: S mit 13 km/h"/>
</current_conditions>
[...]

We use the following URL parameters for the XMLvalue sensor:

-u="http://www.google.com/ig/api?weather=nuernberg" -n="temp_c data" -cm="%1 Degrees Celsius"

The parameter -n="temp_c data" tells the sensor to use the data of property "data" from node "temp_c" as sensor value. If you want the Fahrenheit value, please use temp_f.

Getting Weather Data Using the API of weatherbug.com

The API of weatherbug.com requires that you sign up for an account so you can get an API key. Then you must find out your "cityCode" parameter using their "search locations" function.

We use the following URL parameters for the custom sensor:

-u="http://your_api_key.api.wxbug.net/getLiveWeatherRSS.aspx?ACode=your_api_key&cityCode=your_city_code&&UnitType=1&OutputType=1" -n=aws:temp -cm="%1 Degrees Celsius at NUE Airport"

Note: Parameter unitType controls whether the value is in Fahrenheit (unitType=0) or Celsius (unitType=1).

Getting Weather Data Using the API of weather.com

The API of weather.com also requires that you sign up for an account so you can get a set of API keys. Then you must find out your location code using their website (note: with the API weather.com seems to support US locations only ).

We use the following URL parameters for the custom sensor:

-u="http://xoap.weather.com/weather/local/USNY0996?cc=*&dayf=5&link=xoap&prod=xoap&par=1210791329&key=1e8c160fbe39d347" -n=tmp -cm="%1 Fahrenheit in Central Park"

Other APIs

API Access to Ticket System Fogbugz

We monitor the number of new and open tickets in our support ticket system (Fogbugz by FogCreek Software, http://fogcreek.com/fogbugz/) in order to display the number in our company Intranet dashboard.

The command line options are:

-u="http://www.fogbugz.bsx/api.asp?cmd=search&q=project:'Paessler AG Support Inbox' status:open opened:'1/1/2010..-0d'&token=9q8jhha4v8pc6v54ls3rgiic6abm72" -n="cases count"

The response looks like this:

<response> − <cases count="81"> <case ixBug="159965" operations="edit,spam,assign,resolve,reply,forward,remind"/> [...] <case ixBug="198178" operations="edit,spam,assign,resolve,reply,forward,remind"/> </cases> </response>

With the parameter -n="cases count" we tell the sensor to use property "count" of the XML node "cases" as value for the sensor.

Monitoring the Ranking of a Domain on Compete.com

The API of compete.com allows you (among other features) to get the traffic ranking of a domain. First you must register for a developer user account, then you must register your application to get your personal API key.

We use the following parameters to get the ranking of paessler.com:

-u="http://api.compete.com/fast-cgi/MI?d=paessler.com&ver=3&apikey=your_api_key&size=large" -n=ranking -rc=,

Monitoring the Number of Views of a Photo on Flickr.com

First you must apply for an API key on their website. Using the following parameters you can get the number of views of a photo on photo sharing website Flickr.com:

-u="http://api.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=your_api_key&photo_id=740325509" -n="photo views" -cm="%1 Total Views"

Created on Nov 10, 2010 11:55:23 AM by  Dirk Paessler [Founder Paessler AG] (11,025) 3 6

Last change on May 26, 2014 5:04:17 PM by  Gerald Schoch [Paessler Support]



Votes:

0

That custom sensor has been deprecated because the author says this functionality is now included in PRTG. How do I do this? I don't see it in the sensor list.

Created on Mar 11, 2011 10:25:34 PM



Votes:

0

It is now integrated directly into PRTG and you will find it in the group of WebServer (HTTP) sensors.

Created on Mar 14, 2011 6:00:53 AM by  Aurelio Lombardi [Paessler Support]



Votes:

0

Is there a more sophisticated way to debug this than using the results.txt file? I am using the Intervals.com API and get 401 Unauthorized using the PRTG sensor but when I test it with my own development tools I'm able to authenticate and get the results. I'm wondering if my authentication is being mangled somehow. I included the credentials in the sensor configuration and also tried base64 encoded credentials (although I assume PRTG's sensor handles the encoding).

I'd like to see the header that PRTG is passing to the server, is that possible?

Created on Jun 10, 2011 8:15:36 PM



Votes:

0

No, sorry, you can not access the headers. You could set up a debugging proxy like "Fiddler2", enter the proxy settings into PRTG and then you can look into the HTTP traffic.

Created on Jun 14, 2011 1:10:07 PM by  Dirk Paessler [Founder Paessler AG] (11,025) 3 6



Votes:

0

Or use Microsoft Network Monitor to capture requests send to intervals.com

Created on Jun 20, 2011 12:29:59 PM



Votes:

0

Created on May 20, 2020 8:01:43 PM



Votes:

0

Hi there,

All custom sensors from the PRTG Tools Family can be found here.


Kind regards

Felix Wiesneth - Team Tech Support

Created on May 21, 2020 7:21:12 AM by  Felix Wiesneth [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.