aboutsummaryrefslogtreecommitdiffstats
path: root/netwatch-notify
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2022-02-03 13:51:40 +0100
committerGravatar Christian Hesse <mail@eworm.de>2022-02-10 08:41:12 +0100
commitc6e581d4f90c9bea0adf405685aa634e264d1f3b (patch)
tree0ca6b4c59ad7cdb6936a79a762da218ea3dc997e /netwatch-notify
parent42c203291a7db814be00f40caddb6980632358fa (diff)
netwatch-notify: allow to suppress notification on host downchange-76
Diffstat (limited to 'netwatch-notify')
-rw-r--r--netwatch-notify16
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;
}
}