文章目錄

有些时候,需要通过Zabbix的API添加维护,挂起Zabbix的报警,简单的API调用如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from zabbix_client import ZabbixServerProxy
zapi = ZabbixServerProxy("http://127.0.0.1/")
print zapi.user.login(user="test", password="password")
print zapi.host.get(output=['hostid', 'host'])
import time
params = {
"name": "madfsdfsadsdfsdf",
"active_since": int(time.time()),
"active_till": int(time.time()) + 3600,
"hostids": ["10109"],
"timeperiods": [
{
"start_time": 64800,
"period": 3600
}
]
}
# print zapi.maintenance.create(**params)
params = {
"hostids": ["10109"]
}
print zapi.maintenance.get(**params)

params = ('19',)
print zapi.maintenance.delete(*params)
文章目錄