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

Api Call: HTML "Sensor Status History" table in XML?

Votes:

0

Hi, any help would be greatly appreciated.

The short of it I need to get this information "Sensor Status History": https://www.paessler.com/knowledgebase/en/topic/24953-data-and-time-in-the-reports#reply-74653 With an API call, in XML.

The long of it Currently I'm stuck with having to make an API call to the sensor history and trawl through the xml to find sensors that were down for longer than 15 minutes. The issue is that we have about 200+ sensors and to get accurate information means pulling many xml files and doing the logic to find the value in the percentage downtime column (100% downtime), across the time period I've selected (to be accurate it should be 1 minute, so 15 x 1 minute units that are contiguous).

When I pull an html report though, voila! There is a table "Sensor Status History", which is exactly what I need. The link above shows the table beautifully. It's concise and exactly what I'm after. So instead of me making an api call to the html and dissecting the html with code or trawling through reams of XML, is there any way to just get this table of data in XML format?

api historic-data prtg sensor

Created on Oct 18, 2011 8:41:07 AM



3 Replies

Votes:

0

Ok, so I found the answer after I posted. It seems like an undocumented api feature, unless I missed it somewhere.

The content variable needs to be set to statehistory & and the columns=status,datetime. As per below.

yourprtgserver/api/historicdata.xml?id=8001&sdate=2011-10-01-00-00-01&edate=2011-10-18-10-00-00&avg=43200&content=statehistory&sortby=datetime&columns=status,datetime

This seems to work in Version 9, but I don't seem to be having any luck with the version 7 installation my client has!

Created on Oct 18, 2011 1:26:26 PM

Last change on Jul 18, 2018 12:59:16 PM by  Brandy Greger [Paessler Support]



Votes:

0

The url in your post for some reason throws an error...

Created on Oct 18, 2011 1:42:58 PM



Votes:

0

In the \website\api folder of your PRTG installation, create a new file called historicdata_xml.htm and paste the following code

<#checkobjecttype objecttype="sensor">
<#table tableid="statereporttable" content="statehistory" columns="status,datetime" sortby="datetime" output="xml">

You can call it with the following parameters:

yourprtgserver/api/historicdata_xml.htm?id=xxx&sdate=2011-10-11-15-31-00&edate=2011-10-18-15-31-00&avg=3600

Please replace xxx with the id of the sensor you want to report on and adjust the start and end date. To automatically login, append

&login=myusername&password=mypassword

to the url above. Replace myusername and mypassword with valid credentials.

This will produce the xml you are looking for.

<?xml version="1.0" encoding="UTF-8" ?>
  <statehistory>
   <prtg-version>9.1.2.1718</prtg-version>
   <item>
    <status_raw>2</status_raw>
    <datetime>11.10.2011 17:31:00 - 11.10.2011 17:31:37</datetime>
    <datetime_raw>40827.6469561574</datetime_raw>
   </item>
   <item>
    <status_raw>1</status_raw>
    <datetime>11.10.2011 17:31:37 - 13.10.2011 11:34:40</datetime>
    <datetime_raw>40829.3990741667</datetime_raw>
   </item>
   <item>
    <status_raw>2</status_raw>
    <datetime>13.10.2011 11:34:40 - 13.10.2011 11:41:45</datetime>
    <datetime_raw>40829.4039932755</datetime_raw>
   </item>
   <item>
    <status_raw>1</status_raw>
    <datetime>13.10.2011 11:41:45 - 18.10.2011 17:30:45</datetime>
    <datetime_raw>40834.6463542245</datetime_raw>
   </item>
   <item>
    <status_raw>2</status_raw>
    <datetime>18.10.2011 17:30:45 - 18.10.2011 17:31:00</datetime>
    <datetime_raw>40834.6465277894</datetime_raw>
   </item>
  </statehistory>

Regards,

Created on Oct 18, 2011 2:20:54 PM

Last change on Oct 18, 2011 5:30:54 PM by  Torsten Lindner [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.