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?


Article Comments

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!


Oct, 2011 - Permalink

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


Oct, 2011 - Permalink

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,


Oct, 2011 - Permalink