1
0
mirror of https://github.com/eworm-de/routeros-scripts.git synced 2024-05-11 05:55:19 +00:00

netwatch-notify: cache the result

If this script runs from terminal this will not change... 😜
So cache the result.

Co-authored-by: Michael Gisbers <michael@gisbers.de>
This commit is contained in:
Christian Hesse
2022-10-21 09:07:50 +02:00
parent a0163aa487
commit 6822e71564

View File

@ -52,6 +52,8 @@
$ScriptLock $0; $ScriptLock $0;
:local ScriptFromTerminalCached [ $ScriptFromTerminal $0 ];
:if ([ /system/resource/get uptime ] < 5m) do={ :if ([ /system/resource/get uptime ] < 5m) do={
$LogPrintExit2 info $0 ("System just booted, giving netwatch some time to settle.") true; $LogPrintExit2 info $0 ("System just booted, giving netwatch some time to settle.") true;
} }
@ -145,7 +147,7 @@ $ScriptLock $0;
} }
} }
:if ($Metric->"notified" = false || $Metric->"count-down" % 120 = 0 || \ :if ($Metric->"notified" = false || $Metric->"count-down" % 120 = 0 || \
[ $ScriptFromTerminal $0 ] = true) do={ $ScriptFromTerminalCached = true) do={
$LogPrintExit2 [ $IfThenElse ($HostInfo->"no-down-notification" != true) info debug ] $0 \ $LogPrintExit2 [ $IfThenElse ($HostInfo->"no-down-notification" != true) info debug ] $0 \
("The " . $Type . " '" . $Name . "' (" . $HostDetails . ") is down for " . \ ("The " . $Type . " '" . $Name . "' (" . $HostDetails . ") is down for " . \
$Metric->"count-down" . " checks, " . [ $IfThenElse ($ParentNotified = false) [ $IfThenElse \ $Metric->"count-down" . " checks, " . [ $IfThenElse ($ParentNotified = false) [ $IfThenElse \