转载自:http://www.icanwen.com/?p=746
最近有很多朋友写mail给我,要求分享Nagios微信报警的文章,不好意思由于工作的原因写的有点晚了。
如果要使用微信报警需要用到微信的公众平台,我朋友用Nodejs写了一个模拟微信公众平台登陆的接口,用SHELL调用即可。
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
|
-
{
-
id: 11212856820,
-
nick_name: "微信昵称",
-
remark_name: "",
-
group_id: 0
}
-
