zabbix api调用步骤

目的

明确调用zabbix api的步骤,便于利用zabbix进行二次开发。

步骤

简单来说,zabbix api调用分4步:获取userid–>获取hostid–>获取itemid–>根据时间节点获取数据,流程如下:

操作

获取userid:

1
curl -i -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"user.login","params":{"user":"xxxx","password":"xxxx"},"auth":null,"id":0}' http://x.x.x.x/api_jsonrpc.php

获取hostid:

1
curl -i -X POST -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0","method":"host.get","params":{"output":["hostid"],"filter": {"host":"192.168.211.60"}},"auth": "a826fca79a0795ccc1224dc76329972f","id": 0}' http://x.x.x.x/api_jsonrpc.php

获取itemid:

1
curl -i -X POST -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0","method":"item.get","params":{"output":"itemids","hostids":"10243","search":{"key_":"system.cpu.util[,idle,avg1]"}},"auth": "a826fca79a0795ccc1224dc76329972f","id": 0}'  http://x.x.x.x/api_jsonrpc.php

获取数据:

1
curl -i -X POST -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0","method":"history.get","params":{"history":0,"itemids":["24526"],"time_from":"1392789600","time_till":"1392790200","output":"extend"},"auth": "a826fca79a0795ccc1224dc76329972f","id": 0}'  http://x.x.x.x/api_jsonrpc.php

c

-------------本文结束感谢您的阅读-------------

本文标题:zabbix api调用步骤

文章作者:WanDouDuoDuo

发布时间:2019年06月14日 - 16:06

最后更新:2019年11月01日 - 10:11

原始链接:https://wandouduoduo.com/articles/4c04639e.html

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

原创技术分享,您的支持将鼓励我继续创作