mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
netwatch-notify: add support for down hook
Adding up-hook does not make sense... Just use netwatch's up-script for that.
This commit is contained in:
parent
49d5f52f0b
commit
1c10044b24
1 changed files with 6 additions and 1 deletions
|
@ -18,7 +18,8 @@
|
||||||
|
|
||||||
:foreach Host in=[ / tool netwatch find where comment~"^notify," ] do={
|
:foreach Host in=[ / tool netwatch find where comment~"^notify," ] do={
|
||||||
:local HostVal [ / tool netwatch get $Host ];
|
: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 };
|
:local Metric { "count"=0; "notified"=false };
|
||||||
:if ([ :typeof ($NetwatchNotify->$HostName) ] = "array") do={
|
:if ([ :typeof ($NetwatchNotify->$HostName) ] = "array") do={
|
||||||
|
@ -43,6 +44,10 @@
|
||||||
$SendNotification ("Netwatch Notify: \E2\9D\8C " . $HostName . " down") \
|
$SendNotification ("Netwatch Notify: \E2\9D\8C " . $HostName . " down") \
|
||||||
("Host " . $HostName . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . ".");
|
("Host " . $HostName . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . ".");
|
||||||
:set ($Metric->"notified") true;
|
: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") };
|
:set ($NetwatchNotify->$HostName) { "count"=($Metric->"count"); "notified"=($Metric->"notified") };
|
||||||
|
|
Loading…
Reference in a new issue