aboutsummaryrefslogtreecommitdiffstats
path: root/early-errors
blob: 36cc23e04eff6f5498a18448c4b5618441676502 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!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 Errors [ / log find where (topics~"error" or topics~"critical") !(topics~"e-mail") ];
:local ErrCount [ :len $Errors ];
:if ($ErrCount > 0) do={
  :local Message ("The log on " . $Identity . " contains " . $ErrCount . \
    " errors after " . [ / system resource get uptime ] . " uptime.\n");
  :foreach Log in=$Errors do={
    :local LogVal [ / log get $Log ];
    :set Message ($Message . "\n" . [ :tostr ($LogVal->"topics") ] . \
      " " . ($LogVal->"message"));
  }
  $SendNotification ("\E2\9A\A0 Early errors") ($Message);
}