Notifications 为什么Icinga2电报通知在特定服务中失败?
我创建了与电子邮件通知非常相似的自定义电报通知。问题是,它适用于主机和大多数服务,但不适用于所有服务 我不会在Notifications 为什么Icinga2电报通知在特定服务中失败?,notifications,monitoring,icinga,Notifications,Monitoring,Icinga,我创建了与电子邮件通知非常相似的自定义电报通知。问题是,它适用于主机和大多数服务,但不适用于所有服务 我不会在scripts文件夹中发布*.sh文件,因为它可以正常工作 在constants.conf中,我添加了bot令牌: const TelegramBotToken = "MyTelegramToken" 我想在用户文件中管理电报频道或聊天ID,所以我有users/user my username.conf,如下所示: object User "my-username" { imp
scripts
文件夹中发布*.sh
文件,因为它可以正常工作
在constants.conf
中,我添加了bot令牌:
const TelegramBotToken = "MyTelegramToken"
我想在用户文件中管理电报频道或聊天ID,所以我有users/user my username.conf
,如下所示:
object User "my-username" {
import "generic-user"
display_name = "My Username"
groups = ["faxadmins"]
email = "my-username@domain.com"
vars.telegram_chat_id = "@my_channel"
}
在templates/templates.conf
中,我添加了以下代码:
template Host "generic-host-domain" {
import "generic-host"
vars.notification.mail.groups = ["domainadmins"]
vars.notification["telegram"] = {
users = [ "my-username" ]
}
}
template Service "generic-service-fax" {
import "generic-service"
vars.notification["telegram"] = {
users = [ "my-username" ]
}
}
在通知中
我有:
template Notification "telegram-host-notification" {
command = "telegram-host-notification"
period = "24x7"
}
template Notification "telegram-service-notification" {
command = "telegram-service-notification"
period = "24x7"
}
apply Notification "telegram-notification" to Host {
import "telegram-host-notification"
user_groups = host.vars.notification.telegram.groups
users = host.vars.notification.telegram.users
assign where host.vars.notification.telegram
}
apply Notification "telegram-notification" to Service {
import "telegram-service-notification"
user_groups = host.vars.notification.telegram.groups
users = host.vars.notification.telegram.users
assign where host.vars.notification.telegram
}
这是我所有的。正如我之前所说,它适用于某些服务,而不适用于其他服务。我在服务
或主机
文件中没有任何用于电报通知
的配置
为了进行测试,我使用了ICingaWeb2
。转到主机中的特定服务并发送自定义通知。当我发送自定义通知时,我会检查日志文件以查看是否有任何错误,它会显示已完成
:
[2017-01-01 11:48:38 +0000] information/Notification: Sending reminder 'Problem' notification 'host-***!serviceName!telegram-notification for user 'my-username'
[2017-01-01 11:48:38 +0000] information/Notification: Completed sending 'Problem' notification 'host-***!serviceName!telegram-notification' for checkable 'host-***!serviceName' and user 'my-username'.
我应该注意到,电子邮件是按预期发送的。12项服务中有2项的电报通知有问题
知道罪魁祸首是什么吗?这里有什么问题?脚本(命令)的返回是否会影响此行为
在任何服务中都没有电报配置。一些电报命令可能由于标记解析器而失败。 我遇到了这个问题:
如果服务名称有一个下划线(“”),则解析器将抱怨未关闭标记,并且消息将不会发送究竟哪些服务失败?@anatol它是一个rabbitMQ服务,使用脚本返回数据。有趣的是,它可以在其他rabbitMQ服务上工作。