zabbix 自定义监控项每隔1分钟检测一次三次失败报警
Posted dribs
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zabbix 自定义监控项每隔1分钟检测一次三次失败报警相关的知识,希望对你有一定的参考价值。
在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(" ") success_status = [‘xxxxx‘,‘xxxxx‘] def sendMail(mTitle,mes): receiver = ["a@b.com","b@c.com"] encoding = "utf-8" message = MIMEText("巡检主机: " + hostName + " " + "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 开始创建监控条件
添加新到条件
以上是关于zabbix 自定义监控项每隔1分钟检测一次三次失败报警的主要内容,如果未能解决你的问题,请参考以下文章
当日志文件中的时间与主机时间不同步时,怎么监控每隔五分钟检测一次日志文件是否出自按某个关键字?