首页 > 代码库 > zabbix自动化监控8(2.4)
zabbix自动化监控8(2.4)
-----------------通过API的方式添加
参考:https://www.zabbix.com/documentation/2.4/manual/api/reference/user/login
1.验证
curl -s -X POST -H ‘Content-Type:application/json‘ -d ‘
{
"jsonrpc": "2.0",
"method": "user.login",
"params": {
"user": "Admin",
"password": "zabbix"
},
"id": 1
}‘ http://192.168.10.129/zabbix/api_jsonrpc.php |python -mjson.tool
#{
# "id": 1,
# "jsonrpc": "2.0",
# "result": "ff31018f161c34206952936393192f4e"
#}
参考:#https://www.zabbix.com/documentation/2.4/manual/api/reference/host/create
2.请求API,附带sessionID
curl -s -X POST -H ‘Content-Type:application/json‘ -d ‘
{
"jsonrpc": "2.0",
"method": "host.create",
"params": {
"host": "linux-node1.example.com", #hostname
"interfaces": [
{
"type": 1, #类型1代表zabbix agent类型
"main": 1,
"useip": 1,
"ip": "192.168.10.128", #添加的主机ip
"dns": "",
"port": "10050"
}
],
"groups": [
{
"groupid": "2"
}
],
"templates": [
{
"templateid": "10001"
}
]
},
"auth": "ff31018f161c34206952936393192f4e",
"id": 1
}‘ http://192.168.10.129/zabbix/api_jsonrpc.php |python -mjson.tool
注:在zabbix-server端直接执行这两步
查看网页端已经添加上了主机
本文出自 “feng” 博客,请务必保留此出处http://fengxiaoli.blog.51cto.com/12104465/1955302
zabbix自动化监控8(2.4)