top of page

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

  1. Create Telegram Bot using @BotFather

    1. Search @BotFather in Telegram App

    2. /start  # If it not start

    3. /newbot  # To create new bot

    4. NagiosAlert_Bot  # Bot display name

    5. NagiosAlert_bot  # Bot username

    6. Take note the token, exp: 123456789:AKFJjfads8713lknsaldkfjanl1239102381231

    7. /setprivacy

      1. Select the bot then select Disable

    8. Invite bot into Nagios Alert Group

    9. You write something on the group

    10. Go to Shell execute:

      1. curl -Lk -i -X GET https://api.telegram.org/botACCESSTOKEN-GIVEN-FROM-BOTFATHER/getUpdates

      2. 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"}}]}

      3. Take note: "id":-123456789

  2. Nagios Commands:

  1. 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"}

  2. 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"

bottom of page