routeros-scripts/early-errors

28 lines
917 B
Text
Raw Normal View History

2020-04-18 21:20:29 +00:00
#!rsc
# RouterOS script: early-errors
# Copyright (c) 2020 Christian Hesse <mail@eworm.de>
# 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;
:global WaitFullyConnected;
$WaitFullyConnected;
2020-04-18 21:20:29 +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);
}