NagiosXI integrate Notification with Telegram

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
kimseng
Posts: 42
Joined: Tue Apr 24, 2018 1:40 am

NagiosXI integrate Notification with Telegram

Post by kimseng »

Hi, NagiosXI team,

My NagiosXI is working with send notification to email already but my management team need to send to Telegram Group also so please help to guide me how to configure my NagiosXI to send all notification to Telegram.

i'm waiting to hearing back from you soon.

Best Regards,
Kimseng
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: NagiosXI integrate Notification with Telegram

Post by benjaminsmith »

Hi @Kimseng,

How's the trial of Nagios XI going so far?

Regarding Telegram Integration, I haven't directly setup this one up yet, but there is a script available on the Nagios XI with documentation. This looks like the best option.

Telegram Notifications

Take a look and let me know if you need assistance with anything.

Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
kimseng
Posts: 42
Joined: Tue Apr 24, 2018 1:40 am

Re: NagiosXI integrate Notification with Telegram

Post by kimseng »

Hi,

I have try with NagiosXI license a few year already and my license already expired too and i plan to renew my current license but before i renew i want to look more detail about configure to send notification to Telegram. Look your document not detail so can you have other detail or video that is clear step by step?

Best Regards,
Kimseng
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: NagiosXI integrate Notification with Telegram

Post by benjaminsmith »

HI,

This is a community plugin, and I haven't set this one up directly, there are steps in the associated readme file. First you'll need to download the plugin and transfer the files to the Nagios XI server, I would put these in the plugin directory (/usr/local/nagios/libexec) so nothing is overwritten during an upgrade.

Then setup host and service notification commands:

Code: Select all

define command{
command_name notify-service-telegram
command_line /usr/bin/php /usr/local/nagios/sbin/telegram-notify/telegram-bot.php "$_CONTACTTELEGRAM$" "83633434:kewkekekekdkkfiirrjririrjr" $_SERVICESENDTELEGRAM$ "Notify: $NOTIFICATIONTYPE$ 0XzXZ0 Hsot: $HOSTNAME$ 0XzXZ0 Service: $SERVICEDESC$ 0XzXZ0 Date: $SHORTDATETIME$ 0XzXZ0 Info: $SERVICEOUTPUT$"
}

# 'notify-host-telegram' command definition
define command{
command_name notify-host-telegram
command_line /usr/bin/php /usr/local/nagios/sbin/telegram-notify/telegram-bot.php "$_CONTACTTELEGRAM" "83633434:kewkekekekdkkfiirrjririrjr" $_HOSTSENDTELEGRAM$ "Notify: $NOTIFICATIONTYPE$ 0XzXZ0 Host: $HOSTNAME$ 0XzXZ0 Date: $SHORTDATETIME$ 0XzXZ0 Info: $HOSTOUTPUT$"
}
Then create a contact for Telegram notifications, and assign these notification handlers to the contact.

Code: Select all

define contact{
name generic-contact
...
service_notification_commands notify-service-by-email-bs,notify-service-xml-sms,notify-service-skype,notify-service-telegram
host_notification_commands notify-host-by-email-bs,notify-host-xml-sms,notify-host-skype,notify-host-telegram
...
}
For this script to work, the host or service will also need a custom macro enabling Telegram notifications. For example:

Code: Select all

_SENDTELEGRAM 1;
Try stepping through the documentation and if you reach an error, please post it to the thread so we can help troubleshoot it.
https://exchange.nagios.org/directory/A ... ns/details

Regards,
Benjamin

Also, the process is very similar to setting up Slack Integration, and the guide below may help clarify the process as well.
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
kimseng
Posts: 42
Joined: Tue Apr 24, 2018 1:40 am

Re: NagiosXI integrate Notification with Telegram

Post by kimseng »

Hi,

By follow this url: https://exchange.nagios.org/directory/A ... ns/details

i have done step 2.3 and now i'm starting 3. Nagios Configuration but i don't know where to start so could you give me how to do next?

Best Regards,
Kimseng
You do not have the required permissions to view the files attached to this post.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: NagiosXI integrate Notification with Telegram

Post by benjaminsmith »

Hi @kimseng,

So starting in step 3, you'll create the configuration objects using the Nagios Core Configuration Manager. To create the notification commands go to Configure > Core Config Manager and select Commands from the left-hand menu.
add-new-command.png
Then create both host and service notification commands for Telegram (the command string will need your API key)
new-command.png
Next go to Alerting > Contacts in the left-hand sidebar menu, and create a new contact for Telegram using these notification commands.
contact-notification-commands.png
Choose the Misc tab and set a free variable for the Telegram user id.
free-variables-telegram-1.png
And do the same for each host or service object using Telegram. You can use a template or the Bulk Mods Tool to set this across a large number of host or service objects.
free-variables-telegram.png
A good way to test notifications is by sending passive check results and forcing a state change. You can do this from the Home page by selecting the Advanced tab under host or service status details.
passive-checks.png
Let me know if you get it going. Please post any error messages so we can help troubleshoot.

Regards,
Benjamin
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
kimseng
Posts: 42
Joined: Tue Apr 24, 2018 1:40 am

Re: NagiosXI integrate Notification with Telegram

Post by kimseng »

Hi team,
I have done step 3 and the below is my notification to email and i don't see any notification to my telegram yet so what to do next?

Attachment file is my last notification to my email.

Best Regards,
Kimseng
You do not have the required permissions to view the files attached to this post.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: NagiosXI integrate Notification with Telegram

Post by benjaminsmith »

Hi kimseng,

Let's verify in the nagios log that the notification handler was indeed executed. You'll find the nagios log at:

Code: Select all

/usr/local/nagios/var/nagios.log
Every 24 hours the logs will be rotated in the archive log, so if you would like to see yesterday's data, go to:

Code: Select all

/usr/local/nagios/var/archives
You should see something like this:
[1613588030] HOST NOTIFICATION: nagiosadmin;localhost;DOWN;xi_host_notification_handler;Down
[1613588030] HOST ALERT: localhost;DOWN;HARD;1;Down
However, instead of xi_host_notification_handler it should call your telegram commands that were created for the contact.

Benajmin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
kimseng
Posts: 42
Joined: Tue Apr 24, 2018 1:40 am

Re: NagiosXI integrate Notification with Telegram

Post by kimseng »

Hi,

I see log notification but i don't received on my email and telegram when i enable it
here is my log on tail -f /usr/local/nagios/var/nagios.log

[1613623101] SERVICE NOTIFICATION: nagiosnoc;a CSW1;Ethernet2/7 / Trunk to RT1 Ten0/0/24 / Status;WARNING;notify-service-telegram;WARNING: Interface Ethernet2/37 (index 436879360) is administratively down.
[1613623974] SERVICE ALERT: SW1;GigabitEthernet1/0/9 / --Coffee-DPLC / Status;CRITICAL;SOFT;1;CRITICAL: Interface GigabitEthernet1/0/9 (index 11) is down.
[1613624032] SERVICE ALERT: -SW1;GigabitEthernet1/0/9 / ---DPLC / Status;CRITICAL;SOFT;2;CRITICAL: Interface GigabitEthernet1/0/9 (index 11) is down.
[1613624091] SERVICE ALERT: -SW1;GigabitEthernet1/0/9 / ---DPLC / Status;CRITICAL;SOFT;3;CRITICAL: Interface GigabitEthernet1/0/9 (index 11) is down.
[1613624150] SERVICE ALERT: -SW1;GigabitEthernet1/0/9 / ---DPLC / Status;CRITICAL;SOFT;4;CRITICAL: Interface GigabitEthernet1/0/9 (index 11) is down.
[1613624209] SERVICE ALERT: -SW1;GigabitEthernet1/0/9 / ---DPLC / Status;OK;HARD;1;OK: Interface GigabitEthernet1/0/9 (index 11) is up.
[1613631785] SERVICE NOTIFICATION: nagiosnoc;MEM;ether1 Status;OK;notify-service-telegram;OK: Interface ether1 (index 5) is up.
[1613631785] SERVICE ALERT: MEM;ether1 Status;OK;HARD;1;OK: Interface ether1 (index 5) is up.
[1613631829] SERVICE NOTIFICATION: nagiosnoc;MEM;Loopback0 Status;OK;notify-service-telegram;OK: Interface Loopback0 (index 18) is up.
[1613631829] SERVICE ALERT: MEM;Loopback0 Status;OK;HARD;1;OK: Interface Loopback0 (index 18) is up.
[1613631922] SERVICE NOTIFICATION: nagiosnoc;MEM;Loopback1 Status;OK;notify-service-telegram;OK: Interface Loopback1 (index 20)
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: NagiosXI integrate Notification with Telegram

Post by benjaminsmith »

Hi,

The Telegram notification handler is executing, so I would check the logs on the Telegram side for any errors. In step 2.3 of the instructions, there are directions for testing the telegram command from the CLI to make sure it's working. Was that step successful for you?
2.3. Now you can send test message from command line to see if everything is ok:
- login as nagios user: su - nagios.
- run script (example): php /usr/local/nagios/sbin/telegram-notify/telegram-bot.php "370022700" "83633434:kewkekekekdkkfiirrjririrjr" 1 "Notify: NOTIFICATIONTYPE 0XzXZ0 Host: HOSTNAME 0XzXZ0 Service: SERVICEDESC 0XzXZ0 Date: SHORTDATETIME 0XzXZ0 Info: SERVICEOUTPUT"
, where
370022700 - telegram id of user who need to receive message;
83633434:kewkekekekdkkfiirrjririrjr - HTTP API key of your bot;
1 - mark. Script will send message if flag=1 only.
0XzXZ0 - fake linebreak character. I don't know why n doesn't work :(

If the test was successful go to the last part - configuring nagios.
For email notifications, make sure you have a xi contact assigned to the service with the correct notification settings. If only the telegram contact is assigned, it's not going to email.

See: Nagios XI - Notification Problems

If that's not working, please send me the system profile.

To send us your system profile.
Login to the Nagios XI GUI using a web browser.
Click the "Admin" > "System Profile" Menu
Click the "Download Profile" button

Regards,
Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked