Community discussions

MikroTik App
 
User avatar
mambotech
Member Candidate
Member Candidate
Topic Author
Posts: 112
Joined: Thu Jun 08, 2006 6:20 pm

Scritp for monitoring errors in log

Sun Feb 15, 2009 2:58 pm

Hi,

Can anyone help me. I am trying to workout how to send an email when an error appears in the log file.

Router OS 3.17

Thanks Mark
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: Scritp for monitoring errors in log

Sun Feb 15, 2009 3:10 pm

Hi Mark,

I don't have the exact script, but you might be able to paste one together using this and one of the email scripts from the wiki. This prints the log entries like "/log print", except it only prints entries that have 'critical' in the topics. You can change the search to the message instead if that is where you need to look.
:local loglist [/log find]
:local topics
:local thistopic "critical"

:foreach i in=$loglist do={
    :set topics [/log get $i topics]
    :if ([:len [:find $topics $thistopic]] > 0) do={
:put ([/log get $i time] . " " . [:tostr [/log get $i topics]] . " " . [/log get $i message])
    }
}
 
User avatar
mambotech
Member Candidate
Member Candidate
Topic Author
Posts: 112
Joined: Thu Jun 08, 2006 6:20 pm

Re: Scritp for monitoring errors in log

Sun Feb 15, 2009 3:22 pm

Thanks Tim I will look for an email script.

Mark
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: Scritp for monitoring errors in log

Sun Feb 15, 2009 3:44 pm

Glad I could help. If you need any assistance pasting them together, let me know what you are looking for in the logs, and what you want to send, and maybe I can help you.

Who is online

Users browsing this forum: No registered users and 27 guests