Icinga Notifications in Telegram

git clone https://github.com/FAUSheppy/telegram-http-gateway
cd telegram-http-gateway echo $AUTH_TOKEN > bot.token
python3 -m pip install -r req.txt
./telegram-interface.py --port 6000
include /etc/icinga2/monitoring-tools/commands.d/telegram-notify.conf;

Notification Command Object

object NotificationCommand "telegram-service-notification" {
command = [ "/usr/bin/curl", "-X", "POST", "-H", "Content-Type:
application/json", "--data", "
{ 'service_name' : 'hello world',
service_type : '$notification_type$' }",
"localhost:6000/send-all-icinga"]
}
object NotificationCommand "telegram-service-notification" {
command = [ "/etc/icinga2/monitoring-tools/telegram-notify.py" ]

arguments += {
"-4" = "$notification_address$"
"-6" = "$notification_address6$"
"-b" = "$notification_author$"
"-c" = "$notification_comment$"
"-d" = {
required = true
value = "$notification_date$"
}
"-e" = {
required = true
value = "$notification_servicename$"
}
"-f" = {
value = "$notification_from$"
description = "Set from address."
}
"-i" = "$notification_icingaweb2url$"
"-l" = {
required = true
value = "$notification_hostname$"
}
"-n" = {
required = true
value = "$notification_hostdisplayname$"
}
"-o" = {
required = true
value = "$notification_serviceoutput$"
}
"-r" = {
required = true
value = "$notification_useremail$"
}
"-s" = {
required = true
value = "$notification_servicestate$"
}
"-t" = {
required = true
value = "$notification_type$"
}
"-u" = {
required = true
value = "$notification_servicedisplayname$"
}
"-v" = "$notification_logtosyslog$"
}

vars += {
notification_address = "$address$"
notification_address6 = "$address6$"
notification_author = "$notification.author$"
notification_comment = "$notification.comment$"
notification_type = "$notification.type$"
notification_date = "$icinga.long_date_time$"
notification_hostname = "$host.name$"
notification_hostdisplayname = "$host.display_name$"
notification_servicename = "$service.name$"
notification_serviceoutput = "$service.output$"
notification_servicestate = "$service.state$"
notification_useremail = "$user.email$"
notification_servicedisplayname = "$service.display_name$"
}
}

Notification Object

apply Notification "telegram-generic" to Service {
import "mail-service-notification"
user_groups = ["icingaadmins"]
command = "telegram-service-notification"
assign where host.address
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store