2020-04-18 21:20:29 +00:00
|
|
|
#!rsc
|
|
|
|
# RouterOS script: early-errors
|
|
|
|
# Copyright (c) 2020 Christian Hesse <mail@eworm.de>
|
2020-06-19 20:17:42 +00:00
|
|
|
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
|
2020-04-18 21:20:29 +00:00
|
|
|
#
|
|
|
|
# send notification with early errors
|
|
|
|
# https://git.eworm.de/cgit/routeros-scripts/about/doc/early-errors.md
|
|
|
|
|
|
|
|
:global Identity;
|
|
|
|
|
|
|
|
:global SendNotification;
|
2020-05-26 22:13:57 +00:00
|
|
|
:global WaitFullyConnected;
|
|
|
|
|
|
|
|
$WaitFullyConnected;
|
2020-04-18 21:20:29 +00:00
|
|
|
|
2020-04-24 21:31:21 +00:00
|
|
|
:local Errors [ / log find where (topics~"error" or topics~"critical") !(topics~"e-mail") !(topics~"dns") ];
|
2020-04-24 21:14:58 +00:00
|
|
|
:local ErrCount [ :len $Errors ];
|
2020-04-18 21:20:29 +00:00
|
|
|
:if ($ErrCount > 0) do={
|
|
|
|
:local Message ("The log on " . $Identity . " contains " . $ErrCount . \
|
|
|
|
" errors after " . [ / system resource get uptime ] . " uptime.\n");
|
2020-04-24 21:14:58 +00:00
|
|
|
:foreach Log in=$Errors do={
|
2020-04-18 21:20:29 +00:00
|
|
|
:local LogVal [ / log get $Log ];
|
|
|
|
:set Message ($Message . "\n" . [ :tostr ($LogVal->"topics") ] . \
|
|
|
|
" " . ($LogVal->"message"));
|
|
|
|
}
|
|
|
|
$SendNotification ("\E2\9A\A0 Early errors") ($Message);
|
|
|
|
}
|