diff options
author | Christian Hesse <mail@eworm.de> | 2022-09-07 22:16:11 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2022-09-07 22:20:52 +0200 |
commit | 5aff4019fe00f9c5781efb0cd1a37863b8eacab5 (patch) | |
tree | 4dbf0aff6ca431734736e2ebd804ae3f989aed14 | |
parent | a6645b3e75d55ad0028f349a8c4de5618e77beb7 (diff) |
netwatch-notify: do not (yet) notify if parent is up recently
Monitoring a VPN (or similar) may be tricky: This used to send notifications
if the physical connection recovered, but the VPN and/or its routing did not
yet. Let's work around and send notification only if the parent is up
for at least three checks.
-rw-r--r-- | netwatch-notify | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/netwatch-notify b/netwatch-notify index dbf6e10..1d285de 100644 --- a/netwatch-notify +++ b/netwatch-notify @@ -128,6 +128,7 @@ $ScriptLock $0; :set ($Metric->"since") ($HostVal->"since"); :local CountDown [ $IfThenElse ([ :tonum ($HostInfo->"count-down") ] > 0) ($HostInfo->"count-down") 5 ]; :local Parent ($HostInfo->"parent"); + :local ParentUp false; :while ([ :len $Parent ] > 0) do={ :set CountDown ($CountDown + 1); :set Parent ($NetwatchNotify->$Parent->"parent"); @@ -137,6 +138,7 @@ $ScriptLock $0; :while ($ParentNotified = false && [ :len $Parent ] > 0) do={ :set ParentNotified [ $IfThenElse (($NetwatchNotify->$Parent->"notified") = true) \ true false ]; + :set ParentUp ($NetwatchNotify->$Parent->"count-up"); :if ($ParentNotified = false) do={ :set Parent ($NetwatchNotify->$Parent->"parent"); } @@ -151,7 +153,7 @@ $ScriptLock $0; $NetwatchNotifyHook $Name $Type "pre-down" ($HostInfo->"pre-down-hook"); } :if ($ParentNotified = false && $Metric->"count-down" >= $CountDown && \ - $Metric->"notified" != true) do={ + ($ParentUp = false || $ParentUp > 2) && $Metric->"notified" != true) do={ :local Message ("The " . $Type . " '" . $Name . "' (" . $HostDetails . \ ") is down since " . $HostVal->"since" . "."); :if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={ |