Is there a way with thw API to retreive the last value from a particular Channel on a Sensor (Free Space F: on a Multi-Disk Sensor for example)?


Article Comments

Hello,

that should be possible with the API, and for example a call like:

/api/table.xml?content=values&output=html&columns=datetime,value_,coverage&id=1004

More details under "Setup"->"PRTG API"->"Live Data" in your PRTG.

best regards.


May, 2011 - Permalink

Hello, Why the last value reported by API is different compare to live data in the web ?


Aug, 2017 - Permalink

Hello encarta,
thank you for your reply.

What do you mean by different? Please provide an example for comparison. Please share the complete output from the API.

Best Regards,
Luciano Lingnau [Paessler Support]


Aug, 2017 - Permalink

I'm using api call

table.xml?content=values&output=xml&columns=datetime,value_&count=1&id=11089&noraw=1&usecaption=true&username=***&passhash=***

result is :

<?xml version="1.0" encoding="UTF-8"?>
  <values totalcount="1440" listend="0">
   <prtg-version>17.3.32.2339</prtg-version>
   <item>
    <datetime>03.08.2017 15:57:00 - 15:58:00</datetime>
    <datetime_raw>42950.3736111111</datetime_raw>
    <value channel="Traffic Total (volume)" channelid="-1">40,226 MByte</value>
    <value_raw channel="Traffic Total (volume)" channelid="-1">42179692629.9687</value_raw>
    <value channel="Traffic Total (speed)" channelid="-1">5,625 Mbit/s</value>
    <value_raw channel="Traffic Total (speed)" channelid="-1">703112062.5099</value_raw>
    <value channel="Traffic In (volume)" channelid="0">37,664 MByte</value>
    <value_raw channel="Traffic In (volume)" channelid="0">39493925131.6092</value_raw>
    <value channel="Traffic In (speed)" channelid="0">5,267 Mbit/s</value>
    <value_raw channel="Traffic In (speed)" channelid="0">658341809.1617</value_raw>
    <value channel="Traffic Out (volume)" channelid="1">2,561 MByte</value>
    <value_raw channel="Traffic Out (volume)" channelid="1">2685767498.3596</value_raw>
    <value channel="Traffic Out (speed)" channelid="1">358 Mbit/s</value>
    <value_raw channel="Traffic Out (speed)" channelid="1">44770253.3482</value_raw>
    <value channel="Downtime" channelid="-4">0 %</value>
    <value_raw channel="Downtime" channelid="-4">0.0000</value_raw>
   </item>
  </values>

And the value from live data table of prtg web portal (via sensor.htm?id=11089&tabid=2)

is like this

Date Time 	Traffic Total (volume)	Traffic Total (speed)	Traffic In (volume)	Traffic In (speed)	Traffic Out (volume)	Traffic Out (speed)	Downtime	Coverage
04.08.2017 15:57:12	40,229 MByte	5,630 Mbit/s	37,647 MByte	5,269 Mbit/s	2,581 MByte	361 Mbit/s	0 %	100 %

Aug, 2017 - Permalink

Hello encarta,
thank you for your reply.

I've just tested this locally and it checks out. The values don't match because you're comparing different timeframes. The sorting in PRTG and in the API call are different. Please refer to the time-stamps in your output(s):

datetime>03.08.2017 15:57:00 - 15:58:00</datetime>
Date Time
04.08.2017 15:57:12

I encourage you to use /api/table.json?content=channels to poll only the last values from a sensor's channels. Please refer to:

Note: You can poll the data in json or xml, just poll the appropriate API.

/api/table.json?content=channels&output=json
/api/table.xml?content=channels&output=xml

Best Regards,
Luciano Lingnau [Paessler Support]


Aug, 2017 - Permalink