diff options
author | Christian Hesse <mail@eworm.de> | 2022-10-20 15:28:25 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2022-10-21 15:00:39 +0200 |
commit | c3da4ed69604bfcc2ec01c8c735a2e9820d1a4af (patch) | |
tree | dc4401651e5c71a666e80bcb20fa5de36729cf89 | |
parent | a1ef912ec7e3cc87c04d1a558ea837b16a5bf325 (diff) |
netwatch-notify: stop flooding the log after down notification
This will now log all messages before notification, and every two hours
(or scheduler interval * 120) after.
-rw-r--r-- | netwatch-notify | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/netwatch-notify b/netwatch-notify index 27e0759..76b3f2b 100644 --- a/netwatch-notify +++ b/netwatch-notify @@ -143,11 +143,13 @@ $ScriptLock $0; :set Parent ($NetwatchNotify->$Parent->"parent"); } } - $LogPrintExit2 [ $IfThenElse ($HostInfo->"no-down-notification" != true) info debug ] $0 \ - ("The " . $Type . " '" . $Name . "' (" . $HostDetails . ") is down for " . \ - $Metric->"count-down" . " checks, " . [ $IfThenElse ($ParentNotified = false) [ $IfThenElse \ - ($Metric->"notified" = true) ("already notified.") ($CountDown - $Metric->"count-down" . \ - " to go.") ] ("parent " . $Type . " " . $Parent . " is down.") ]) false; + :if ($Metric->"notified" = false || $Metric->"count-down" % 120 = 0) do={ + $LogPrintExit2 [ $IfThenElse ($HostInfo->"no-down-notification" != true) info debug ] $0 \ + ("The " . $Type . " '" . $Name . "' (" . $HostDetails . ") is down for " . \ + $Metric->"count-down" . " checks, " . [ $IfThenElse ($ParentNotified = false) [ $IfThenElse \ + ($Metric->"notified" = true) ("already notified.") ($CountDown - $Metric->"count-down" . \ + " to go.") ] ("parent " . $Type . " " . $Parent . " is down.") ]) false; + } :if ((($CountDown * 2) - ($Metric->"count-down" * 3)) / 2 = 0 && \ [ :typeof ($HostInfo->"pre-down-hook") ] = "str") do={ $NetwatchNotifyHook $Name $Type "pre-down" ($HostInfo->"pre-down-hook"); |