Currently the return data from the API call history.get is quite challenging to understand. It also tends to waste a fair bit of bandwidth. This patch does the following:
1) It greatly simplifies the output for the call
Example JSON output:
The following link shows the current output format:
http://www.zabbix.com/documentation/1.8/api/history/get
2) It alters the order in which items are sorted. Presently history data is sorted with the itemid having precedence, not the clock. This is reversed in this patch. Thus if you call this API function with 5 different itemids and limit your return to 100 items, you will get the latest 100 items in chronological order, which means it is possible not not see one of the items you wanted if it was not polled in the time period of your query. Before it would show you the first 100 history points for the first item, and never show you any of the others.
This patch was tested with Zabbix 1.8.3 (API 1.3).
It is applied against the api/classes/class.chistory.php file.
One last thing to note, this is mostly for the devs. There is a provision in the call for grouping the output, however this data is never used. I think this code should be used. I did not make changes to that aspect of the call.
1) It greatly simplifies the output for the call
Example JSON output:
Code:
Call:
{
"auth":"*********",
"method":"history.get",
"id":99,
"params":{"history":0,
"output":"extend",
"itemids":[22194,22196,22197],
"limit":10},
"jsonrpc":"2.0"
}
Reply:
{"jsonrpc":"2.0","result":
[{"itemid":"22194","clock":"1284536929","value":"0.0800"},
{"itemid":"22194","clock":"1284536934","value":"0.0800"},
{"itemid":"22194","clock":"1284536939","value":"0.0700"},
{"itemid":"22194","clock":"1284536944","value":"0.1400"},
{"itemid":"22194","clock":"1284536949","value":"0.1300"},
{"itemid":"22194","clock":"1284536954","value":"0.1200"},
{"itemid":"22194","clock":"1284536959","value":"0.1100"},
{"itemid":"22194","clock":"1284536964","value":"0.1000"},
{"itemid":"22194","clock":"1284536969","value":"0.0900"},
{"itemid":"22194","clock":"1284536974","value":"0.1700"}],
"id":99}
http://www.zabbix.com/documentation/1.8/api/history/get
2) It alters the order in which items are sorted. Presently history data is sorted with the itemid having precedence, not the clock. This is reversed in this patch. Thus if you call this API function with 5 different itemids and limit your return to 100 items, you will get the latest 100 items in chronological order, which means it is possible not not see one of the items you wanted if it was not polled in the time period of your query. Before it would show you the first 100 history points for the first item, and never show you any of the others.
This patch was tested with Zabbix 1.8.3 (API 1.3).
It is applied against the api/classes/class.chistory.php file.
One last thing to note, this is mostly for the devs. There is a provision in the call for grouping the output, however this data is never used. I think this code should be used. I did not make changes to that aspect of the call.
Comment