Nagios Telegram Notification Using Bot
DESCRIPTION
Create Telegram bot using BotFather, the bot will be used as Notification sender.
More info: https://github.com/mglantz/nagios-telegram-notification
WHEN TO USE IT?
1) If you want to sent Notification to Telegram without using Phone number.
PRE-REQUSITES
1. Telegram in your Mobile Phone.
2. Group chat.
STEPS
-
Create Telegram Bot using @BotFather
-
Search @BotFather in Telegram App
-
/start # If it not start
-
/newbot # To create new bot
-
NagiosAlert_Bot # Bot display name
-
NagiosAlert_bot # Bot username
-
Take note the token, exp: 123456789:AKFJjfads8713lknsaldkfjanl1239102381231
-
/setprivacy
-
Select the bot then select Disable
-
-
Invite bot into Nagios Alert Group
-
You write something on the group
-
Go to Shell execute:
-
curl -Lk -i -X GET https://api.telegram.org/botACCESSTOKEN-GIVEN-FROM-BOTFATHER/getUpdates
-
Output as: "message":{"message_id":14,"from":{"id":300920731,"is_bot":false,"first_name":"Your","last_name":"Name","language_code":"en-US"},"chat":{"id":-123456789,"title":"My fancy Telegram group","type":"supergroup"},"date":1520901132,"text":"I like beer"}}]}
-
Take note: "id":-123456789
-
-
2. Nagios Commands:
-
Host: curl -k -L --data chat_id=-REPLACEME --data-urlencode "text=***** Nagios ***** Notification Type: $NOTIFICATIONTYPE$ Host: $HOSTNAME$ State: $HOSTSTATE$ Address: $HOSTADDRESS$ Info: $HOSTOUTPUT$ Date/Time: $LONGDATETIME$" "https://api.telegram.org/botREPLACEME/sendMessage"}
-
Service: curl -k -L --data chat_id=-REPLACEME --data-urlencode "text=***** Nagios ***** Notification Type: $NOTIFICATIONTYPE$ Service: $SERVICEDESC$ Host: $HOSTALIAS$ Address: $HOSTADDRESS$ State: $SERVICESTATE$ Date/Time: $LONGDATETIME$ Additional Info: $SERVICEOUTPUT$" "https://api.telegram.org/botREPLACEME/sendMessage"