aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2022-09-07 22:02:46 +0200
committerGravatar Christian Hesse <mail@eworm.de>2022-09-07 22:02:46 +0200
commita6645b3e75d55ad0028f349a8c4de5618e77beb7 (patch)
tree413b738f65d189d217aa31690c84aaf57aed0eea
parent6f772e92a616acb15bdef8ab7b7bfdb9d002bfeb (diff)
netwatch-notify: add new array element to count up-checks
-rw-r--r--netwatch-notify5
1 files changed, 4 insertions, 1 deletions
diff --git a/netwatch-notify b/netwatch-notify
index 0451823..dbf6e10 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; "notified"=false };
+ :local Metric { "count-down"=0; "count-up"=0; "notified"=false };
:if ([ :typeof ($NetwatchNotify->$Name) ] = "array") do={
:set $Metric ($NetwatchNotify->$Name);
}
@@ -104,6 +104,7 @@ $ScriptLock $0;
("The " . $Type . " '" . $Name . "' (" . $HostDetails . ") is up.") false;
:set ($Metric->"count-down") 0;
}
+ :set ($Metric->"count-up") ($Metric->"count-up" + 1);
:if ($Metric->"notified" = true) do={
:local Message ("The " . $Type . " '" . $Name . "' (" . $HostDetails . \
") is up since " . $HostVal->"since" . ".\n" . \
@@ -122,6 +123,7 @@ $ScriptLock $0;
:set ($Metric->"since");
} else={
:set ($Metric->"count-down") ($Metric->"count-down" + 1);
+ :set ($Metric->"count-up") 0;
:set ($Metric->"parent") ($HostInfo->"parent");
:set ($Metric->"since") ($HostVal->"since");
:local CountDown [ $IfThenElse ([ :tonum ($HostInfo->"count-down") ] > 0) ($HostInfo->"count-down") 5 ];
@@ -167,6 +169,7 @@ $ScriptLock $0;
}
:set ($NetwatchNotify->$Name) {
"count-down"=($Metric->"count-down");
+ "count-up"=($Metric->"count-up");
"notified"=($Metric->"notified");
"parent"=($Metric->"parent");
"resolve-failed"=($Metric->"resolve-failed");