From f3e2fb654b171446ce17e7ab01c7929d85f13839 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 5 Mar 2020 12:47:42 +0100 Subject: netwatch-notify: add logging --- netwatch-notify | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/netwatch-notify b/netwatch-notify index dfa62e8..d2d256b 100644 --- a/netwatch-notify +++ b/netwatch-notify @@ -7,6 +7,7 @@ :global NetwatchNotify; :global ParseKeyValueStore; +:global LogPrintExit; :global SendNotification; :if ([ :typeof $NetwatchNotify ] = "nothing") do={ @@ -23,6 +24,7 @@ } :if ($HostVal->"status" = "up") do={ + $LogPrintExit debug ("Host " . $HostName . " (" . $HostVal->"host" . ") is up.") false; :set ($Metric->"count") 0; :if ($Metric->"notified" = true) do={ $SendNotification ("Netwatch Notify: " . $HostName . " up") \ @@ -31,6 +33,8 @@ :set ($Metric->"notified") false; } else={ :set ($Metric->"count") ($Metric->"count" + 1); + $LogPrintExit info ("Host " . $HostName . " (" . $HostVal->"host" . ") is down for " . \ + $Metric->"count" . " checks.") false; :if ($Metric->"count" >= 5 && $Metric->"notified" != true) do={ $SendNotification ("Netwatch Notify: " . $HostName . " down") \ ("Host " . $HostName . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . "."); -- cgit v1.2.3-54-g00ecf