为什么Icinga2电报通知在特定服务中失败?

时间:2017-01-01 11:52:12

标签: notifications monitoring icinga

我创建的自定义电报通知与电子邮件通知非常相似。问题是它适用于主机和大多数服务,但不适用于所有服务。

我不会在scripts文件夹中发布constants.conf文件,因为它有效!

const TelegramBotToken = "MyTelegramToken" 我添加了机器人令牌:

users/user-my-username.conf

我想管理用户文件中的电报频道或聊天ID,所以我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" ] } } 我添加了以下代码:

notifications

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 } 我有:

service

这就是我的全部。正如我之前所说,它适用于某些服务,不适用于其他服务。 host的{​​{1}}或telegram notification个文件中没有任何配置。

要测试我使用Icinga web2。转到主机中的特定服务并发送自定义通知。当我发送自定义通知时,我会检查日志文件以查看是否有任何错误,并显示completed

[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个服务的电报通知只有一个问题。

知道什么是罪魁祸首?这里有什么问题?脚本(命令)的返回是否会影响此行为?

任何服务都没有Telegram配置。

1 个答案:

答案 0 :(得分:1)

由于降价解析器,某些电报命令可能会失败。 我遇到过这个问题: 如果服务名称有一个下划线('_'),则解析器会抱怨没有关闭的markdown标记,并且不会发送消息

相关问题