From 92ca31a41df332171d1f2dcf08c75db570b12234 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 24 Aug 2020 14:18:32 +0200 Subject: netwatch-notify: be more verbose on host downtime Signed-off-by: Christian Hesse --- netwatch-notify | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/netwatch-notify b/netwatch-notify index b52c4d1..e47f715 100644 --- a/netwatch-notify +++ b/netwatch-notify @@ -35,15 +35,17 @@ :if ($Metric->"notified" = true) do={ $SendNotification ([ $SymbolForNotification "white-heavy-check-mark" ] . "Netwatch Notify: " . $HostName . " up") \ ("Host " . $HostName . " (" . $HostVal->"host" . ") is up since " . $HostVal->"since" . ".\n" . \ - "It was down for " . $Count . " checks."); + "It was down for " . $Count . " checks since " . ($Metric->"since") . "."); :if ([ :typeof ($HostInfo->"up-hook") ] = "str") do={ $LogPrintExit info ("Running hook on host " . $HostName . " up: " . ($HostInfo->"up-hook")) false; [ :parse ($HostInfo->"up-hook") ]; } } :set ($Metric->"notified") false; + :set ($Metric->"since"); } 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; :if ($Metric->"count" >= [ $IfThenElse ([ :typeof ($HostVal->"count") ] != "nothing") ($HostVal->"count") 5 ] && \ @@ -57,5 +59,8 @@ } } } - :set ($NetwatchNotify->$HostName) { "count"=($Metric->"count"); "notified"=($Metric->"notified") }; + :set ($NetwatchNotify->$HostName) { + "count"=($Metric->"count"); + "notified"=($Metric->"notified"); + "since"=($Metric->"since") }; } -- cgit v1.2.3-54-g00ecf