diff options
author | Christian Hesse <mail@eworm.de> | 2022-02-03 13:51:40 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2022-02-10 09:14:36 +0100 |
commit | c03da561cdf7cf6f47de79772749ef459f6ee495 (patch) | |
tree | 315f8bbf20215b40733e6ef41d5f470f3d7ee0d1 /netwatch-notify | |
parent | 8d49babb0114ad55ec3094f7d9cec2f1bfea43be (diff) |
netwatch-notify: allow to suppress notification on host downchange-76-v6
(cherry picked from commit c6e581d4f90c9bea0adf405685aa634e264d1f3b)
Diffstat (limited to 'netwatch-notify')
-rw-r--r-- | netwatch-notify | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/netwatch-notify b/netwatch-notify index ae89cfb..e82cea6 100644 --- a/netwatch-notify +++ b/netwatch-notify @@ -122,10 +122,10 @@ $ScriptLock $0; :set Parent ($NetwatchNotify->$Parent->"parent"); } } - $LogPrintExit2 info $0 ("Host " . $HostName . " (" . $HostVal->"host" . ") is down for " . \ - $Metric->"count" . " checks, " . [ $IfThenElse ($ParentNotified = false) [ $IfThenElse \ - ($Metric->"notified" = true) ("already notified.") ($Count - $Metric->"count" . " to go.") ] \ - ("parent host " . $Parent . " is down.") ]) false; + $LogPrintExit2 [ $IfThenElse ($HostInfo->"no-down-notification" != true) info debug ] $0 \ + ("Host " . $HostName . " (" . $HostVal->"host" . ") is down for " . $Metric->"count" . " checks, " . \ + [ $IfThenElse ($ParentNotified = false) [ $IfThenElse ($Metric->"notified" = true) ("already notified.") \ + ($Count - $Metric->"count" . " to go.") ] ("parent host " . $Parent . " is down.") ]) false; :if ((($Count * 2) - ($Metric->"count" * 3)) / 2 = 0 && [ :typeof ($HostInfo->"pre-down-hook") ] = "str") do={ $NetwatchNotifyHook $HostName "pre-down" ($HostInfo->"pre-down-hook"); } @@ -134,9 +134,11 @@ $ScriptLock $0; :if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={ :set Message ($Message . "\n\n" . [ $NetwatchNotifyHook $HostName "down" ($HostInfo->"down-hook") ]); } - $SendNotification2 ({ origin=$0; \ - subject=([ $SymbolForNotification "cross-mark" ] . "Netwatch Notify: " . $HostName . " down"); \ - message=$Message }); + :if ($HostInfo->"no-down-notification" != true) do={ + $SendNotification2 ({ origin=$0; \ + subject=([ $SymbolForNotification "cross-mark" ] . "Netwatch Notify: " . $HostName . " down"); \ + message=$Message }); + } :set ($Metric->"notified") true; } } |