#安装所需的依赖包yum-yinstallnet-snmpnet-snmp-develntpdatelibxml2libxml2-develnet-snmp-develcurlcurl-develyu
.
#安装所需的依赖包yum -y install net-snmp net-snmp-devel ntpdate libxml2 libxml2-devel net-snmp-devel curl curl-develyum -y install mysql-develyum -y install gccyum -y install vim#安装ntpdateyum -y install ntpdate#同步服务器跟客户端的时间,避免日志出现时间错乱ntpdate 1.cn.pool.ntp.org#配置编译,指定安装目录,编译server与agent./configure /--prefix=/usr/local/zabbix /--enable-server /--enable-agent /--with-mysql /--with-net-snmp /--with-libcurl /--with-libclass ReportForm: def __init__(self): #打开数据库连接 self.conn = MySQLdb.connect(host=dbhost,user=dbuser,passwd=dbpasswd,db=dbname,port=dbport,charset='utf8') self.cursor = self.conn.cursor(cursorclass=MySQLdb.cursors.DictCursor) def getGraphID(self,HostName,GraphsName): #获取graphid sql = 'select distinct graphs_items.graphid from items join graphs_items on graphs_items.itemid=items.itemid join graphs on graphs_items.graphid=graphs.graphid where items.hostid=(select hostid from hosts where host="%s") and graphs.name="%s"' % (HostName,GraphsName) if self.cursor.execute(sql): graphid = self.cursor.fetchone()['graphid'] else: graphid = None return graphid def __del__(self): #关闭数据库连接 self.cursor.close() self.conn.close().