From d5125b816aeef0f86e48bdf5dbd1dccfe0164c9f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 17 Nov 2020 15:14:27 +0100 Subject: netwatch-notify: be more verbose in logs --- netwatch-notify | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/netwatch-notify b/netwatch-notify index 2462e9b..4c3586c 100644 --- a/netwatch-notify +++ b/netwatch-notify @@ -46,13 +46,15 @@ } else={ :set ($Metric->"count") ($Metric->"count" + 1); :set ($Metric->"since") ($HostVal->"since"); - $LogPrintExit info ("Host " . $HostName . " (" . $HostVal->"host" . ") is down for " . \ - $Metric->"count" . " checks.") false; :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); } + $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; :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" . "."); -- cgit v1.2.3-54-g00ecf