zabbix自定义报警

1、在服务端自定义脚本:

[root@linux-node1 alertscripts]# cat /etc/zabbix/zabbix_server.conf |grep alert

#       How often Zabbix will try to send unsent alerts (in seconds).

#       Full path to location of custom alert scripts.

# AlertScriptsPath=${datadir}/zabbix/alertscripts

AlertScriptsPath=/usr/lib/zabbix/alertscripts

 

2、添加测试脚本

[root@linux-node1 alertscripts]# pwd

/usr/lib/zabbix/alertscripts

[root@linux-node1 alertscripts]# cat SendMail.sh

echo $1 $2 $3 > /tmp/sendmail.txt

 

3zabbix dashboard的界面做如下修改:

添加如下的触发项(此监控项是自定义的监控项)

监控项的配置:

zabbix-agent客户端的配置:

[root@linux-node2 ~]# cat /etc/zabbix/zabbix_agentd.conf |grep UserP

#       Does not support UserParameters or aliases.

### Option: UnsafeUserParameters

UnsafeUserParameters=1

### Option: UserParameter

#       Format: UserParameter=<key>,<shell command>

# UserParameter=

UserParameter=login-user,uptime|awk  -F ' ' '{print $4}'

4、添加动作(修改自带的)

 

5、开始测试,多个用户登录,zabbix dashboard界面会报如下的界面:

 

6、查看zabbix-server端的/tmp目录下产生的文件:

[root@linux-node1 alertscripts]# cat /tmp/sendmail.txt                         

15201249693@163.com PROBLEM: login-user :login-user: 3

posted @ 2018-05-04 17:27  求其在我  阅读(96)  评论(0)    收藏  举报