aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--netwatch-notify16
1 files changed, 13 insertions, 3 deletions
diff --git a/netwatch-notify b/netwatch-notify
index 4c3586c..1cfd4a6 100644
--- a/netwatch-notify
+++ b/netwatch-notify
@@ -42,19 +42,28 @@
}
}
:set ($Metric->"notified") false;
+ :set ($Metric->"parent") ($HostInfo->"parent");
:set ($Metric->"since");
} else={
:set ($Metric->"count") ($Metric->"count" + 1);
+ :set ($Metric->"parent") ($HostInfo->"parent");
:set ($Metric->"since") ($HostVal->"since");
:local Count [ $IfThenElse ([ :tonum ($HostInfo->"count") ] > 0) ($HostInfo->"count") 5 ];
- :local ParentNotified [ $IfThenElse (($NetwatchNotify->($HostInfo->"parent")->"notified") = true) true false ];
- :if ([ :len ($HostInfo->"parent") ] > 0) do={
+ :local Parent ($HostInfo->"parent");
+ :if ([ :len $Parent ] > 0) do={
:set Count ($Count + 1);
}
+ :local ParentNotified false;
+ :while ($ParentNotified = false && [ :len $Parent ] > 0) do={
+ :set ParentNotified [ $IfThenElse (($NetwatchNotify->$Parent->"notified") = true) true false ];
+ :if ($ParentNotified = false) do={
+ :set Parent ($NetwatchNotify->$Parent->"parent");
+ }
+ }
$LogPrintExit info ("Host " . $HostName . " (" . $HostVal->"host" . ") is down for " . \
$Metric->"count" . " checks, " . [ $IfThenElse ($ParentNotified = false) [ $IfThenElse \
($Metric->"notified" = true) ("already notified.") ($Count - $Metric->"count" . " to go.") ] \
- ("parent host " . $HostInfo->"parent" . " is down.") ]) false;
+ ("parent host " . $Parent . " is down.") ]) false;
:if ($ParentNotified = false && $Metric->"count" >= $Count && $Metric->"notified" != true) do={
$SendNotification ([ $SymbolForNotification "cross-mark" ] . "Netwatch Notify: " . $HostName . " down") \
("Host " . $HostName . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . ".");
@@ -68,5 +77,6 @@
:set ($NetwatchNotify->$HostName) {
"count"=($Metric->"count");
"notified"=($Metric->"notified");
+ "parent"=($Metric->"parent");
"since"=($Metric->"since") };
}