注:该脚本需在AlertScriptsPath路径下,且需可执行权限。 设置告警介质
Administration-> Media types-> create media type
注意:Type需选择为Script
将告警介质与用户关联
Administration -> Users
点击 Admin,也可以新建用户进行关联
Media -> Add
type选择告警介质中定义的name
创建Action
Configuration -> Actions -> Create action
在这里,以Zabbix自带的“Template OS Linux”模板中的服务器重启的Trigger作为Action的对象
测试
重启node1
[iyunv@node1 ~]# init 6
验证测试结果
首先查看Action是否产生
Administration -> Audit
查看告警信息是否写入到文件中
[iyunv@node3 ~]# cat /tmp/syslog_test.txt
2017-04-25 18:28:30 /usr/lib/zabbix/alertscripts/zabbix_syslog.py slowtech@126.com PROBLEM: node1 has just been restarted node1^192.168.244.10^PROBLEM^Warning^主机重启 主机:node1(node1 has just been restarted)
2017-04-25 18:28:30 /usr/lib/zabbix/alertscripts/zabbix_syslog.py slowtech@126.com OK: node1 has just been restarted node1^192.168.244.10^OK^Warning^主机重启恢复 主机:node1(node1 has just been restarted)