From 6822e715646833efc3a0018ffe0e840dc8371715 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 21 Oct 2022 09:07:50 +0200 Subject: netwatch-notify: cache the result MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If this script runs from terminal this will not change... 😜 So cache the result. Co-authored-by: Michael Gisbers --- netwatch-notify | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'netwatch-notify') diff --git a/netwatch-notify b/netwatch-notify index e37fc36..7a0766c 100644 --- a/netwatch-notify +++ b/netwatch-notify @@ -52,6 +52,8 @@ $ScriptLock $0; +:local ScriptFromTerminalCached [ $ScriptFromTerminal $0 ]; + :if ([ /system/resource/get uptime ] < 5m) do={ $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 || \ - [ $ScriptFromTerminal $0 ] = true) do={ + $ScriptFromTerminalCached = true) do={ $LogPrintExit2 [ $IfThenElse ($HostInfo->"no-down-notification" != true) info debug ] $0 \ ("The " . $Type . " '" . $Name . "' (" . $HostDetails . ") is down for " . \ $Metric->"count-down" . " checks, " . [ $IfThenElse ($ParentNotified = false) [ $IfThenElse \ -- cgit v1.2.3-70-g09d2