Created
January 20, 2016 15:03
-
-
Save cyper85/ab8bc2d1aea6a1adc88d to your computer and use it in GitHub Desktop.
Nagios Notfication via Telegram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 'notify-host-by-telegram' command definition | |
define command{ | |
command_name notify-host-by-telegram | |
command_line /usr/bin/curl -X POST --data chat_id=$CONTACTPAGER$ --data text="***** Nagios *****%0A%0ANotification Type: $NOTIFICATIONTYPE$%0AHost: $HOSTNAME$%0AState: $HOSTSTATE$%0AAddress: $HOSTADDRESS$%0AInfo: $HOSTOUTPUT$%0A%0ADate/Time: | |
$LONGDATETIME$%0A" https://api.telegram.org/bot$BOT-TOKEN$/sendMessage | |
} | |
# 'notify-service-by-telegram' command definition | |
define command{ | |
command_name notify-service-by-telegram | |
command_line /usr/bin/curl -X POST --data chat_id=$CONTACTPAGER$ --data text="***** Nagios *****%0A%0ANotification Type: $NOTIFICATIONTYPE$%0A%0AService: $SERVICEDESC$%0AHost: $HOSTALIAS$%0AAddress: $HOSTADDRESS$%0AState: $SERVICESTATE$%0A%0 | |
ADate/Time: $LONGDATETIME$%0A%0AAdditional Info:%0A%0A$SERVICEOUTPUT$%0A" https://api.telegram.org/bot$BOT-TOKEN$/sendMessage | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define contact { | |
contact_name andreas-telegram | |
alias Andreas Neumann | |
service_notification_options w,u,c,r | |
service_notification_period 24x7 | |
host_notification_period 24x7 | |
service_notification_commands notify-service-by-telegram | |
host_notification_commands notify-host-by-telegram | |
host_notification_options d,r | |
pager $CHAT-ID$ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This is a sample shell script showing how you can submit the SEND_CUSTOM_HOST_NOTIFICATION command | |
# to Nagios. Adjust variables to fit your environment as necessary. | |
now=`date +%s` | |
commandfile='/var/lib/nagios3/rw/nagios.cmd' | |
/usr/bin/printf "[%lu] SEND_CUSTOM_HOST_NOTIFICATION;blog.stadtplan-ilmenau.de;3;andreas-telegram;Sinnlose Notification als Test?!?\n" $now > $commandfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment