diff options
author | Christian Hesse <mail@eworm.de> | 2022-09-20 22:40:47 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2022-09-20 22:49:04 +0200 |
commit | 493e4fc8c116e094a420adb4cb2383065cf02443 (patch) | |
tree | fea98b1b756f55df15b4f6dc246afdccaaa48dbe | |
parent | 84b5e77860e2705c257273395cf21ea4e3da5ccf (diff) |
netwatch-notify: use a counter for resolve failures
This should relax the error message a bit as it is not triggered
on first failure.
-rw-r--r-- | netwatch-notify | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/netwatch-notify b/netwatch-notify index 1d285de..f95f426 100644 --- a/netwatch-notify +++ b/netwatch-notify @@ -69,7 +69,7 @@ $ScriptLock $0; :if ($HostInfo->"notify" = true && $HostInfo->"disabled" != true) do={ :local Name [ $EitherOr ($HostInfo->"name") ($HostVal->"name") ]; - :local Metric { "count-down"=0; "count-up"=0; "notified"=false }; + :local Metric { "count-down"=0; "count-up"=0; "notified"=false; "resolve-failcnt"=0 }; :if ([ :typeof ($NetwatchNotify->$Name) ] = "array") do={ :set $Metric ($NetwatchNotify->$Name); } @@ -84,14 +84,14 @@ $ScriptLock $0; $HostInfo->"name") "" ] . "' resolves to different address " . $Resolve . \ ", updating.") false; /tool/netwatch/set host=$Resolve $Host; - :set ($Metric->"resolve-failed") false; + :set ($Metric->"resolve-failcnt") 0; } } on-error={ - :if ($Metric->"resolve-failed" != true) do={ + :set ($Metric->"resolve-failcnt") ($Metric->"resolve-failcnt" + 1); + :if ($Metric->"resolve-failcnt" = 3) do={ $LogPrintExit2 warning $0 ("Resolving name '" . $HostInfo->"resolve" . [ $IfThenElse \ ($HostInfo->"resolve" != $HostInfo->"name") ("' for " . $Type . " '" . \ $HostInfo->"name") "" ] . "' failed.") false; - :set ($Metric->"resolve-failed") true; } } } @@ -174,7 +174,7 @@ $ScriptLock $0; "count-up"=($Metric->"count-up"); "notified"=($Metric->"notified"); "parent"=($Metric->"parent"); - "resolve-failed"=($Metric->"resolve-failed"); + "resolve-failcnt"=($Metric->"resolve-failcnt"); "since"=($Metric->"since") }; } } |