从 Nagios4 向 Telegram 发送通知

从 Nagios4 向 Telegram 发送通知

无法从我的 nagios 获取警报。Debian 上的服务器。从 github.com/vysheng/tg 安装了 telegram-cli

Nagios4的配置文件。

命令.cfg:

#'notify-service-by-tg' command definition
define command{
        command_name    notify-service-by-tg
        command_line    /home/nagios/tg/bin/telegram-cli -WR -U root -D -e 'msg $_CONTACTTG$ $NOTIFICATIONTYPE$ Host : $HOSTNAME$ - Service : $SERVIC$
}
#'notify-host-by-tg' command definition
define command{
        command_name    notify-host-by-tg
        command_line    /home/nagios/tg/bin/telegram-cli -WR -U root -D -e 'msg $_CONTACTTG$  "$NOTIFICATIONTYPE$ Host : $HOSTNAME$ is $HOSTSTATE$ @ $
}

联系人.cfg:

define contact{

contact_name nagiosadmin;
use generic-contact;
alias Nagios Admin;
service_notification_period 24x7;
host_notification_period 24x7;
service_notification_options w,u,c,r,f,s;
email nagios@localhost;
_tg Anton_T;
service_notification_commands notify-service-by-tg;
host_notification_commands notify-host-by-tg;

}
define contactgroup{

contactgroup_name       admins
alias                   Nagios Administrators
members                 nagiosadmin

       }

nginx 出现此错误:

2015/12/31 20:56:47 [info] 512#0: *299 client closed connection while waiting for request, client: 1*8.*.*.*, server: 0.0.0.0:800

请帮忙!

答案1

解决了!

您需要以用户 nagios 的身份激活 Telegram 代码。

su - nagios

/home/nagios/tg/bin/telegram-cli -k /home/nagios/tg/tg-server.pub

并输入以短信形式发送给您的代码

相关内容