Skip to content

Commit 493e4fc

Browse files
committed
netwatch-notify: use a counter for resolve failures
This should relax the error message a bit as it is not triggered on first failure.
1 parent 84b5e77 commit 493e4fc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

netwatch-notify

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ $ScriptLock $0;
6969
:if ($HostInfo->"notify" = true && $HostInfo->"disabled" != true) do={
7070
:local Name [ $EitherOr ($HostInfo->"name") ($HostVal->"name") ];
7171

72-
:local Metric { "count-down"=0; "count-up"=0; "notified"=false };
72+
:local Metric { "count-down"=0; "count-up"=0; "notified"=false; "resolve-failcnt"=0 };
7373
:if ([ :typeof ($NetwatchNotify->$Name) ] = "array") do={
7474
:set $Metric ($NetwatchNotify->$Name);
7575
}
@@ -84,14 +84,14 @@ $ScriptLock $0;
8484
$HostInfo->"name") "" ] . "' resolves to different address " . $Resolve . \
8585
", updating.") false;
8686
/tool/netwatch/set host=$Resolve $Host;
87-
:set ($Metric->"resolve-failed") false;
87+
:set ($Metric->"resolve-failcnt") 0;
8888
}
8989
} on-error={
90-
:if ($Metric->"resolve-failed" != true) do={
90+
:set ($Metric->"resolve-failcnt") ($Metric->"resolve-failcnt" + 1);
91+
:if ($Metric->"resolve-failcnt" = 3) do={
9192
$LogPrintExit2 warning $0 ("Resolving name '" . $HostInfo->"resolve" . [ $IfThenElse \
9293
($HostInfo->"resolve" != $HostInfo->"name") ("' for " . $Type . " '" . \
9394
$HostInfo->"name") "" ] . "' failed.") false;
94-
:set ($Metric->"resolve-failed") true;
9595
}
9696
}
9797
}
@@ -174,7 +174,7 @@ $ScriptLock $0;
174174
"count-up"=($Metric->"count-up");
175175
"notified"=($Metric->"notified");
176176
"parent"=($Metric->"parent");
177-
"resolve-failed"=($Metric->"resolve-failed");
177+
"resolve-failcnt"=($Metric->"resolve-failcnt");
178178
"since"=($Metric->"since") };
179179
}
180180
}

0 commit comments

Comments
 (0)