随着移动互联网技术的高速发展,微信被大家广泛使用,被应用到很多领域。本文将介绍如何让监控神器集成微信报警。
如果要使用微信报警需要用到微信的公众平台。这里写了一个模拟微信公众平台登陆的接口。
-
{
-
id: 5726745,
-
nick_name: "user1",
-
remark_name: "",
-
group_id: 0
},
-
-
{
-
id: 618272308,
-
nick_name: "user2",
-
remark_name: "",
-
group_id: 0
},
-
-
{
-
id: 2026561000,
-
nick_name: "user3",
-
remark_name: "",
-
group_id: 0
},
-
define command{ command_name notify-host-by-weixin command_line /usr/bin/printf "%b" "*****ERS monitor Robot*****\n\n Notification Type: $NOTIFICATIONTYPE$\n Host: $HOSTNAME$\nState: $HOSTSTATE$\n Address: $HOSTADDRESS$\n Info: $HOSTOUTPUT$\n\n Date/Time: $LONGDATETIME$\n" >/usr/local/nagios/var/weixin.out | /usr/local/bin/weixin.sh -f $CONTACTADDRESS1$ } # 'notify-service-by-weixin' command definition define command{ command_name notify-service-by-weixin command_line /usr/bin/printf "%b" "***** ERS monitor Robot*****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" > /usr/local/nagios/var/weixin.out | /usr/local/bin/weixin.sh -f $CONTACTADDRESS1$ } |
define contact{
contact_name nagiosadmin ; Short name of user alias Nagios Admin ; Full name of user
service_notification_period 24×7
host_notification_period 24×7
service_notification_options w,u,c,r,f,s
host_notification_options d,u,r,f,s
service_notification_commands notify-host-by-email,notify-host-by-sms ,notify-service-by-weixin
host_notification_commands notify-host-by-email,notify-host-by-sms ,notify-service-by-weixin
pager 134123456 ;pager number |

转载于:https://blog.51cto.com/chenshengang/1392812