From d7cdc5c0a1834727aa6074b7cc77079c0503ee45 Mon Sep 17 00:00:00 2001 From: Marianne Spiller Date: Sun, 12 Apr 2020 11:34:32 +0200 Subject: [PATCH 1/4] Update README.md --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index c7e2062..c58ab48 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,8 @@ apply Notification "Host by Telegram" to Host { ``` #### Example Command Definitions +
+ object NotificationCommand "Notify Host By Telegram" ```ini object NotificationCommand "Notify Host By Telegram" { @@ -115,6 +117,11 @@ object NotificationCommand "Notify Host By Telegram" { } ``` +
+ +
+ object NotificationCommand "Notify Service By Telegram" + ```ini object NotificationCommand "Notify Service By Telegram" { import "plugin-notification-command" @@ -173,6 +180,9 @@ object NotificationCommand "Notify Service By Telegram" { } } ``` + +
+ #### Example Director config ![Icinga Director Config](img/Telegram_Notification_in_Icinga_Director.jpg) From 483af2368b5d33a7e3cb224b62d3c2f81eba92b8 Mon Sep 17 00:00:00 2001 From: Marianne Spiller Date: Sun, 12 Apr 2020 12:06:28 +0200 Subject: [PATCH 2/4] Update README.md --- README.md | 145 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 121 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index c58ab48..94801fe 100644 --- a/README.md +++ b/README.md @@ -43,28 +43,54 @@ If you do not want to notify a group i.e. just **a direct user notification**: Sending a test notification – replace the token, botname and chat id obviously. -`sudo -u nagios ./service-by-telegram.sh -4 127.0.0.1 -l myhostname -o testingTGnotifiy -p -q -r "<1234134325:blafasel>" -s CRITICAL -c mycomment -b mycommentuser -i https://myicingaserver/icingaweb2 -n maaaaaaaaaaa -d"$(date +%F-%T)" -e serviceshort -u fullservicename -D` - - -### Icinga2 objects -#### Example Notification Object - -```ini -apply Notification "Host by Telegram" to Host { - command = "Notify Host By Telegram" - interval = 1h - assign where host.vars.notification_type == "Telegram" - users = [ "telegram_unixe" ] - vars.notification_logtosyslog = true - vars.telegram_bot = "" - vars.telegram_chatid = "" - vars.telegram_bottoken = "" -} +``` +sudo -u nagios ./service-by-telegram.sh -4 127.0.0.1 \ +-l myhostname \ +-o testingTGnotifiy \ +-p \ +-q \ +-r "<1234134325:blafasel>" \ +-s CRITICAL \ +-c mycomment \ +-b mycommentuser \ +-i https://myicingaserver/icingaweb2 \ +-n maaaaaaaaaaa \ +-d"$(date +%F-%T)" \ +-e serviceshort \ +-u fullservicename \ +-D ``` -#### Example Command Definitions +### Icinga2 objects +#### Example user templates
- object NotificationCommand "Notify Host By Telegram" + Generic user template + +```ini +template User "Generic User Template" { + enable_notifications = true +} +``` +
+ +
+ User "telegram_bot" + +```ini +object User "telegram_bot" { + import "Generic User Template" + + display_name = "Bot via Telegram" + email = "you@yourdomain.tld" + states = [ Critical, Down, OK, Unknown, Up, Warning ] + types = [ Custom, Problem, Recovery ] +} +``` +
+ +#### Example command definitions +
+ Notification Command: Hosts by Telegram ```ini object NotificationCommand "Notify Host By Telegram" { @@ -116,11 +142,10 @@ object NotificationCommand "Notify Host By Telegram" { } } ``` -
- object NotificationCommand "Notify Service By Telegram" + Notification Command: Services by Telegram ```ini object NotificationCommand "Notify Service By Telegram" { @@ -180,9 +205,81 @@ object NotificationCommand "Notify Service By Telegram" { } } ``` -
- -#### Example Director config +#### Example notification objects + +
+ Notification Template: Telegram Generic + +```ini +template Notification "Template: Telegram (Generic)" { + vars.telegram_bot = "" + vars.telegram_bottoken = "" + vars.telegram_chatid = "" + vars.telegram_notification_logtosyslog = true +} +``` +
+ +
+ Notification Template: Host Notifications + +```ini +template Notification "Template: Host Notifications via Telegram" { + import "Template: Telegram (Generic)" + + command = "Notify Host By Telegram" + interval = 1h +} +``` +
+ +
+ Notification Template: Service Notifications + +```ini +template Notification "Template: Service Notifications via Telegram" { + import "Template: Telegram (Generic)" + + command = "Notify Service By Telegram" + interval = 4h +} +``` +
+ + +#### Example notification apply rules +
+ Apply rule for host notifications + +```ini + apply Notification "Host Alert via @telegram_bot" to Host { + import "Template: Host Notifications via Telegram" + + interval = 1h + assign where host.vars.notification_type == "Telegram" + states = [ Down, Up ] + types = [ Custom, Problem, Recovery ] + users = [ "telegram_bot" ] +} +``` +
+ +
+ Apply rule for service notifications + +```ini +apply Notification "Service Alerts via @telegram_bot" to Service { + import "Template: Service Notifications via Telegram" + + interval = 12h + assign where host.vars.notification_type == "Telegram" + users = [ "telegram_bot" ] +} +``` +
+ + +#### Example Director screenshot ![Icinga Director Config](img/Telegram_Notification_in_Icinga_Director.jpg) From 5d89dbca5104ba63e28c79f1c586ad2f5a8dd7da Mon Sep 17 00:00:00 2001 From: Marianne Spiller Date: Sun, 12 Apr 2020 12:20:32 +0200 Subject: [PATCH 3/4] Update README.md --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/README.md b/README.md index 94801fe..5a10168 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,41 @@ sudo -u nagios ./service-by-telegram.sh -4 127.0.0.1 \ ``` ### Icinga2 objects +#### Example host objects +
+ Example host template + +```ini +template Host "Generic Host Template" { + check_command = "hostalive" + max_check_attempts = "3" + check_interval = 1m + retry_interval = 1m + check_timeout = 30s + enable_notifications = true + enable_active_checks = true + enable_passive_checks = true + enable_event_handler = true + enable_flapping = true + enable_perfdata = true + volatile = false + vars.notification_type = "Telegram" +} +``` +
+ +
+ Example host object + +```ini +object Host "icinga2-master" { + import "Generic Host Template" + address = "127.0.0.1" +} + +``` +
+ #### Example user templates
Generic user template @@ -282,4 +317,9 @@ apply Notification "Service Alerts via @telegram_bot" to Service { #### Example Director screenshot +
+ Notifications by Telegram via Icinga Director + ![Icinga Director Config](img/Telegram_Notification_in_Icinga_Director.jpg) +
+ From 478357de7616bb34cc4e8bd331e49a9c5b8a47e0 Mon Sep 17 00:00:00 2001 From: Marianne Spiller Date: Sun, 12 Apr 2020 13:12:42 +0200 Subject: [PATCH 4/4] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 5a10168..c51c228 100644 --- a/README.md +++ b/README.md @@ -323,3 +323,7 @@ apply Notification "Service Alerts via @telegram_bot" to Service { ![Icinga Director Config](img/Telegram_Notification_in_Icinga_Director.jpg)
+#### Related Director Baskets +* [Just the Commands](contrib/Director-Basket_Telegram_Commands.json) +* [Commands and Notification Templates with fields](contrib/Director-Basket_Telegram_Notifications.json) + (requires Director v1.8.0 or a master newer than [80f9ea2])(https://github.com/Icinga/icingaweb2-module-director/commit/80f9ea2)