码迷,mamicode.com
首页 > Windows程序 > 详细

zabbix API 获取CPU 信息

时间:2014-09-15 19:47:00      阅读:5920      评论:0      收藏:0      [点我收藏+]

标签:zabbix   api   linux   

curl -i -X POST -H ‘Content-Type: application/json‘ -d 

‘{"jsonrpc":"2.0","method":"user.login","params":{"user":"william","password":"Autolinux123!@#"},"auth":null,"id":0}‘ http://192.168.49.90/zabbix/api_jsonrpc.php;



{"jsonrpc":"2.0","result":"4023ceeb084e87211f2373626a7b1ea5","id":0}[root@GoogleAuthentication9 ~]#




2, 获取指定或所有监控主机的hostids


curl -i -X POST -H ‘Content-Type: application/json‘ -d ‘{"jsonrpc": "2.0","method":"host.get","params":{"output":["hostid"],"filter": {"host":"192.168.6.4"}},"auth": 

"4023ceeb084e87211f2373626a7b1ea5","id": 0}‘ http://192.168.49.90/zabbix/api_jsonrpc.php;


{"jsonrpc":"2.0","result":[{"hostid":"10456"}],"id":0}[root@GoogleAuthentication9 ~]#


3, zabbix下所有监控主机hostids


curl -i -X POST -H ‘Content-Type: application/json‘ -d ‘{"jsonrpc": "2.0","method":"host.get","params":{"output":["10456"]},"auth": 

"4023ceeb084e87211f2373626a7b1ea5","id": 0}‘ http://192.168.49.90/zabbix/api_jsonrpc.php;


{"jsonrpc":"2.0","result":[{"hostid":"10084"},{"hostid":"10124"},{"hostid":"10125"},{"hostid":"10128"},{"hostid":"10129"},{"hostid":"10130"},{"hostid":"10131"},{"host

id":"10135"},{"hostid":"10136"},{"hostid":"10137"},{"hostid":"10138"},{"hostid":"10139"},{"hostid":"10140"},{"hostid":"10141"},{"hostid":"10142"},{"hostid":"10143"},{

"hostid":"10144"},{"hostid":"10147"},{"hostid":"10148"},{"hostid":"10150"},{"hostid":"10151"},{"hostid":"10153"},{"hostid":"10155"},{"hostid":"10156"},{"hostid":"1015

7"},{"hostid":"10158"},{"hostid":"10159"},{"hostid":"10160"},{"hostid":"10161"},{"hostid":"10166"},{"hostid":"10167"},{"hostid":"10168"},{"hostid":"10169"},{"hostid":

"10174"},{"hostid":"10175"},{"hostid":"10176"},{"hostid":"10177"},{"hostid":"10178"},{"hostid":"10179"},{"hostid":"10180"},{"hostid":"10181"},{"hostid":"10182"},{"hos

tid":"10183"},{"hostid":"10184"},{"hostid":"10185"},{"hostid":"10186"},{"hostid":"10187"},{"hostid":"10188"},{"hostid":"10189"},{"hostid":"10190"},{"hostid":"10191"},

{"hostid":"10193"},{"hostid":"10203"},{"hostid":"10204"},{"hostid":"10205"},{"hostid":"10206"},{"hostid":"10207"},{"hostid":"10208"},{"hostid":"10209"},{"hostid":"102

10"},{"hostid":"10212"},{"hostid":"10215"},{"hostid":"10216"},{"hostid":"10217"},{"hostid":"10218"},{"hostid":"10219"},{"hostid":"10220"},{"hostid":"10221"},{"hostid"

:"10222"},{"hostid":"10223"},{"hostid":"10224"},{"hostid":"10225"},{"hostid":"10226"},{"hostid":"10227"},{"hostid":"10228"},{"hostid":"10229"},{"hostid":"10230"},{"ho

stid":"10239"},{"hostid":"10240"},{"hostid":"10241"},{"hostid":"10242"},{"hostid":"10243"},{"hostid":"10244"},{"hostid":"10248"},{"hostid":"10252"},{"hostid":"10253"}

,{"hostid":"10254"},{"hostid":"10255"},{"hostid":"10261"},{"hostid":"10263"},{"hostid":"10271"},{"hostid":"10279"},{"hostid":"10280"},{"hostid":"10281"},{"hostid":"10

297"},{"hostid":"10298"},{"hostid":"10309"},{"hostid":"10310"},{"hostid":"10311"},{"hostid":"10312"},{"hostid":"10313"},{"hostid":"10314"},{"hostid":"10316"},{"hostid

":"10317"},{"hostid":"10318"},{"hostid":"10319"},{"hostid":"10320"},{"hostid":"10321"},{"hostid":"10322"},{"hostid":"10323"},{"hostid":"10324"},{"hostid":"10325"},{"h

ostid":"10326"},{"hostid":"10327"},{"hostid":"10328"},{"hostid":"10329"},{"hostid":"10331"},{"hostid":"10332"},{"hostid":"10333"},{"hostid":"10334"},{"hostid":"10335"

},{"hostid":"10336"},{"hostid":"10337"},{"hostid":"10340"},{"hostid":"10341"},{"hostid":"10342"},{"hostid":"10343"},{"hostid":"10344"},{"hostid":"10345"},{"hostid":"1

0346"},{"hostid":"10347"},{"hostid":"10348"},{"hostid":"10349"},{"hostid":"10350"},{"hostid":"10351"},{"hostid":"10352"},{"hostid":"10353"},{"hostid":"10354"},{"hosti

d":"10355"},{"hostid":"10366"},{"hostid":"10383"},{"hostid":"10384"},{"hostid":"10385"},{"hostid":"10450"},{"hostid":"10451"},{"hostid":"10452"},{"hostid":"10453"},{"

hostid":"10455"},{"hostid":"10456"},{"hostid":"10457"},{"hostid":"10458"},{"hostid":"10459"},{"hostid":"10460"}],"id":0}[root@GoogleAuthentication9 ~]



3,获得指定主机下指定监控项或是所有监控项itemids


curl -i -X POST -H ‘Content-Type: application/json‘ -d ‘{"jsonrpc": 

"2.0","method":"item.get","params":{"output":"itemids","hostids":"10456","search":{"key_":"system.cpu.util"}},"auth": "4023ceeb084e87211f2373626a7b1ea5","id": 0}‘ 

http://192.168.49.90/zabbix/api_jsonrpc.php;


{"jsonrpc":"2.0","result":[{"itemid":"99612"}],"id":0}[root@GoogleAuthentication9 ~]#


获取指定监控项itemids的指定时间段历史数据;


我们获取下2014-05-01到2014-05-03期间的数据语句如下a


curl -i -X POST -H ‘Content-Type: application/json‘ -d ‘{"jsonrpc": 

"2.0","method":"history.get","params":{"history":0,"itemids":["99612"],"time_from":"1410403076.3190279","time_till":"1410489466.6890171","output":"extend"},"auth": 

"4023ceeb084e87211f2373626a7b1ea5","id": 0}‘ http://192.168.49.90/zabbix/api_jsonrpc.php;


本文出自 “欢迎评论,欢迎点赞” 博客,请务必保留此出处http://swq499809608.blog.51cto.com/797714/1552912

zabbix API 获取CPU 信息

标签:zabbix   api   linux   

原文地址:http://swq499809608.blog.51cto.com/797714/1552912

(6)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!