mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
netwatch-notify: add logging
This commit is contained in:
parent
9aed03693c
commit
f3e2fb654b
1 changed files with 4 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
||||||
:global NetwatchNotify;
|
:global NetwatchNotify;
|
||||||
|
|
||||||
:global ParseKeyValueStore;
|
:global ParseKeyValueStore;
|
||||||
|
:global LogPrintExit;
|
||||||
:global SendNotification;
|
:global SendNotification;
|
||||||
|
|
||||||
:if ([ :typeof $NetwatchNotify ] = "nothing") do={
|
:if ([ :typeof $NetwatchNotify ] = "nothing") do={
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ($HostVal->"status" = "up") do={
|
:if ($HostVal->"status" = "up") do={
|
||||||
|
$LogPrintExit debug ("Host " . $HostName . " (" . $HostVal->"host" . ") is up.") false;
|
||||||
:set ($Metric->"count") 0;
|
:set ($Metric->"count") 0;
|
||||||
:if ($Metric->"notified" = true) do={
|
:if ($Metric->"notified" = true) do={
|
||||||
$SendNotification ("Netwatch Notify: " . $HostName . " up") \
|
$SendNotification ("Netwatch Notify: " . $HostName . " up") \
|
||||||
|
@ -31,6 +33,8 @@
|
||||||
:set ($Metric->"notified") false;
|
:set ($Metric->"notified") false;
|
||||||
} else={
|
} else={
|
||||||
:set ($Metric->"count") ($Metric->"count" + 1);
|
: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" >= 5 && $Metric->"notified" != true) do={
|
||||||
$SendNotification ("Netwatch Notify: " . $HostName . " down") \
|
$SendNotification ("Netwatch Notify: " . $HostName . " down") \
|
||||||
("Host " . $HostName . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . ".");
|
("Host " . $HostName . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . ".");
|
||||||
|
|
Loading…
Reference in a new issue