-->

在agent上添加 UserParameter=auth.check,/etc/zabbix/auth_monitor/auth_www.hack95.com

auth.check就是之后添加的自定义的item值。脚本返回0/1,做trigger报警用

#!/usr/bin/env python #_*_coding:utf-8_*_ import os,sys,time import smtplib from email.mime.text import MIMEText from email.header import Header from email.utils import formatdate hostName="xxxxx" res_str = os.popen("java -jar /etc/zabbix/auth_monitor/loginMonitor.jar") res = res_www.hack95.com().strip().split("\n") success_status = ['xxxxx','xxxxx'] def sendMail(mTitle,mes): receiver = ["support@www.hack95.com","support@www.hack95.com"] encoding = "utf-8" message = MIMEText("巡检主机:\n" + hostName + "\n\n" + "auth check error:" + mes, 'plain', 'utf-8') message['Subject'] = Header(mTitle, encoding) message['From'] = "support@www.hack95.com" message['To'] = ", ".join(receiver) message['Date'] = formatdate() try: smtpObj = smtplib.SMTP_SSL('www.hack95.com', 465) smtpObj.ehlo() smtpObj.login('support@www.hack95.com', 'xxxxxxx') smtpObj.sendmail('support@www.hack95.com', receiver, www.hack95.com_string()) #print "send mail success" except Exception: print "send mail error" def auth_status(): if success_status == res: #sendMail("【auth0 巡检告警】auth不异常!",str(res)) statuscode = 1 return statuscode else: sendMail("【auth 巡检告警】auth异常!",res) statuscode = 0 return statuscode i = auth_status() print i

  

trigger

创建新的报警触发器 create trigger

点击Expression constructor 开始创建监控条件

添加新到条件

-->