NETWAYS / icinga2-notification-telegram

Send Icinga 2 notifications via Telegram
https://netways.de/
GNU General Public License v3.0
16 stars 9 forks source link

Problem Send but no Notification on Bot #1

Closed sawitcon closed 2 years ago

sawitcon commented 5 years ago

Hello,

I finally have setup your scripts and setup the notifications. I have one test host, and if it goes down the log says: [2019-04-12 10:50:17 +0200] information/Checkable: Checking for configured notifications for object 'test2' [2019-04-12 10:50:17 +0200] information/Notification: Sending 'Problem' notification 'test2!Host by Telegram' for user 'telegram_unixe' [2019-04-12 10:50:17 +0200] information/Notification: Completed sending 'Problem' notification 'test2!Host by Telegram' for checkable 'test2' and user 'telegram_unixe'.

But on the bot I got no notification

When it goes up again: [2019-04-12 11:23:34 +0200] information/Notification: Sending 'Recovery' notification 'test2!Host by Telegram' for user 'telegram_unixe' [2019-04-12 11:23:34 +0200] information/Notification: Completed sending 'Recovery' notification 'test2!Host by Telegram' for checkable 'test2' and user 'telegram_unixe'.

I'll get a notification

alert

Yours Alex

netzwerkgoettin commented 5 years ago

Hi sawitcon,

I got your message and will look for that as soon as possible - just be a bit patient please :)

Thank you, Marianne

netzwerkgoettin commented 5 years ago

Hi Alex,

I just updated both, README and code – a user contributed some great ideas. I installed it on a test host, and everything works fine for me. So up to your case, there might be several reasons the message for Problem does not go out to the user. I would check

But I assume you solved it by yourself meanwhile :)

Cheers, Marianne

achmet9948 commented 4 years ago

Hi sysadmama,

I configure the notificaton with your script today. I have now the same error like sawitcon. Have you any idea yet? image

Icinga sent the notification but on telegrom the message with the problem I did't receive. The recovery works fine.

Best regards Steffen

netzwerkgoettin commented 4 years ago

Hi Steffen, hi Alex,

I just did a setup from scratch and everything works as it's intended. I got a pull request I just merged, and I extended the docs - can you please have a look at it? I'm pretty sure it's a very small undiscovered misconfiguration anywhere.

Cheers, Marianne

achmet9948 commented 4 years ago

Hi Marianna, I rebuild today my icinga farm. But the notification don't work. I havn't an idea.

zones.d/raspberrypi/commands.conf object NotificationCommand "Notify Host by Telegram" { import "plugin-notification-command" command = [ "/etc/icinga2/scripts/host-by-telegram.sh" ] arguments += { "-4" = { required = true value = "$address$" } "-6" = "$address6$" "-b" = "$notification.author$" "-c" = "$notification.comment$" "-d" = { required = true value = "$icinga.long_date_time$" } "-i" = "$icingaweb2url$" "-l" = { required = true value = "$host.name$" } "-n" = "$host.display_name$" "-o" = { required = true value = "$host.output$" } "-p" = { required = true value = "$telegram_bot$" } "-q" = { required = true value = "$telegram_chatid$" } "-r" = { required = true value = "$telegram_bottoken$" } "-s" = { required = true value = "$host.state$" } "-t" = { required = true value = "$notification.type$" } "-v" = "$telegram_notification_logtosyslog$" } }

achmet9948 commented 4 years ago

In the Icinga-Log are the following lines: [2020-05-08 19:00:12 +0100] information/Notification: Sending 'Custom' notification 'XXXXXXX!Host Crit' for user 'steffen' [2020-05-08 19:00:12 +0100] information/Notification: Completed sending 'Custom' notification 'XXXXXXX'!Host Crit' for checkable 'mail.fam-meck.de' and user 'steffen' using command 'Notify Host by Telegram'.

But in telegram does nothing happend.

achmet9948 commented 4 years ago

Okay I thin I found something. If I set the state to Down via "Process check result" I recive a notification.

So I think, the plugin output is not correct. is that possible? My server is connected to Icinga via OpenVPN. If I stop the Service on my server, the plugin Output is following:

On the history I the the notification, but without output: ![image](https://user-images.githubusercontent.com/35784592/81442226-82350200-9173-11ea-913f-4349f7e5071f.png)
achmet9948 commented 4 years ago

Okay I found the Issue! The check timout was to short, so the check terminated. The plugin is critical after 30 seconds. I increase the timeout to 45 seconds. Now works!

chinmay241 commented 2 years ago

I have a similar problem. Checking manually via the CLI with the below command Works 👍

./service-by-telegram.sh -4 127.0.0.1 \
-l myhostname \
-o testingTGnotifiy \
-p bot \
-q "-" \
-r "group" \
-s CRITICAL \
-c mycomment \
-b mycommentuser \
-i https://myicingaserver/icingaweb2 \
-n maaaaaaaaaaa \
-d"$(date +%F-%T)" \
-e serviceshort \
-u fullservicename \
-D

But via Icinga2 Notification's no notification is sent. On the log All I could find:

[2022-02-06 20:35:38 +0200] warning/Process: PID 13721 was terminated by signal 15 (Terminated)
[2022-02-06 20:35:38 +0200] warning/PluginCheckTask: Check command for object 'xyz.com' (PID: 13721, arguments: '/usr/lib/nagios/plugins/check_ping' '-H' '1.1.1.1' '-c' '5000,100%' '-w' '3000,80%') terminated with exit code 128, output: <Timeout exceeded.><Terminated by signal 15 (Terminated).>
[2022-02-06 20:35:38 +0200] information/Checkable: Checkable 'xyz.com' has 1 notification(s). Checking filters for type 'Problem', sends will be logged.
[2022-02-06 20:35:38 +0200] information/Notification: Sending 'Problem' notification 'xyz.com!Host Alert via @telegram_bot' for user 'telegram_bot'
[2022-02-06 20:35:38 +0200] warning/PluginUtility: Error: Non-optional macro 'telegram_botid' used in argument '-q' is missing.
[2022-02-06 20:35:38 +0200] warning/PluginNotificationTask: Notification command for object 'xyz.com' (PID: -1, arguments: 'sh' '-c' '') terminated with exit code 3, output: Error: Non-optional macro 'telegram_botid' used in argument '-q' is missing.
[2022-02-06 20:35:38 +0200] information/Notification: Completed sending 'Problem' notification 'xyz.com!Host Alert via @telegram_bot' for checkable 'xyz.com' and user 'telegram_bot' using command 'Notify Host By Telegram'.

[2022-02-06 20:38:09 +0200] information/Checkable: Checkable 'xyz.com' has 1 notification(s). Checking filters for type 'Recovery', sends will be logged.
[2022-02-06 20:38:09 +0200] information/Notification: Sending 'Recovery' notification 'xyz.com!Host Alert via @telegram_bot' for user 'telegram_bot'
[2022-02-06 20:38:09 +0200] warning/PluginUtility: Error: Non-optional macro 'telegram_botid' used in argument '-q' is missing.
[2022-02-06 20:38:09 +0200] warning/PluginNotificationTask: Notification command for object 'xyz.com' (PID: -1, arguments: 'sh' '-c' '') terminated with exit code 3, output: Error: Non-optional macro 'telegram_botid' used in argument '-q' is missing.
[2022-02-06 20:38:09 +0200] information/Notification: Completed sending 'Recovery' notification 'xyz.com!Host Alert via @telegram_bot' for checkable 'xyz.com' and user 'telegram_bot' using command 'Notify Host By Telegram'.
[2022-02-06 20:38:19 +0200] information/Checkable: Checkable 'xyz.com!ssh' has 1 notification(s). Checking filters for type 'Recovery', sends will be logged.
[2022-02-06 20:38:19 +0200] information/Notification: Sending 'Recovery' notification 'xyz.com!ssh!Service Alerts via @telegram_bot' for user 'telegram_bot'
[2022-02-06 20:38:19 +0200] warning/PluginUtility: Error: Non-optional macro 'telegram_botid' used in argument '-q' is missing.
[2022-02-06 20:38:19 +0200] warning/PluginNotificationTask: Notification command for object 'xyz.com!ssh' (PID: -1, arguments: 'sh' '-c' '') terminated with exit code 3, output: Error: Non-optional macro 'telegram_botid' used in argument '-q' is missing.
[2022-02-06 20:38:19 +0200] information/Notification: Completed sending 'Recovery' notification 'xyz.com!ssh!Service Alerts via @telegram_bot' for checkable 'xyz.com!ssh' and user 'telegram_bot' using command 'Notify Service By Telegram'

I am pretty sure I followed everything correctly and the setup is new.

martialblog commented 2 years ago

Issue might be stale. We don't assume it's a bug with the script.

If this Issue still persists please let us know.