zabbix API 使用
zabbix 官方地址
https://www.zabbix.com/documentation/3.0/manual/api/reference/user/login
这里弄几个简单的例子 官方都介绍了
curl -s -X POST -H 'Content-type:application/json' -d ' { "jsonrpc": "2.0", "method": "user.login", "params": { "user": "Admin", "password": "Wu123456.." }, "id": 1 }' http://192.168.57.132/zabbix/api_jsonrpc.php | python -mjson.tool 65b234ea48bdfa55019b2799b063251a curl -s -X POST -H 'Content-type:application/json' -d ' { "jsonrpc": "2.0", "method": "host.get", "params": { "output": ["hostid"] }, "auth": "65b234ea48bdfa55019b2799b063251a", "id": 1 }' http://192.168.57.132/zabbix/api_jsonrpc.php | python -mjson.tool 1. 验证 curl -s -X POST -H 'Content-type:application/json' -d ' { "jsonrpc": "2.0", "method": "user.login", "params": { "user": "Admin", "password": "Wu123456.." }, "id": 1 }' http://192.168.57.132/zabbix/api_jsonrpc.php | python -mjson.tool SessionID: 21f86cdc5f6d103a3100e7aaa2f01a8c 2、请求API ,附带上SessionID curl -s -X POST -H 'Content-type:application/json' -d ' { "jsonrpc": "2.0", "method": "host.create", "params": { "host": "Linux server", "interfaces": [ { "type": 1, "main": 1, "useip": 1, "ip": "192.168.57.131", "dns": "", "port": "10050" } ], "groups": [ { "groupid": "2" } ], "templates": [ { "templateid": "10001" } ] }, "auth": "21f86cdc5f6d103a3100e7aaa2f01a8c", "id": 1 }' http://192.168.57.132/zabbix/api_jsonrpc.php | python -mjson.tool