从zabbix api 2.0中的多个itemid中检索值

时间:2014-11-17 09:58:14

标签: api json-rpc zabbix

我想通过主机ID获取从主机收到的所有最新数据。根据规格,我试试这个

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

作为响应,仅接收第一个数组元素的数据。 提前谢谢。

1 个答案:

答案 0 :(得分:1)

这是您的PHP Zabbix API库的问题 - 是否能够自动将 PHP数组($ itemids)转换为 JSON数组?它显然有问题,所以尝试手动完成:

$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
));