Page 1 of 1
Scritp for monitoring errors in log
Posted: Sun Feb 15, 2009 2:58 pm
by mambotech
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
Re: Scritp for monitoring errors in log
Posted: Sun Feb 15, 2009 3:10 pm
by SurferTim
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])
}
}
Re: Scritp for monitoring errors in log
Posted: Sun Feb 15, 2009 3:22 pm
by mambotech
Thanks Tim I will look for an email script.
Mark
Re: Scritp for monitoring errors in log
Posted: Sun Feb 15, 2009 3:44 pm
by SurferTim
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.