Skip to content

Commit 5aff401

Browse files
committed
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.
1 parent a6645b3 commit 5aff401

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

netwatch-notify

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ $ScriptLock $0;
128128
:set ($Metric->"since") ($HostVal->"since");
129129
:local CountDown [ $IfThenElse ([ :tonum ($HostInfo->"count-down") ] > 0) ($HostInfo->"count-down") 5 ];
130130
:local Parent ($HostInfo->"parent");
131+
:local ParentUp false;
131132
:while ([ :len $Parent ] > 0) do={
132133
:set CountDown ($CountDown + 1);
133134
:set Parent ($NetwatchNotify->$Parent->"parent");
@@ -137,6 +138,7 @@ $ScriptLock $0;
137138
:while ($ParentNotified = false && [ :len $Parent ] > 0) do={
138139
:set ParentNotified [ $IfThenElse (($NetwatchNotify->$Parent->"notified") = true) \
139140
true false ];
141+
:set ParentUp ($NetwatchNotify->$Parent->"count-up");
140142
:if ($ParentNotified = false) do={
141143
:set Parent ($NetwatchNotify->$Parent->"parent");
142144
}
@@ -151,7 +153,7 @@ $ScriptLock $0;
151153
$NetwatchNotifyHook $Name $Type "pre-down" ($HostInfo->"pre-down-hook");
152154
}
153155
:if ($ParentNotified = false && $Metric->"count-down" >= $CountDown && \
154-
$Metric->"notified" != true) do={
156+
($ParentUp = false || $ParentUp > 2) && $Metric->"notified" != true) do={
155157
:local Message ("The " . $Type . " '" . $Name . "' (" . $HostDetails . \
156158
") is down since " . $HostVal->"since" . ".");
157159
:if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={

0 commit comments

Comments
 (0)