mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
netwatch-notify: make check count threshold configurable
Signed-off-by: Christian Hesse <mail@eworm.de>
This commit is contained in:
parent
d65874e142
commit
e58d8e4373
|
@ -35,6 +35,10 @@ comment:
|
|||
|
||||
/ tool netwatch add comment="notify, hostname=poe-device, down-hook=/ interface ethernet poe power-cycle en21;" host=10.0.0.20 timeout=5s;
|
||||
|
||||
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 timeout=5s;
|
||||
|
||||
Also notification settings are required for e-mail and telegram.
|
||||
|
||||
---
|
||||
|
|
|
@ -8,8 +8,9 @@
|
|||
|
||||
:global NetwatchNotify;
|
||||
|
||||
:global ParseKeyValueStore;
|
||||
:global IfThenElse;
|
||||
:global LogPrintExit;
|
||||
:global ParseKeyValueStore;
|
||||
:global SendNotification;
|
||||
:global SymbolForNotification;
|
||||
|
||||
|
@ -45,7 +46,8 @@
|
|||
:set ($Metric->"count") ($Metric->"count" + 1);
|
||||
$LogPrintExit info ("Host " . $HostName . " (" . $HostVal->"host" . ") is down for " . \
|
||||
$Metric->"count" . " checks.") false;
|
||||
:if ($Metric->"count" >= 5 && $Metric->"notified" != true) do={
|
||||
:if ($Metric->"count" >= [ $IfThenElse ([ :typeof ($HostVal->"count") ] != "nothing") ($HostVal->"count") 5 ] && \
|
||||
$Metric->"notified" != true) do={
|
||||
$SendNotification ([ $SymbolForNotification "cross-mark" ] . "Netwatch Notify: " . $HostName . " down") \
|
||||
("Host " . $HostName . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . ".");
|
||||
:set ($Metric->"notified") true;
|
||||
|
|
Loading…
Reference in a new issue