Hello

I am trying to parse the total data used in a specific month (for billing purposes). From what i've read, the historicdata should be able to offer me that.

My request is: http://monitor:8080/api/historicdata.json?username=user&password=pass&id=27743&avg=86400&sdate=2016-01-01-00-00-00&edate=2016-01-21-00-00-00

Which provides daily results in the format:

  array(6) {
    ["datetime"]=>
    string(9) "24-2-2016"
    ["datetime_raw"]=>
    float(42424.958333333)
    ["value"]=>
    string(3) "0 %"
    ["value_raw"]=>
    float(0)
    ["coverage"]=>
    string(5) "100 %"
    ["coverage_raw"]=>
    int(9999)
}

How can i get the total (in TB/GB/Bytes) for input, output in the specified period?

From what i've seen, the value is always 0% and value_raw=0 although the graphical interface shows a lot of traffic.

Thank you


Article Comments

Have you tried using tab "Historic Data Reports" feature instead the API call? It allows you to set the period and choose "No interval/display raw data".

Kind regards.


Feb, 2016 - Permalink

I have tried the Historic Data Reports, which is missing the submit button - http://prntscr.com/a89g4c , but i do need an API call, as i need to parse the information.

Choosing no interval/display data seems to be a big strain on the resources on prtg and on my application to parse it, as far as i understand from the documentation.

Ok, i've found the problem. PRTG's API provides invalid json (multiple keys with same name). I've switched to XML and it seems ok now.


Feb, 2016 - Permalink

Dear belcloud

For testing, please try CSV instead: /api/historicdata.csv?...

In any case, the historic data API call only provides the values for each interval. If you want to get the sum, your parser has to compute it. Yes, it does put a lot of strain on PRTG. There is an alternative. If you manually start to get a historic data HTML using the webinterface, you see the URL, beginning with /historicdata_html.htm

If you change the ?id= parameter, &sdate= and &edate= parameters, you can get this report for other sensors and other time frames. The HTML produced by this call also has a table with a "Total" row. It might be easier to generate this historicdata_html.htm output and parse the content of the "Total" row.


Feb, 2016 - Permalink

One small addition when using JSON as export format: Add &usecaption=true to the API call.


Feb, 2016 - Permalink