aboutsummaryrefslogtreecommitdiffstats
path: root/netwatch-notify
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2021-02-22 15:14:10 +0100
committerGravatar Christian Hesse <mail@eworm.de>2021-02-24 21:51:54 +0100
commitf46db918453dcb8878b9a0de6e122fb0ea2224d9 (patch)
tree31544a450651d0705ecdea0c3d35e650ef784d67 /netwatch-notify
parentb0e52aa2d1baa78fc9d025c0671fea8babba0ec2 (diff)
global: give script or function name in log messages
Diffstat (limited to 'netwatch-notify')
-rw-r--r--netwatch-notify11
1 files changed, 6 insertions, 5 deletions
diff --git a/netwatch-notify b/netwatch-notify
index d050b75..6bd8953 100644
--- a/netwatch-notify
+++ b/netwatch-notify
@@ -6,13 +6,14 @@
# monitor netwatch and send notifications
# https://git.eworm.de/cgit/routeros-scripts/about/doc/netwatch-notify.md
+:local 0 "netwatch-notify";
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global NetwatchNotify;
:global IfThenElse;
-:global LogPrintExit;
+:global LogPrintExit2;
:global ParseKeyValueStore;
:global SendNotification;
:global SymbolForNotification;
@@ -32,7 +33,7 @@
}
:if ($HostVal->"status" = "up") do={
- $LogPrintExit debug ("Host " . $HostName . " (" . $HostVal->"host" . ") is up.") false;
+ $LogPrintExit2 debug $0 ("Host " . $HostName . " (" . $HostVal->"host" . ") is up.") false;
:local Count ($Metric->"count");
:set ($Metric->"count") 0;
:if ($Metric->"notified" = true) do={
@@ -40,7 +41,7 @@
("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={
- $LogPrintExit info ("Running hook on host " . $HostName . " up: " . ($HostInfo->"up-hook")) false;
+ $LogPrintExit2 info $0 ("Running hook on host " . $HostName . " up: " . ($HostInfo->"up-hook")) false;
[ :parse ($HostInfo->"up-hook") ];
}
}
@@ -65,7 +66,7 @@
:set Parent ($NetwatchNotify->$Parent->"parent");
}
}
- $LogPrintExit info ("Host " . $HostName . " (" . $HostVal->"host" . ") is down for " . \
+ $LogPrintExit2 info $0 ("Host " . $HostName . " (" . $HostVal->"host" . ") is down for " . \
$Metric->"count" . " checks, " . [ $IfThenElse ($ParentNotified = false) [ $IfThenElse \
($Metric->"notified" = true) ("already notified.") ($Count - $Metric->"count" . " to go.") ] \
("parent host " . $Parent . " is down.") ]) false;
@@ -74,7 +75,7 @@
("Host " . $HostName . " (" . $HostVal->"host" . ") is down since " . $HostVal->"since" . ".");
:set ($Metric->"notified") true;
:if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={
- $LogPrintExit info ("Running hook on host " . $HostName . " down: " . ($HostInfo->"down-hook")) false;
+ $LogPrintExit2 info $0 ("Running hook on host " . $HostName . " down: " . ($HostInfo->"down-hook")) false;
[ :parse ($HostInfo->"down-hook") ];
}
}