diff options
author | Christian Hesse <mail@eworm.de> | 2023-03-20 12:18:32 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2023-03-20 12:35:34 +0100 |
commit | 650c362ed903209bb2144b3d4a89f46ca4865a38 (patch) | |
tree | c98076feaea093eecf167d3633ce17b5ec5aeb1f | |
parent | 3b5026ea8d8e8f9867b85d91c81d2296265d6d6a (diff) |
netwatch-notify: support note in notificationchange-96
-rw-r--r-- | doc/netwatch-notify.md | 7 | ||||
-rw-r--r-- | global-functions.rsc | 2 | ||||
-rw-r--r-- | netwatch-notify.rsc | 6 | ||||
-rw-r--r-- | news-and-changes.rsc | 2 |
4 files changed, 16 insertions, 1 deletions
diff --git a/doc/netwatch-notify.md b/doc/netwatch-notify.md index 5bbd657..aa1204a 100644 --- a/doc/netwatch-notify.md +++ b/doc/netwatch-notify.md @@ -88,6 +88,13 @@ powered off, but accessibility is of interest. Go and get your coffee ☕️ before sending the print job. +### Add a note in notification + +For some extra information it is possible to add a text note. This is +included verbatim into the notification. + + /tool/netwatch/add comment="notify, name=example, note=Do not touch!" host=10.0.0.31; + Also notification settings are required for [e-mail](mod/notification-email.md), [matrix](mod/notification-matrix.md) and/or diff --git a/global-functions.rsc b/global-functions.rsc index 6e3f00a..512cf34 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -12,7 +12,7 @@ :local 0 "global-functions"; # expected configuration version -:global ExpectedConfigVersion 95; +:global ExpectedConfigVersion 96; # global variables not to be changed by user :global GlobalFunctionsReady false; diff --git a/netwatch-notify.rsc b/netwatch-notify.rsc index d04d23f..3f47304 100644 --- a/netwatch-notify.rsc +++ b/netwatch-notify.rsc @@ -112,6 +112,9 @@ $ScriptLock $0; :local Message ("The " . $Type . " '" . $Name . "' (" . $HostDetails . \ ") is up since " . $HostVal->"since" . ".\n" . \ "It was down for " . $CountDown . " checks since " . ($Metric->"since") . "."); + :if ([ :typeof ($HostInfo->"note") ] = "str") do={ + :set Message ($Message . "\n\nNote:\n" . ($HostInfo->"note")); + } :if ([ :typeof ($HostInfo->"up-hook") ] = "str") do={ :set Message ($Message . "\n\n" . [ $NetwatchNotifyHook $Name $Type "up" \ ($HostInfo->"up-hook") ]); @@ -162,6 +165,9 @@ $ScriptLock $0; ($ParentUp = false || $ParentUp > 2) && $Metric->"notified" != true) do={ :local Message ("The " . $Type . " '" . $Name . "' (" . $HostDetails . \ ") is down since " . $HostVal->"since" . "."); + :if ([ :typeof ($HostInfo->"note") ] = "str") do={ + :set Message ($Message . "\n\nNote:\n" . ($HostInfo->"note")); + } :if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={ :set Message ($Message . "\n\n" . [ $NetwatchNotifyHook $Name $Type "down" \ ($HostInfo->"down-hook") ]); diff --git a/news-and-changes.rsc b/news-and-changes.rsc index e532496..e809db2 100644 --- a/news-and-changes.rsc +++ b/news-and-changes.rsc @@ -9,8 +9,10 @@ # Changes for global-config to be added to notification on script updates :global GlobalConfigChanges { + 96="Added support for notes in 'netwatch-notify', these are included verbatim into the notification."; }; # Migration steps to be applied on script updates :global GlobalConfigMigration { + 0; }; |