zabbix API 擷取CPU 資訊

來源:互聯網
上載者:User

標籤:zabbix   api   linux   

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

‘{"jsonrpc":"2.0","method":"user.login","params":{"user":"william","password":"[email protected]#"},"auth":null,"id":0}‘ http://192.168.49.90/zabbix/api_jsonrpc.php;



{"jsonrpc":"2.0","result":"4023ceeb084e87211f2373626a7b1ea5","id":0}[[email protected] ~]#




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}[[email protected] ~]#


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}[[email protected] ~]



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}[[email protected] ~]#


擷取指定監控項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 資訊

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.