From 9c7ad26b87b2347bc94e8272f16e393aa10221e3 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 9 Apr 2020 15:18:32 +0200 Subject: [PATCH] contrib: provide sample baskets --- README.md | 6 + .../Director-Basket_Telegram_Commands.json | 150 +++++++++ ...irector-Basket_Telegram_Notifications.json | 294 ++++++++++++++++++ 3 files changed, 450 insertions(+) create mode 100644 contrib/Director-Basket_Telegram_Commands.json create mode 100644 contrib/Director-Basket_Telegram_Notifications.json diff --git a/README.md b/README.md index c7e2062..d3b9f4a 100644 --- a/README.md +++ b/README.md @@ -176,3 +176,9 @@ object NotificationCommand "Notify Service By Telegram" { #### Example Director config ![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) diff --git a/contrib/Director-Basket_Telegram_Commands.json b/contrib/Director-Basket_Telegram_Commands.json new file mode 100644 index 0000000..7be23db --- /dev/null +++ b/contrib/Director-Basket_Telegram_Commands.json @@ -0,0 +1,150 @@ +{ + "Command": { + "Notify Service By Telegram": { + "arguments": { + "-6": { + "value": "$address6$" + }, + "-4": { + "required": true, + "value": "$address$" + }, + "-b": { + "value": "$notification.author$" + }, + "-c": { + "value": "$notification.comment$" + }, + "-d": { + "required": true, + "value": "$icinga.long_date_time$" + }, + "-e": { + "required": true, + "value": "$service.name$" + }, + "-i": { + "value": "$icingaweb2url$" + }, + "-l": { + "required": true, + "value": "$host.name$" + }, + "-n": { + "value": "$host.display_name$" + }, + "-o": { + "required": true, + "value": "$service.output$" + }, + "-p": { + "required": true, + "value": "$telegram_bot$" + }, + "-q": { + "required": true, + "value": "$telegram_chatid$" + }, + "-r": { + "required": true, + "value": "$telegram_bottoken$" + }, + "-s": { + "required": true, + "value": "$service.state$" + }, + "-t": { + "required": true, + "value": "$notification.type$" + }, + "-u": { + "required": true, + "value": "$service.display_name$" + }, + "-v": { + "value": "$telegram_notification_logtosyslog$" + } + }, + "command": "\/etc\/icinga2\/scripts\/service-by-telegram.sh", + "disabled": false, + "fields": [], + "imports": [], + "is_string": null, + "methods_execute": "PluginNotification", + "object_name": "Notify Service By Telegram", + "object_type": "object", + "timeout": "60", + "vars": {}, + "zone": null + }, + "Notify Host By Telegram": { + "arguments": { + "-6": { + "value": "$address6$" + }, + "-4": { + "required": true, + "value": "$address$" + }, + "-b": { + "value": "$notification.author$" + }, + "-c": { + "value": "$notification.comment$" + }, + "-d": { + "required": true, + "value": "$icinga.long_date_time$" + }, + "-i": { + "value": "$icingaweb2url$" + }, + "-l": { + "required": true, + "value": "$host.name$" + }, + "-n": { + "value": "$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": { + "value": "$telegram_notification_logtosyslog$" + } + }, + "command": "\/etc\/icinga2\/scripts\/host-by-telegram.sh", + "disabled": false, + "fields": [], + "imports": [], + "is_string": null, + "methods_execute": "PluginNotification", + "object_name": "Notify Host By Telegram", + "object_type": "object", + "timeout": "60", + "vars": {}, + "zone": null + } + } +} \ No newline at end of file diff --git a/contrib/Director-Basket_Telegram_Notifications.json b/contrib/Director-Basket_Telegram_Notifications.json new file mode 100644 index 0000000..68f3118 --- /dev/null +++ b/contrib/Director-Basket_Telegram_Notifications.json @@ -0,0 +1,294 @@ +{ + "Command": { + "Notify Service By Telegram": { + "arguments": { + "-6": { + "value": "$address6$" + }, + "-4": { + "required": true, + "value": "$address$" + }, + "-b": { + "value": "$notification.author$" + }, + "-c": { + "value": "$notification.comment$" + }, + "-d": { + "required": true, + "value": "$icinga.long_date_time$" + }, + "-e": { + "required": true, + "value": "$service.name$" + }, + "-i": { + "value": "$icingaweb2url$" + }, + "-l": { + "required": true, + "value": "$host.name$" + }, + "-n": { + "value": "$host.display_name$" + }, + "-o": { + "required": true, + "value": "$service.output$" + }, + "-p": { + "required": true, + "value": "$telegram_bot$" + }, + "-q": { + "required": true, + "value": "$telegram_chatid$" + }, + "-r": { + "required": true, + "value": "$telegram_bottoken$" + }, + "-s": { + "required": true, + "value": "$service.state$" + }, + "-t": { + "required": true, + "value": "$notification.type$" + }, + "-u": { + "required": true, + "value": "$service.display_name$" + }, + "-v": { + "value": "$telegram_notification_logtosyslog$" + } + }, + "command": "\/etc\/icinga2\/scripts\/service-by-telegram.sh", + "disabled": false, + "fields": [], + "imports": [], + "is_string": null, + "methods_execute": "PluginNotification", + "object_name": "Notify Service By Telegram", + "object_type": "object", + "timeout": "60", + "vars": {}, + "zone": null + }, + "Notify Host By Telegram": { + "arguments": { + "-6": { + "value": "$address6$" + }, + "-4": { + "required": true, + "value": "$address$" + }, + "-b": { + "value": "$notification.author$" + }, + "-c": { + "value": "$notification.comment$" + }, + "-d": { + "required": true, + "value": "$icinga.long_date_time$" + }, + "-i": { + "value": "$icingaweb2url$" + }, + "-l": { + "required": true, + "value": "$host.name$" + }, + "-n": { + "value": "$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": { + "value": "$telegram_notification_logtosyslog$" + } + }, + "command": "\/etc\/icinga2\/scripts\/host-by-telegram.sh", + "disabled": false, + "fields": [], + "imports": [], + "is_string": null, + "methods_execute": "PluginNotification", + "object_name": "Notify Host By Telegram", + "object_type": "object", + "timeout": "60", + "vars": {}, + "zone": null + } + }, + "NotificationTemplate": { + "Service by Telegram": { + "apply_to": null, + "assign_filter": null, + "command": "Notify Service By Telegram", + "disabled": false, + "fields": [ + { + "datafield_id": 122, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 119, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 121, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 120, + "is_required": "n", + "var_filter": null + } + ], + "host": null, + "imports": [], + "notification_interval": "1800", + "object_name": "Service by Telegram", + "object_type": "template", + "period": null, + "service": null, + "states": [ + "Critical", + "OK", + "Unknown", + "Warning" + ], + "times_begin": null, + "times_end": null, + "types": null, + "user_groups": [], + "users": [], + "vars": { + "notification_logtosyslog": false + }, + "zone": null + }, + "Host by Telegram": { + "apply_to": null, + "assign_filter": null, + "command": "Notify Host By Telegram", + "disabled": false, + "fields": [ + { + "datafield_id": 122, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 119, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 121, + "is_required": "n", + "var_filter": null + }, + { + "datafield_id": 120, + "is_required": "n", + "var_filter": null + } + ], + "host": null, + "imports": [], + "notification_interval": "1800", + "object_name": "Host by Telegram", + "object_type": "template", + "period": null, + "service": null, + "states": [ + "Down", + "Up" + ], + "times_begin": null, + "times_end": null, + "types": null, + "user_groups": [], + "users": [], + "vars": { + "notification_logtosyslog": false + }, + "zone": null + } + }, + "Datafield": { + "122": { + "varname": "notification_logtosyslog", + "caption": "Log to Syslog", + "description": "Whether notifications should be logged to Syslog", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeBoolean", + "format": null, + "originalId": "122", + "settings": {} + }, + "119": { + "varname": "telegram_bot", + "caption": "Telegram Bot Channel", + "description": "Your Telegram bot name", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "originalId": "119", + "settings": { + "visibility": "visible" + } + }, + "121": { + "varname": "telegram_bottoken", + "caption": "Telegram Bot Token", + "description": "Your Telegram bot API token", + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "originalId": "121", + "settings": { + "visibility": "hidden" + } + }, + "120": { + "varname": "telegram_chatid", + "caption": "Telegram Bot Chat ID", + "description": null, + "datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString", + "format": null, + "originalId": "120", + "settings": { + "visibility": "visible" + } + } + } +}