Community discussions

MikroTik App
 
Gronaldo
just joined
Topic Author
Posts: 3
Joined: Thu Feb 10, 2022 9:23 pm

Email last 24hrs logs

Thu Feb 10, 2022 10:01 pm

Dear experts,

I'm looking for a 'novice proof' solution to send the logs from last 24hrs by email.

Found a solution to send full log, using Scheduler:
/log print  file=logs
delay 10
/tool e-mail send to="user@name.--" subject="$[/system identity get name]  logs" \
body="$[/system clock get date] log file" file=logs
delay 10
/file remove logs
However would like to limit log to only last 24hrs. How to achieve this?
 
Gronaldo
just joined
Topic Author
Posts: 3
Joined: Thu Feb 10, 2022 9:23 pm

Re: Email last 24hrs logs

Fri Mar 18, 2022 9:35 pm

Nobody any idea's?
 
Sob
Forum Guru
Forum Guru
Posts: 9119
Joined: Mon Apr 20, 2009 9:11 pm

Re: Email last 24hrs logs

Fri Mar 18, 2022 9:58 pm

It's possible to do some filtering, e.g. this at first sight works as expected:
/log print where topics~"account"
Another field offered by tab-completition is "time", so I guess it's possible to use that. But how exactly, I can't tell. Having encountered RouterOS scripting before, I expect it to be something unintuitive and cumbersome.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Email last 24hrs logs  [SOLVED]

Sat Mar 19, 2022 1:33 am

after send the log, empty the logs....

without see your actual log configuration, this probably simply do what you want...

change first line of the script with...
/log print file=logs where buffer=memory
/system logging action
set [find where target=memory] memory-lines=1
:delay 1s
set [find where target=memory] memory-lines=1000

<<<insert the remaining script here>>>
schedule it at 23:59 and you have the last day logs only
 
brg3466
Member Candidate
Member Candidate
Posts: 177
Joined: Sat Aug 01, 2015 7:29 am

Re: Email last 24hrs logs

Mon Mar 21, 2022 5:20 am

The below script used to work in v6:
/log print where time>( [system clock get time] - 1h )
So you can schedule to run the script at the end of the day like below just don't get negative in the subtraction.
/log print where time>( [system clock get time] - 23h50m )

But it doesn't work in v7 anymore.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Email last 24hrs logs

Mon Mar 21, 2022 7:58 am

You can send all logs using syslog. See link in my signature for how to use Splunk to analyze them and graph them.
 
Gronaldo
just joined
Topic Author
Posts: 3
Joined: Thu Feb 10, 2022 9:23 pm

Re: Email last 24hrs logs

Fri Mar 25, 2022 9:23 pm

after send the log, empty the logs....

without see your actual log configuration, this probably simply do what you want...

change first line of the script with...
/log print file=logs where buffer=memory
/system logging action
set [find where target=memory] memory-lines=1
:delay 1s
set [find where target=memory] memory-lines=1000

<<<insert the remaining script here>>>
schedule it at 23:59 and you have the last day logs only

Seems to be the easiest solution, indeed. Although erasing the full log is not he most ideal scenario.

Surprised MT makes it so difficult, by using the current time/date notation.

Anyway, thanks all!

Who is online

Users browsing this forum: bertus and 32 guests