aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2021-02-26 16:05:34 +0100
committerGravatar Christian Hesse <mail@eworm.de>2021-02-26 16:23:13 +0100
commit99d3e5d578bb73be020c718a5816f221b58a5f14 (patch)
treeb535b13462a978529346fab800b62c6877ed3cd0
parentcf87be70f9836bfcf93ef33f4f2cb3eb5f431697 (diff)
netwatch-notify: use $ValidateSyntax
-rw-r--r--netwatch-notify17
1 files changed, 13 insertions, 4 deletions
diff --git a/netwatch-notify b/netwatch-notify
index 6bd8953..ef67804 100644
--- a/netwatch-notify
+++ b/netwatch-notify
@@ -17,6 +17,7 @@
:global ParseKeyValueStore;
:global SendNotification;
:global SymbolForNotification;
+:global ValidateSyntax;
:if ([ :typeof $NetwatchNotify ] = "nothing") do={
:set NetwatchNotify [ :toarray "" ];
@@ -41,8 +42,12 @@
("Host " . $HostName . " (" . $HostVal->"host" . ") is up since " . $HostVal->"since" . ".\n" . \
"It was down for " . $Count . " checks since " . ($Metric->"since") . ".");
:if ([ :typeof ($HostInfo->"up-hook") ] = "str") do={
- $LogPrintExit2 info $0 ("Running hook on host " . $HostName . " up: " . ($HostInfo->"up-hook")) false;
- [ :parse ($HostInfo->"up-hook") ];
+ :if ([ $ValidateSyntax ($HostInfo->"up-hook") ] = true) do={
+ $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;
@@ -75,8 +80,12 @@
("Host " . $HostName . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . ".");
:set ($Metric->"notified") true;
:if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={
- $LogPrintExit2 info $0 ("Running hook on host " . $HostName . " down: " . ($HostInfo->"down-hook")) false;
- [ :parse ($HostInfo->"down-hook") ];
+ :if ([ $ValidateSyntax ($HostInfo->"down-hook") ] = true) do={
+ $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;
+ }
}
}
}