aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2022-10-21 09:07:50 +0200
committerGravatar Christian Hesse <mail@eworm.de>2022-10-21 15:00:42 +0200
commit6822e715646833efc3a0018ffe0e840dc8371715 (patch)
treea9b4e9707dd9c5e8c9d4ed4a41bb462af7ac4e91
parenta0163aa487df214d3f86428c7f93266a88ed3ab8 (diff)
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>
-rw-r--r--netwatch-notify4
1 files changed, 3 insertions, 1 deletions
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 \