#!/usr/bin/env python #coding:utf8 ''' Created on 2016年 08月 30日 星期二 11:23:23 CST ''' from core import ZabbixAPI, zbx_conf server = zbx_conf.get_conf("server") username = zbx_conf.get_conf("username") password = zbx_conf.get_conf("password") if __name__ == "__main__": zapi = ZabbixAPI(server, username, password) try: hostinfo = zapi.trigger.get({ "output": ["description", "lastchange", "triggerid"], "filter": { "value": 1 }, "selectHosts": ["hostid", "name"] }) print hostinfo except: print "host not exist: %s" % server
#!/usr/bin/env python #coding:utf8 ''' Created on 2016年 08月 25日 星期四 15:22:01 CST ''' import requests import urllib2,urllib,cookielib from core import zbx_conf server = zbx_conf.get_conf("server") username = zbx_conf.get_conf("username") password = zbx_conf.get_conf("password") def get_graph(graphs,stime,period,width=539,height=304): login_data = urllib.urlencode({ "name": username, "password": password, "autologin": 1, "enter": "Sign in"}) cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) urllib2.install_opener(opener) opener.open(server + "/index.php",login_data).read() for graph in graphs: graph_args = urllib.urlencode({ "graphid": graph["id"],