标签:zab success sage host ssl form format send env
在agent上添加 UserParameter=auth.check,/etc/zabbix/auth_monitor/auth_check.py
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_str.read().strip().split("\n") success_status = [‘xxxxx‘,‘xxxxx‘] def sendMail(mTitle,mes): receiver = ["a@b.com","b@c.com"] encoding = "utf-8" message = MIMEText("巡检主机:\n" + hostName + "\n\n" + "auth check error:" + mes, ‘plain‘, ‘utf-8‘) message[‘Subject‘] = Header(mTitle, encoding) message[‘From‘] = "alert@b.com" message[‘To‘] = ", ".join(receiver) message[‘Date‘] = formatdate() try: smtpObj = smtplib.SMTP_SSL(‘smtp.exmail.qq.com‘, 465) smtpObj.ehlo() smtpObj.login(‘alert@b.com‘, ‘xxxxxxx‘) smtpObj.sendmail(‘alert@b.com‘, receiver, message.as_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 开始创建监控条件
添加新到条件
标签:zab success sage host ssl form format send env
原文地址:https://www.cnblogs.com/dribs/p/11776262.html