From 6c14412aa936d24a7a6c124b390bbd95fdc66cd7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 17 Nov 2020 15:03:01 +0100 Subject: netwatch-notify: implemented simple dependency model --- netwatch-notify | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'netwatch-notify') diff --git a/netwatch-notify b/netwatch-notify index 6c2a18c..2462e9b 100644 --- a/netwatch-notify +++ b/netwatch-notify @@ -48,8 +48,12 @@ :set ($Metric->"since") ($HostVal->"since"); $LogPrintExit info ("Host " . $HostName . " (" . $HostVal->"host" . ") is down for " . \ $Metric->"count" . " checks.") false; - :if ($Metric->"count" >= [ $IfThenElse ([ :typeof ($HostInfo->"count") ] != "nothing") ($HostInfo->"count") 5 ] && \ - $Metric->"notified" != true) do={ + :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={ + :set Count ($Count + 1); + } + :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" . "."); :set ($Metric->"notified") true; -- cgit v1.2.3-54-g00ecf