diff options
author | Christian Hesse <mail@eworm.de> | 2020-07-03 15:19:46 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2020-07-03 15:27:21 +0200 |
commit | 1c10044b2430c4bd8ec5955ead84fbe282587bef (patch) | |
tree | 1d8aa29a5e5ebb32680b1e7a447ba92c3c9f94fc | |
parent | 49d5f52f0b1c0a18489bd0fa64894ed2c54532a2 (diff) |
netwatch-notify: add support for down hook
Adding up-hook does not make sense... Just use netwatch's up-script for that.
-rw-r--r-- | netwatch-notify | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/netwatch-notify b/netwatch-notify index 854d5fa..350c088 100644 --- a/netwatch-notify +++ b/netwatch-notify @@ -18,7 +18,8 @@ :foreach Host in=[ / tool netwatch find where comment~"^notify," ] do={ :local HostVal [ / tool netwatch get $Host ]; - :local HostName ([ $ParseKeyValueStore ($HostVal->"comment") ]->"hostname"); + :local HostInfo [ $ParseKeyValueStore ($HostVal->"comment") ]; + :local HostName ($HostInfo->"hostname"); :local Metric { "count"=0; "notified"=false }; :if ([ :typeof ($NetwatchNotify->$HostName) ] = "array") do={ @@ -43,6 +44,10 @@ $SendNotification ("Netwatch Notify: \E2\9D\8C " . $HostName . " down") \ ("Host " . $HostName . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . "."); :set ($Metric->"notified") true; + :if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={ + $LogPrintExit info ("Running hook on host " . $HostName . " down: " . ($HostInfo->"down-hook")) false; + [ :parse ($HostInfo->"down-hook") ]; + } } } :set ($NetwatchNotify->$HostName) { "count"=($Metric->"count"); "notified"=($Metric->"notified") }; |