Module: check_mk
Branch: master
Commit: efb1ce95f0a3ca16cb53ccf00a0b2d28b662a2d2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=efb1ce95f0a3ca…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Apr 24 11:33:37 2017 +0200
4590 Now retry and expire time can be configured in pushover notification below
'emergency' priority
Change-Id: I482375e2e8b1d49e7e84ac7d36e7771432b0f424
---
.werks/4590 | 10 ++++++++++
notifications/pushover | 2 ++
web/plugins/wato/notifications.py | 40 ++++++++++++++++++++++++++++++---------
3 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/.werks/4590 b/.werks/4590
new file mode 100644
index 0000000..81b1d69
--- /dev/null
+++ b/.werks/4590
@@ -0,0 +1,10 @@
+Title: Now retry and expire time can be configured in pushover notification below
'emergency' priority
+Level: 1
+Component: notifications
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1493018255
+Class: feature
+
+
diff --git a/notifications/pushover b/notifications/pushover
index d9b9d39..a3527e1 100755
--- a/notifications/pushover
+++ b/notifications/pushover
@@ -122,6 +122,8 @@ def send_push_notification(api_key, recipient_key, subject, text,
context):
("message", text.encode("utf-8")),
("timestamp", int(context["MICROTIME"])/1000000),
("priority", context.get("PARAMETER_PRIORITY", 0)),
+ ("expire", context.get("PARAMETER_PRIORITY_EXPIRE", 0)),
+ ("retry", context.get("PARAMETER_PRIORITY_RETRY", 0)),
("html", 1),
])
diff --git a/web/plugins/wato/notifications.py b/web/plugins/wato/notifications.py
index ea3afe2..e978975 100644
--- a/web/plugins/wato/notifications.py
+++ b/web/plugins/wato/notifications.py
@@ -284,6 +284,18 @@ register_notification_parameters(
)
)
+# We have to transform because 'add_to_event_context'
+# in modules/events.py can't handle complex data structures
+def transform_back_pushover_priority(params):
+ if type(params) == tuple:
+ return {"retry" : params[1][0], "expire" : params[1][1]}
+ return params
+
+def transform_forth_pushover_priority(params):
+ if type(params) == dict:
+ return ("2", (params["retry"], params["expire"]))
+ return params
+
register_notification_parameters("pushover", Dictionary(
optional_keys = ["url_prefix", "priority"],
elements = [
@@ -320,15 +332,25 @@ register_notification_parameters("pushover", Dictionary(
default_value = "http://" + socket.gethostname() + "/"
+ (
config.omd_site() and config.omd_site() + "/" or
"") + "check_mk/",
)),
- ("priority", DropdownChoice(
- title = _("Priority"),
- choices = [
- ("1", _("High: Push notification alerts bypass quiet
hours")),
- ("0", _("Normal: Regular push notification
(default)")),
- ("-1", _("Low: No sound/vibration but show popup")),
- ("-2", _("Lowest: No notification, update badge
number")),
- ],
- default_value = "0",
+ ("priority", Transform(
+ CascadingDropdown(
+ title = _("Priority"),
+ choices = [
+ ("2", _("Emergency: Repeat push notification in
intervalls till expire time."),
+ Tuple(elements = [
+ Age(title = _("Retry time")),
+ Age(title = _("Expire time")),
+ ]),
+ ),
+ ("1", _("High: Push notification alerts bypass quiet
hours")),
+ ("0", _("Normal: Regular push notification
(default)")),
+ ("-1", _("Low: No sound/vibration but show
popup")),
+ ("-2", _("Lowest: No notification, update badge
number")),
+ ],
+ default_value = "0",
+ ),
+ forth = transform_forth_pushover_priority,
+ back = transform_back_pushover_priority,
)),
]
))