diff options
author | Christian Hesse <mail@eworm.de> | 2021-05-18 16:44:07 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2021-05-18 16:44:07 +0200 |
commit | 05a7ae409ba1cee217b68adacf1d8d27d43414d5 (patch) | |
tree | e1792fd11e7aeafec14ddd78ad8417c75f6d30c0 /netwatch-notify | |
parent | 5037dbbedc868d6ce881b039a7faa4de91f45c12 (diff) |
netwatch-notify: add info on hook in notification
Diffstat (limited to 'netwatch-notify')
-rw-r--r-- | netwatch-notify | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/netwatch-notify b/netwatch-notify index 27afd70..c630678 100644 --- a/netwatch-notify +++ b/netwatch-notify @@ -60,18 +60,20 @@ :set ($Metric->"count") 0; } :if ($Metric->"notified" = true) do={ - $SendNotification2 ({ origin=$0; \ - subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "Netwatch Notify: " . $HostName . " up"); \ - message=("Host " . $HostName . " (" . $HostVal->"host" . ") is up since " . $HostVal->"since" . ".\n" . \ - "It was down for " . $Count . " checks since " . ($Metric->"since") . ".") }); + :local Message ("Host " . $HostName . " (" . $HostVal->"host" . ") is up since " . $HostVal->"since" . ".\n" . \ + "It was down for " . $Count . " checks since " . ($Metric->"since") . "."); :if ([ :typeof ($HostInfo->"up-hook") ] = "str") do={ :if ([ $ValidateSyntax ($HostInfo->"up-hook") ] = true) do={ $LogPrintExit2 info $0 ("Running hook on host " . $HostName . " up: " . ($HostInfo->"up-hook")) false; + :set Message ($Message . "\n\nRunning hook:\n" . $HostInfo->"up-hook"); [ :parse ($HostInfo->"up-hook") ]; } else={ $LogPrintExit2 warning $0 ("The up-hook for host " . $HostName . " failed syntax validation.") false; } } + $SendNotification2 ({ origin=$0; \ + subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "Netwatch Notify: " . $HostName . " up"); \ + message=$Message }); } :set ($Metric->"notified") false; :set ($Metric->"parent") ($HostInfo->"parent"); @@ -99,18 +101,20 @@ ($Metric->"notified" = true) ("already notified.") ($Count - $Metric->"count" . " to go.") ] \ ("parent host " . $Parent . " is down.") ]) false; :if ($ParentNotified = false && $Metric->"count" >= $Count && $Metric->"notified" != true) do={ - $SendNotification2 ({ origin=$0; \ - subject=([ $SymbolForNotification "cross-mark" ] . "Netwatch Notify: " . $HostName . " down"); \ - message=("Host " . $HostName . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . ".") }); - :set ($Metric->"notified") true; + :local Message ("Host " . $HostName . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . "."); :if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={ :if ([ $ValidateSyntax ($HostInfo->"down-hook") ] = true) do={ $LogPrintExit2 info $0 ("Running hook on host " . $HostName . " down: " . ($HostInfo->"down-hook")) false; + :set Message ($Message . "\n\nRunning hook:\n" . $HostInfo->"down-hook"); [ :parse ($HostInfo->"down-hook") ]; } else={ $LogPrintExit2 warning $0 ("The down-hook for host " . $HostName . " failed syntax validation.") false; } } + $SendNotification2 ({ origin=$0; \ + subject=([ $SymbolForNotification "cross-mark" ] . "Netwatch Notify: " . $HostName . " down"); \ + message=$Message }); + :set ($Metric->"notified") true; } } :set ($NetwatchNotify->$HostName) { |