mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
netwatch-notify: implement pre-down hook
This commit is contained in:
parent
12d34e4a7c
commit
bccb7c3452
|
@ -44,6 +44,10 @@ comment:
|
||||||
|
|
||||||
/ tool netwatch add comment="notify, hostname=poe-device, down-hook=/ interface ethernet poe power-cycle en21;" host=10.0.0.20;
|
/ tool netwatch add comment="notify, hostname=poe-device, down-hook=/ interface ethernet poe power-cycle en21;" host=10.0.0.20;
|
||||||
|
|
||||||
|
Also there is a `pre-down-hook` that fires at two thirds of failed checks
|
||||||
|
required for the notification. The idea is to fix the issue before a
|
||||||
|
notification is sent.
|
||||||
|
|
||||||
The count threshould (default is 5 checks) is configurable as well:
|
The count threshould (default is 5 checks) is configurable as well:
|
||||||
|
|
||||||
/ tool netwatch add comment="notify, hostname=example.com, count=10" host=104.18.144.11;
|
/ tool netwatch add comment="notify, hostname=example.com, count=10" host=104.18.144.11;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
# Make sure all configuration properties are up to date and this
|
# Make sure all configuration properties are up to date and this
|
||||||
# value is in sync with value in script 'global-functions'!
|
# value is in sync with value in script 'global-functions'!
|
||||||
:global GlobalConfigVersion 59;
|
:global GlobalConfigVersion 60;
|
||||||
|
|
||||||
# This is used for DNS and backup file.
|
# This is used for DNS and backup file.
|
||||||
:global Domain "example.com";
|
:global Domain "example.com";
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
# Make sure all configuration properties are up to date and this
|
# Make sure all configuration properties are up to date and this
|
||||||
# value is in sync with value in script 'global-functions'!
|
# value is in sync with value in script 'global-functions'!
|
||||||
# Comment or remove to disable news and change notifications.
|
# Comment or remove to disable news and change notifications.
|
||||||
:global GlobalConfigVersion 59;
|
:global GlobalConfigVersion 60;
|
||||||
|
|
||||||
# Copy configuration from global-config here and modify it.
|
# Copy configuration from global-config here and modify it.
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
57="Celebrating the 1.000th commit - Hooray!";
|
57="Celebrating the 1.000th commit - Hooray!";
|
||||||
58="Added a cleanup script for 'hotspot-to-wpa' to purge old access list entries.";
|
58="Added a cleanup script for 'hotspot-to-wpa' to purge old access list entries.";
|
||||||
59="Updating CAP with 'check-routeros-update' is now possible with opt-in.";
|
59="Updating CAP with 'check-routeros-update' is now possible with opt-in.";
|
||||||
|
60="Implemented a pre-down hook in 'netwatch-notify' that fires at two thirds of failed checks.";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Migration steps to be applied on script updates
|
# Migration steps to be applied on script updates
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
# https://git.eworm.de/cgit/routeros-scripts/about/
|
# https://git.eworm.de/cgit/routeros-scripts/about/
|
||||||
|
|
||||||
# expected configuration version
|
# expected configuration version
|
||||||
:global ExpectedConfigVersion 59;
|
:global ExpectedConfigVersion 60;
|
||||||
|
|
||||||
# global variables not to be changed by user
|
# global variables not to be changed by user
|
||||||
:global GlobalFunctionsReady false;
|
:global GlobalFunctionsReady false;
|
||||||
|
|
|
@ -117,6 +117,9 @@
|
||||||
$Metric->"count" . " checks, " . [ $IfThenElse ($ParentNotified = false) [ $IfThenElse \
|
$Metric->"count" . " checks, " . [ $IfThenElse ($ParentNotified = false) [ $IfThenElse \
|
||||||
($Metric->"notified" = true) ("already notified.") ($Count - $Metric->"count" . " to go.") ] \
|
($Metric->"notified" = true) ("already notified.") ($Count - $Metric->"count" . " to go.") ] \
|
||||||
("parent host " . $Parent . " is down.") ]) false;
|
("parent host " . $Parent . " is down.") ]) false;
|
||||||
|
:if ((($Count * 2) - ($Metric->"count" * 3)) / 2 = 0 && [ :typeof ($HostInfo->"pre-down-hook") ] = "str") do={
|
||||||
|
$NetwatchNotifyHook $HostName "pre-down" ($HostInfo->"pre-down-hook");
|
||||||
|
}
|
||||||
:if ($ParentNotified = false && $Metric->"count" >= $Count && $Metric->"notified" != true) do={
|
:if ($ParentNotified = false && $Metric->"count" >= $Count && $Metric->"notified" != true) do={
|
||||||
:local Message ("Host " . $HostName . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . ".");
|
:local Message ("Host " . $HostName . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . ".");
|
||||||
:if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={
|
:if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={
|
||||||
|
|
Loading…
Reference in a new issue