1.下载agent软件包
请在Zabbix服务器中,使用root或zabbix用户下载软件。下载agent
2.添加应用
创建Zabbix应用,并获取appkey,见下图04b9832b-14b4-4c61-343d-5926ff8af672
3.安装Agent
将agent更新到zabbix的外部告警脚本目录alertscripts,如果是源码安装的请自行更改目录。
tar xvf alert-agent-4.0.1-RC2.tar.gz cp -R alert-agent /usr/lib/zabbix/alertscripts cd /usr/lib/zabbix/alertscripts chown -R zabbix:zabbix alert-agent cp alert-agent/plugin/zabbix-plugin/110monitor /usr/lib/zabbix/alertscripts/ chmod +x /usr/lib/zabbix/alertscripts/110monitor
注意!源码安装的盆友需要注意看配置文件/etc/zabbix/zabbix_server.conf
# AlertScriptsPath=/zabbix/alertscripts AlertScriptsPath=/usr/lib/zabbix/alertscripts
请将agent更新至AlertScriptsPath目录中
alert-agent目录和110monitor需要放在同一级目录里面
4.创建110monitor通知方式
创建媒体类型Media types,,“Administrator”->“Media types”->“Create media type”
采用脚本模式script,脚本名为110monitor. 系统会在/usr/lib/zabbix/alertscripts/下查找上面的110monitor指令
5.创建110monitor用户
创建用户110monitor并设置通知媒介,登录zabbix,“Administrator”->“Users”->“create user”.
将110monitor用户加入到"Zabbix Administrator组"或者是新建组.
媒体类型,添加110monitor,并且设置appkey为发送目标.
设置所有权限"Zabbix Super Admin"
新建110monitor用户.
设置媒介类型.
设置权限.
6.创建触发动作发送通知
创建告警通知策略,"Configurationg"->"Actions"->"Create action"
名称110monitor
主题为trigger和resolve,意味着告警触发和恢复都会同步到110monitor
设置告警内容,注意冒号":"前的内容不可变更,冒号":"后的内容可以自行编辑
alarmName:{TRIGGER.NAME} entityName:{HOSTNAME} entityId:{IPADDRESS} value:{TRIGGER.VALUE} eventId:{EVENT.ID} priority:{TRIGGER.SEVERITY} alarmContent:{IPADDRESS} {ITEM.NAME}:{ITEM.VALUE}
注意!自行配制的通知模板是不行的,需要严格按照以上配置。
6.测试验证
如找台机器验证,如加了"Template ICMP Ping"监控的机器,禁用ping测试是否正常通知
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all 禁ping echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all 恢复ping
查看agent日志,出现sucess字样代表成功,如果发送的告警通知,则会同步发送微信、移动app、短信、邮件
tail -f /usr/lib/zabbix/alertscripts/alert-agent/log/agent.log
正常返回success即表示成功
15-05-2015 18:16:17,698 CST INFO [main] [com.upyoo.agent.ZabbixClient@68] start to call alert ... 15-05-2015 18:16:18,048 CST INFO [main] [com.upyoo.agent.ZabbixClient@68] start to call alert ... 15-05-2015 18:16:18,057 CST INFO [main] [com.upyoo.agent.CommandClient@82] app:04b9832b-14b4-4c61-343d-5926ff8af672 15-05-2015 18:16:18,057 CST INFO [main] [com.upyoo.agent.CommandClient@82] eventType:trigger 15-05-2015 18:16:18,059 CST INFO [main] [com.upyoo.agent.CommandClient@82] alarmName:monitor-agent-nm5 is unavailable by ICMP 15-05-2015 18:16:18,059 CST INFO [main] [com.upyoo.agent.CommandClient@82] entityName:monitor-agent-nm5 15-05-2015 18:16:18,060 CST INFO [main] [com.upyoo.agent.CommandClient@82] entityId:172.19.0.5 15-05-2015 18:16:18,061 CST INFO [main] [com.upyoo.agent.CommandClient@82] eventId:280 15-05-2015 18:16:18,061 CST INFO [main] [com.upyoo.agent.CommandClient@82] priority:Average 15-05-2015 18:16:18,062 CST INFO [main] [com.upyoo.agent.CommandClient@82] alarmContent:172.19.0.5 ICMP ping:Down (0) 15-05-2015 18:16:18,067 CST INFO [main] [com.upyoo.agent.CommandClient@58] start to post url:http://api.110monitor.com/alert/api/event 15-05-2015 18:16:18,144 CST INFO [main] [com.upyoo.agent.CommandClient@65] body:{"app":"04b9832b-14b4-4c61-343d-5926ff8af672","alarmContent":"172.19.0.5 ICMP ping:Down (0)","eventId":"280","priority":"3","entityId":"172.19.0.5","alarmName":"monitor-agent-nm5 is unavailable by ICMP","eventType":"trigger","entityName":"monitor-agent-nm5"} 15-05-2015 18:16:18,728 CST INFO [main] [com.upyoo.agent.CommandClient@68] result:{"result":"success","message":null,"data":"3690","totalCount":0,"code":"200"}
完成
恭喜你 完成Zabbix集成配置,微信即可接收告警提醒,并通过”我的告警“查询所有未处理告警哦。
注意!注册完毕后默认仅发送邮件提醒,请关注微信号alert110,或者到”用户“->“具体用户”下配置短信提醒规则。或参考提醒设置
亲,到现在可以抛弃老的139邮箱、飞信、短信猫、qq邮箱等间接短信配置提醒方式。
本文出自 “我的天空” 博客,谢绝转载!