mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2024-05-11 05:55:19 +00:00
netwatch-notify: use $ValidateSyntax
This commit is contained in:
@ -17,6 +17,7 @@
|
|||||||
:global ParseKeyValueStore;
|
:global ParseKeyValueStore;
|
||||||
:global SendNotification;
|
:global SendNotification;
|
||||||
:global SymbolForNotification;
|
:global SymbolForNotification;
|
||||||
|
:global ValidateSyntax;
|
||||||
|
|
||||||
:if ([ :typeof $NetwatchNotify ] = "nothing") do={
|
:if ([ :typeof $NetwatchNotify ] = "nothing") do={
|
||||||
:set NetwatchNotify [ :toarray "" ];
|
:set NetwatchNotify [ :toarray "" ];
|
||||||
@ -41,8 +42,12 @@
|
|||||||
("Host " . $HostName . " (" . $HostVal->"host" . ") is up since " . $HostVal->"since" . ".\n" . \
|
("Host " . $HostName . " (" . $HostVal->"host" . ") is up since " . $HostVal->"since" . ".\n" . \
|
||||||
"It was down for " . $Count . " checks since " . ($Metric->"since") . ".");
|
"It was down for " . $Count . " checks since " . ($Metric->"since") . ".");
|
||||||
:if ([ :typeof ($HostInfo->"up-hook") ] = "str") do={
|
:if ([ :typeof ($HostInfo->"up-hook") ] = "str") do={
|
||||||
$LogPrintExit2 info $0 ("Running hook on host " . $HostName . " up: " . ($HostInfo->"up-hook")) false;
|
:if ([ $ValidateSyntax ($HostInfo->"up-hook") ] = true) do={
|
||||||
[ :parse ($HostInfo->"up-hook") ];
|
$LogPrintExit2 info $0 ("Running hook on host " . $HostName . " up: " . ($HostInfo->"up-hook")) false;
|
||||||
|
[ :parse ($HostInfo->"up-hook") ];
|
||||||
|
} else={
|
||||||
|
$LogPrintExit2 warning $0 ("The up-hook for host " . $HostName . " failed syntax validation.") false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
:set ($Metric->"notified") false;
|
:set ($Metric->"notified") false;
|
||||||
@ -75,8 +80,12 @@
|
|||||||
("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={
|
:if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={
|
||||||
$LogPrintExit2 info $0 ("Running hook on host " . $HostName . " down: " . ($HostInfo->"down-hook")) false;
|
:if ([ $ValidateSyntax ($HostInfo->"down-hook") ] = true) do={
|
||||||
[ :parse ($HostInfo->"down-hook") ];
|
$LogPrintExit2 info $0 ("Running hook on host " . $HostName . " down: " . ($HostInfo->"down-hook")) false;
|
||||||
|
[ :parse ($HostInfo->"down-hook") ];
|
||||||
|
} else={
|
||||||
|
$LogPrintExit2 warning $0 ("The down-hook for host " . $HostName . " failed syntax validation.") false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user