Retrieve values from multiple itemids in zabbix api 2.0

1.5k views Asked by At

I want to get all latest data received from the host by host id. By the specs i try this one

$itemids=array("36361","36362","36363","36364","36365");
$groups = $api->historyGet(array(
    "output"=> "extend",
    "history"=> 0,
    "hostids"=> "10657",
    "itemids" => $itemids,
    "limit"=> 1
));

In response receive data only for the first array element. Thanks in advance.

1

There are 1 answers

0
Jan Garaj On

That's the question for your PHP Zabbix API library - is it able to translate PHP array ($itemids) to JSON array automatically or not? It has problem apparently, so try to do it manually:

$itemids = array("36361","36362","36363","36364","36365");
// "convert" PHP array to JSON array string
$itemids = "[".implode($itemids, ",")."]";
// or use JSON array string directly: $itemids = "[36361,36362,36363,36364,36365]";
$groups = $api->historyGet(array(
    "output"=> "extend",
    "history"=> 0,
    "hostids"=> "10657",
    "itemids" => $itemids,
    "limit"=> 1
));