aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2020-08-24 14:18:32 +0200
committerGravatar Christian Hesse <mail@eworm.de>2020-08-24 14:26:55 +0200
commit92ca31a41df332171d1f2dcf08c75db570b12234 (patch)
tree51ca8a98c080c6fa0e87a38f23863ef93651171c
parente58d8e43739744d88f04918ff0e74fabf0bcc37c (diff)
netwatch-notify: be more verbose on host downtime
Signed-off-by: Christian Hesse <mail@eworm.de>
-rw-r--r--netwatch-notify9
1 files 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") };
}