mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-26 05:44:39 +02:00
netwatch-notify: do not (yet) notify if parent is up recently
Monitoring a VPN (or similar) may be tricky: This used to send notifications if the physical connection recovered, but the VPN and/or its routing did not yet. Let's work around and send notification only if the parent is up for at least three checks.
This commit is contained in:
parent
a6645b3e75
commit
5aff4019fe
1 changed files with 3 additions and 1 deletions
|
@ -128,6 +128,7 @@ $ScriptLock $0;
|
||||||
:set ($Metric->"since") ($HostVal->"since");
|
:set ($Metric->"since") ($HostVal->"since");
|
||||||
:local CountDown [ $IfThenElse ([ :tonum ($HostInfo->"count-down") ] > 0) ($HostInfo->"count-down") 5 ];
|
:local CountDown [ $IfThenElse ([ :tonum ($HostInfo->"count-down") ] > 0) ($HostInfo->"count-down") 5 ];
|
||||||
:local Parent ($HostInfo->"parent");
|
:local Parent ($HostInfo->"parent");
|
||||||
|
:local ParentUp false;
|
||||||
:while ([ :len $Parent ] > 0) do={
|
:while ([ :len $Parent ] > 0) do={
|
||||||
:set CountDown ($CountDown + 1);
|
:set CountDown ($CountDown + 1);
|
||||||
:set Parent ($NetwatchNotify->$Parent->"parent");
|
:set Parent ($NetwatchNotify->$Parent->"parent");
|
||||||
|
@ -137,6 +138,7 @@ $ScriptLock $0;
|
||||||
:while ($ParentNotified = false && [ :len $Parent ] > 0) do={
|
:while ($ParentNotified = false && [ :len $Parent ] > 0) do={
|
||||||
:set ParentNotified [ $IfThenElse (($NetwatchNotify->$Parent->"notified") = true) \
|
:set ParentNotified [ $IfThenElse (($NetwatchNotify->$Parent->"notified") = true) \
|
||||||
true false ];
|
true false ];
|
||||||
|
:set ParentUp ($NetwatchNotify->$Parent->"count-up");
|
||||||
:if ($ParentNotified = false) do={
|
:if ($ParentNotified = false) do={
|
||||||
:set Parent ($NetwatchNotify->$Parent->"parent");
|
:set Parent ($NetwatchNotify->$Parent->"parent");
|
||||||
}
|
}
|
||||||
|
@ -151,7 +153,7 @@ $ScriptLock $0;
|
||||||
$NetwatchNotifyHook $Name $Type "pre-down" ($HostInfo->"pre-down-hook");
|
$NetwatchNotifyHook $Name $Type "pre-down" ($HostInfo->"pre-down-hook");
|
||||||
}
|
}
|
||||||
:if ($ParentNotified = false && $Metric->"count-down" >= $CountDown && \
|
:if ($ParentNotified = false && $Metric->"count-down" >= $CountDown && \
|
||||||
$Metric->"notified" != true) do={
|
($ParentUp = false || $ParentUp > 2) && $Metric->"notified" != true) do={
|
||||||
:local Message ("The " . $Type . " '" . $Name . "' (" . $HostDetails . \
|
:local Message ("The " . $Type . " '" . $Name . "' (" . $HostDetails . \
|
||||||
") is down since " . $HostVal->"since" . ".");
|
") is down since " . $HostVal->"since" . ".");
|
||||||
:if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={
|
:if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue