mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
netwatch-notify: use a counter for resolve failures
This should relax the error message a bit as it is not triggered on first failure.
This commit is contained in:
parent
84b5e77860
commit
493e4fc8c1
1 changed files with 5 additions and 5 deletions
|
@ -69,7 +69,7 @@ $ScriptLock $0;
|
||||||
:if ($HostInfo->"notify" = true && $HostInfo->"disabled" != true) do={
|
:if ($HostInfo->"notify" = true && $HostInfo->"disabled" != true) do={
|
||||||
:local Name [ $EitherOr ($HostInfo->"name") ($HostVal->"name") ];
|
: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={
|
:if ([ :typeof ($NetwatchNotify->$Name) ] = "array") do={
|
||||||
:set $Metric ($NetwatchNotify->$Name);
|
:set $Metric ($NetwatchNotify->$Name);
|
||||||
}
|
}
|
||||||
|
@ -84,14 +84,14 @@ $ScriptLock $0;
|
||||||
$HostInfo->"name") "" ] . "' resolves to different address " . $Resolve . \
|
$HostInfo->"name") "" ] . "' resolves to different address " . $Resolve . \
|
||||||
", updating.") false;
|
", updating.") false;
|
||||||
/tool/netwatch/set host=$Resolve $Host;
|
/tool/netwatch/set host=$Resolve $Host;
|
||||||
:set ($Metric->"resolve-failed") false;
|
:set ($Metric->"resolve-failcnt") 0;
|
||||||
}
|
}
|
||||||
} on-error={
|
} 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 \
|
$LogPrintExit2 warning $0 ("Resolving name '" . $HostInfo->"resolve" . [ $IfThenElse \
|
||||||
($HostInfo->"resolve" != $HostInfo->"name") ("' for " . $Type . " '" . \
|
($HostInfo->"resolve" != $HostInfo->"name") ("' for " . $Type . " '" . \
|
||||||
$HostInfo->"name") "" ] . "' failed.") false;
|
$HostInfo->"name") "" ] . "' failed.") false;
|
||||||
:set ($Metric->"resolve-failed") true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ $ScriptLock $0;
|
||||||
"count-up"=($Metric->"count-up");
|
"count-up"=($Metric->"count-up");
|
||||||
"notified"=($Metric->"notified");
|
"notified"=($Metric->"notified");
|
||||||
"parent"=($Metric->"parent");
|
"parent"=($Metric->"parent");
|
||||||
"resolve-failed"=($Metric->"resolve-failed");
|
"resolve-failcnt"=($Metric->"resolve-failcnt");
|
||||||
"since"=($Metric->"since") };
|
"since"=($Metric->"since") };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue