zabbix接口

获取auth

curl -i -s -X POST -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0","method": "user.login","params": {"user": "Admin","password": "zabbix"},"id": 1}' http://zabbix.corp.11bee.com//api_jsonrpc.php

返回值:

{"jsonrpc":"2.0","result":"ab459acbdccc23d81835ee009c6dcf39","id":1}

 

获取group信息

curl -i -s -X POST -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0","method": "hostgroup.get","params": {"output": ["groupid","name"]},"auth":"ab459acbdccc23d81835ee009c6dcf39","id":0}' http://zabbix.corp.11bee.com/api_jsonrpc.php

返回值:

{"jsonrpc":"2.0","result":[{"groupid":"5","name":"Discovered hosts"},{"groupid":"7","name":"Hypervisors"},{"groupid":"2","name":"Linux servers"},{"groupid":"21","name":"PING"},{"groupid":"20","name":"TEST"},{"groupid":"1","name":"Templates"},{"groupid":"12","name":"Templates/Applications"},{"groupid":"13","name":"Templates/Databases"},{"groupid":"8","name":"Templates/Modules"},{"groupid":"9","name":"Templates/Network Devices"},{"groupid":"10","name":"Templates/Operating Systems"},{"groupid":"11","name":"Templates/Servers Hardware"},{"groupid":"14","name":"Templates/Virtualization"},{"groupid":"6","name":"Virtual machines"},{"groupid":"19","name":"WLC切换监测"},{"groupid":"22","name":"Windows"},{"groupid":"4","name":"Zabbix servers"},{"groupid":"16","name":"北京职场"},{"groupid":"18","name":"北京顺义"},{"groupid":"17","name":"外地职场"},{"groupid":"15","name":"大族机房"},{"groupid":"24","name":"深圳职场"},{"groupid":"23","name":"重庆职场"}],"id":0}

 

获取group下host信息

curl -i -s -X POST -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0","method": "host.get","params": {"output": ["hostid","name"],"groupsid":"15"},"auth":"ab459acbdccc23d81835ee009c6dcf39","id":0}' http://zabbix.corp.11bee.com/api_jsonrpc.php

返回值:

{"jsonrpc":"2.0","result":[{"hostid":"10084","name":"Zabbix server"},{"hostid":"10254","name":"old-csr1.net.p1"},{"hostid":"10262","name":"c-b12-14.net.p1"},{"hostid":"10263","name":"old-asr1.net.p1"},{"hostid":"10264","name":"r1.net.p1"},{"hostid":"10265","name":"ilo-b10-10.net.p1"},{"hostid":"10266","name":"ilo-b12-14.net.p1"},{"hostid":"10267","name":"ilo-b10-6.net.p1"},{"hostid":"10268","name":"l-vpn1.net.p1"},{"hostid":"10290","name":"fw1.szygkc.net.br"},{"hostid":"10293","name":"csr1.net.corp"},{"hostid":"10294","name":"csr2.net.corp"},{"hostid":"10295","name":"f3-a1.net.corp"},{"hostid":"10296","name":"f3-a2.net.corp"},{"hostid":"10297","name":"f3-a3.net.corp"},{"hostid":"10298","name":"f3-a4.net.corp"},{"hostid":"10299","name":"f3-a5.net.corp"},{"hostid":"10300","name":"f3-a6.net.corp"},{"hostid":"10301","name":"f3-a7.net.corp"},{"hostid":"10303","name":"f2-w1.net.corp"},{"hostid":"10306","name":"asr1.net.by"},{"hostid":"10313","name":"wlc-3504-net-corp"},{"hostid":"10318","name":"fw1.net.corp"},{"hostid":"10319","name":"fw2.net.corp"},{"hostid":"10338","name":"asr1.net.p1"},{"hostid":"10340","name":"csr1.net.p1"},{"hostid":"10342","name":"csr2.net.p1"},{"hostid":"10344","name":"IPSEC_VPN Shenzhen LAN Gateway"},{"hostid":"10345","name":"IPSEC_VPN Shenzhen Peer Global IP"},{"hostid":"10346","name":"IDC Main Internet"},{"hostid":"10347","name":"IDC Backup Internet"},{"hostid":"10348","name":"BS H3C1 Inside"},{"hostid":"10349","name":"BS H3C_A Outside"},{"hostid":"10351","name":"c-b10-2-a.net.p1"},{"hostid":"10352","name":"btest.net.p1"},{"hostid":"10353","name":"c-b10-9-a.net.p1"},{"hostid":"10354","name":"c-b10-9-b.net.p1"},{"hostid":"10355","name":"c-b10-2-b.net.p1"},{"hostid":"10356","name":"c-b10-11-a.net.p1"},{"hostid":"10357","name":"c-b10-11-b.net.p1"},{"hostid":"10359","name":"c-b10-6-a.net.p1"},{"hostid":"10360","name":"c-b10-6-b.net.p1"},{"hostid":"10361","name":"www.baidu.com"},{"hostid":"10362","name":"114.114.114.114"},{"hostid":"10363","name":"DNS Ali 223.5.5.5"},{"hostid":"10364","name":"DNS Ali 223.6.6.6"},{"hostid":"10366","name":"f5-a1.net.corp"},{"hostid":"10367","name":"BS Juniper Outside"},{"hostid":"10368","name":"c-b12-14-a.net.p1"},{"hostid":"10369","name":"c-b12-14-b.net.p1"},{"hostid":"10370","name":"f2-w2.net.corp"},{"hostid":"10372","name":"IPSEC_VPN Shenzhen AP"},{"hostid":"10373","name":"ns1.net.corp"},{"hostid":"10374","name":"h3c1.net.corp"},{"hostid":"10375","name":"h3c2.net.corp"},{"hostid":"10376","name":"BS H3C_B Outside"},{"hostid":"10377","name":"BS H3c Outside"},{"hostid":"10379","name":"new-asr1.net.by"},{"hostid":"10380","name":"fw1.cqzc.net.br"},{"hostid":"10381","name":"csr1.cqzc.net.br"},{"hostid":"10384","name":"10.64.12.18-c100i100"},{"hostid":"10386","name":"100.84.160.188"},{"hostid":"10387","name":"10.64.12.130-c200i200t60"},{"hostid":"10388","name":"116.7.245.10-c200i200t60"},{"hostid":"10389","name":"10.64.44.250-c200i200t60"},{"hostid":"10390","name":"10.64.44.1-c200i200t60"},{"hostid":"10391","name":"10.64.128.11-c100i100"},{"hostid":"10392","name":"10.64.128.12-c100i100"},{"hostid":"10393","name":"10.64.128.13-c100i100"},{"hostid":"10394","name":"10.64.128.14-c100i100"},{"hostid":"10396","name":"l-shepherdplugin2.edj.corp"},{"hostid":"10397","name":"l-ai1.data.corp"},{"hostid":"10399","name":"10.64.50.14-c200i200t60"},{"hostid":"10402","name":"10.64.50.68-c100i100"},{"hostid":"10403","name":"61.128.133.138-c200i200t60"},{"hostid":"10404","name":"10.64.4.1-c100i100"},{"hostid":"10405","name":"10.64.12.18-c200i200t60"},{"hostid":"10407","name":"asr1.net.p1-newtmp"},{"hostid":"10408","name":"csr1.szygkc.net.br"},{"hostid":"10410","name":"111.203.170.78-c200i200t60"},{"hostid":"10411","name":"111.194.125.209-c200i200t60"},{"hostid":"10412","name":"f2.w3.net.corp"},{"hostid":"10413","name":"10.64.52.1-c200i200t60"},{"hostid":"10414","name":"10.64.52.48-c200i200t60"},{"hostid":"10415","name":"10.64.50.68-c200i200t60"}],"id":0}

 

获取host的item

 

 


curl -i -s -X POST -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0","method": "item.get","params": {"output": "itemids","hostids":"10340","search":{"key_":"net.if.in[ifHCInOctets.436231168]"}},"auth":"ab459acbdccc23d81835ee009c6dcf39","id":0}' http://zabbix.corp.11bee.com/api_jsonrpc.php

返回值:

{"jsonrpc":"2.0","result":[{"itemid":"36385"}],"id":0}

 

 

获取item的历史数据(获取最新的数据)


curl -i -s -X POST -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0","method": "item.get","params": {"history": 0,"itemids":"36385","sortfield":"itemid","sortorder":"DESC","limit":1,"output":"extend"},"auth":"ab459acbdccc23d81835ee009c6dcf39","id":"1"}' http://zabbix.corp.11bee.com/api_jsonrpc.php

返回值:

{"jsonrpc":"2.0","result":[{"itemid":"36385","type":"4","snmp_community":"{$SNMP_COMMUNITY}","snmp_oid":"1.3.6.1.2.1.31.1.1.1.6.436231168","hostid":"10340","name":"Interface Ethernet1/47(uplink-main): Bits received","key_":"net.if.in[ifHCInOctets.436231168]","delay":"30","history":"2w","trends":"30d","status":"0","value_type":"3","trapper_hosts":"","units":"bps","snmpv3_securityname":"","snmpv3_securitylevel":"0","snmpv3_authpassphrase":"","snmpv3_privpassphrase":"","formula":"","error":"","lastlogsize":"0","logtimefmt":"","templateid":"0","valuemapid":"0","params":"","ipmi_sensor":"","authtype":"0","username":"","password":"","publickey":"","privatekey":"","mtime":"0","flags":"4","interfaceid":"120","port":"","description":"MIB: IF-MIB\r\nThe total number of octets received on the interface,including framing characters.  This object is a 64-bit version of ifInOctets. Discontinuities in the value of this counter can occur at re-initialization of the management system, and at other times as indicated by the value of ifCounterDiscontinuityTime.","inventory_link":"0","lifetime":"30d","snmpv3_authprotocol":"0","snmpv3_privprotocol":"0","state":"0","snmpv3_contextname":"","evaltype":"0","jmx_endpoint":"","master_itemid":"0","lastclock":"1608782940","lastns":"828436701","lastvalue":"5554576","prevvalue":"5001296"}],"id":"1"}

 

posted @ 2021-02-28 23:51  yuzhen0228  阅读(305)  评论(0编辑  收藏  举报