aboutsummaryrefslogtreecommitdiffstats
path: root/early-errors
diff options
context:
space:
mode:
Diffstat (limited to 'early-errors')
-rw-r--r--early-errors22
1 files changed, 22 insertions, 0 deletions
diff --git a/early-errors b/early-errors
new file mode 100644
index 0000000..ad871f6
--- /dev/null
+++ b/early-errors
@@ -0,0 +1,22 @@
+#!rsc
+# RouterOS script: early-errors
+# Copyright (c) 2020 Christian Hesse <mail@eworm.de>
+#
+# send notification with early errors
+# https://git.eworm.de/cgit/routeros-scripts/about/doc/early-errors.md
+
+:global Identity;
+
+:global SendNotification;
+
+:local ErrCount [ / log print count-only where topics~"error" ];
+:if ($ErrCount > 0) do={
+ :local Message ("The log on " . $Identity . " contains " . $ErrCount . \
+ " errors after " . [ / system resource get uptime ] . " uptime.\n");
+ :foreach Log in=[ / log find where topics~"error" ] do={
+ :local LogVal [ / log get $Log ];
+ :set Message ($Message . "\n" . [ :tostr ($LogVal->"topics") ] . \
+ " " . ($LogVal->"message"));
+ }
+ $SendNotification ("\E2\9A\A0 Early errors") ($Message);
+}