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:
Parameter | Description | Sample |
-u=url | URL to call, with all parameters | -url=https://www.paessler.com |
-n=nodename | XML 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:
Parameter | Description | Sample |
-t=xx | Timeout in seconds (default is 15s) | -t=60 |
-c | count the number of nodes with the name given in -n parameter | -c |
-cc | count the number of childnodes of the xml node. | -cc |
-cs | count the number of sibbelings of the xml node. | -cs |
-rc=char | characters 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
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"
Add comment