例子: 监控agent端服务器的user数量是否大于40。大于则触发邮件报警。
1.添加agent的配置文件,这样可以添加自定义监控条目
1
2
| UnsafeUserParameters=1
UserParameter=count.line.passwd,wc -l /etc/passwd|awk '{print $1}'
|
2.创建 Templates (可以把多个item放在一起。创建host的时候直接link Templates 就行)
3.创建items(点击templates 选中新建的模板,IM-server 中的items )
新建item
3.添加图形(跟item的位置一样)
新建Graphs
效果图:
5.添加 Triggers
5.创建新的action(默认已经有了,自己创建方便些)
需要定义server的配置文件 1
| AlertScriptsPath=/usr/local/zabbix/scripts
|
需要定义server的配置文件 mail.py的内容: 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| #!/usr/bin/python
#coding:utf-8
import smtplib
from email.mime.text import MIMEText
import sys
mail_host = 'smtp.163.com'
mail_user = 'gotye001'
mail_pass = 'gotye2015'
mail_postfix = '163.com'
def send_mail(to_list,subject,content):
me = mail_user+"<"+mail_user+"@"+mail_postfix+">"
msg = MIMEText(content)
msg['Subject'] = subject
msg['From'] = me
msg['to'] = to_list
try:
s = smtplib.SMTP()
s.connect(mail_host)
s.login(mail_user,mail_pass)
s.sendmail(me,to_list,msg.as_string())
s.close()
return True
except Exception,e:
print str(e)
return False
if __name__ == "__main__":
send_mail(sys.argv[1], sys.argv[2], sys.argv[3])
|
这样就添加了报警的方式。 1.因为之前action 定义了 报警会通知Aminsitrator组的用户。 但是用户需要登陆WEB页面才能看到报警,所以用户也需要有邮件报警 (暂时这么理解)
|