Community discussions

MikroTik App
 
parfait02
just joined
Topic Author
Posts: 17
Joined: Sat Jun 26, 2021 10:39 pm

log files limited to 2 on my RB4011

Fri Jan 26, 2024 2:55 pm

Hello,
I would like to know how to configure my RB4011 to create up to 100 files.
Currently, only 2 files is generated so logs are rotating between log.o.txt and log.1.txt.
That is annoying because I cannot see log aged to 5 days.
Fee HDD space is 477.4 MB, Total HDD size is 512.0 MB.
 
User avatar
Kanzler
newbie
Posts: 35
Joined: Wed Oct 05, 2022 6:55 pm
Location: Ukraine

Re: log files limited to 2 on my RB4011  [SOLVED]

Fri Jan 26, 2024 3:11 pm

System-Logging-Actions tab
 
parfait02
just joined
Topic Author
Posts: 17
Joined: Sat Jun 26, 2021 10:39 pm

Re: log files limited to 2 on my RB4011

Fri Jan 26, 2024 3:51 pm

System-Logging-Actions tab
Super cool
Thanks
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3297
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: log files limited to 2 on my RB4011

Fri Jan 26, 2024 3:53 pm

Its better to get the logs out of the router. For example, see my MikroTik for Splunk here:

viewtopic.php?t=179960
 
User avatar
k6ccc
Forum Guru
Forum Guru
Posts: 1497
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)
Contact:

Re: log files limited to 2 on my RB4011

Fri Jan 26, 2024 5:50 pm

I agree with Jotne. In my case, every night, I have a script that ftp the log files to my file server (along with the config export and backup files).
One of these days I will work on Splunk...
 
parfait02
just joined
Topic Author
Posts: 17
Joined: Sat Jun 26, 2021 10:39 pm

Re: log files limited to 2 on my RB4011

Mon Feb 26, 2024 11:11 pm

I agree with Jotne. In my case, every night, I have a script that ftp the log files to my file server (along with the config export and backup files).
One of these days I will work on Splunk...
Hello K6ccc,
Can you please share your script with us?
 
User avatar
k6ccc
Forum Guru
Forum Guru
Posts: 1497
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)
Contact:

Re: log files limited to 2 on my RB4011

Mon Feb 26, 2024 11:44 pm

This is copied from WinBox because in my opinion it's easier to read than an export. If you want the export version, just ask.
The first part creates the backup, export and version files.
Next is to send some of those files via E-Mail.
Last is to use ftp to transfer the files to my file server. My server is running FileZilla as a ftp server. It is configured not to allow any access from off my local LAN.
What is not shown here is a command file on the server that adds the date to the filenames. That is run via the task scheduler a few minutes after the routers ftp the files to the server. Lastly, there is another command file that runs at the end of every month and zips all the files into a monthly zip file.
This script is run every night at 2231 local time (router 2 does the same at 2232, and router 3 does the same at 2233).
# Policies needed:  ftp, read, policy, sensitive, test, write
# Policies NOT needed:  password, reboot, sniff, romon
:log info "Starting daily backup";
/system backup save name=RB4011_Daily
/export file=RB4011_Daily
/system package print file=RB4011_Version.txt
:delay 00:00:01
/tool e-mail send file=RB4011_Daily.backup to="<e-mail address>" body="4011 Router daily backup file attached." \
   subject="RB4011  $[/system clock get date] at $[/system clock get time]  Backup"
:delay 00:00:10
/tool e-mail send file=RB4011_Daily.rsc,RB4011_Version.txt,log.0.txt to="<e-mail address>" body="Router #1 daily script and version files attached." \
   subject="RB4011  $[/system clock get date] at $[/system clock get time]  Script"
:delay 00:00:10
/tool fetch address=192.168.201.11 src-path="RB4011_Daily.backup" user=<Redacted> mode=ftp password="<Redacted>" port=21 dst-path="RB4011_Daily.backup" upload=yes
:delay 00:00:03
/tool fetch address=192.168.201.11 src-path="RB4011_Daily.rsc" user=<Redacted> mode=ftp password="<Redacted>" port=21 dst-path="RB4011_Daily.rsc" upload=yes
:delay 00:00:03
/tool fetch address=192.168.201.11 src-path="RB4011_Version.txt" user=<Redacted> mode=ftp password="<Redacted>" port=21 dst-path="RB4011_Version.txt" upload=yes
:delay 00:00:03
/tool fetch address=192.168.201.11 src-path="log.0.txt" user=<Redacted> mode=ftp password="<Redacted>" port=21 dst-path="RB4011_log.0.txt" upload=yes
:delay 00:00:03
/tool fetch address=192.168.201.11 src-path="log.1.txt" user=<Redacted> mode=ftp password="<Redacted>" port=21 dst-path="RB4011_log.1.txt" upload=yes
:log info "Daily backup script completed"
Is this a perfect script, likely no, but it serves my purposes.

Just because I can, here is the windows filename rename command file - runs at 2245 nightly:
Rename RB4011_Daily.backup %date:~10,4%-%date:~4,2%-%date:~7,2%_RB4011_Daily.backup
Rename RB4011_Daily.rsc %date:~10,4%-%date:~4,2%-%date:~7,2%_RB4011_Daily.rsc
Rename RB4011_Version.txt %date:~10,4%-%date:~4,2%-%date:~7,2%_RB4011_Version.txt
Rename RB4011_log.0.txt %date:~10,4%-%date:~4,2%-%date:~7,2%_RB4011_log.0.txt
Rename RB4011_log.1.txt %date:~10,4%-%date:~4,2%-%date:~7,2%_RB4011_log.1.txt
Rename RB750r2_Daily.backup %date:~10,4%-%date:~4,2%-%date:~7,2%_RB750r2_Daily.backup
Rename RB750r2_Daily.rsc %date:~10,4%-%date:~4,2%-%date:~7,2%_RB750r2_Daily.rsc
Rename RB750r2_Version.txt %date:~10,4%-%date:~4,2%-%date:~7,2%_RB750r2_Version.txt
Rename RB750r2_log.0.txt %date:~10,4%-%date:~4,2%-%date:~7,2%_RB750r2_log.0.txt
Rename RB750r2_log.1.txt %date:~10,4%-%date:~4,2%-%date:~7,2%_RB750r2_log.1.txt
Rename RB750Gr3_Daily.backup %date:~10,4%-%date:~4,2%-%date:~7,2%_RB750Gr3_Daily.backup
Rename RB750Gr3_Daily.rsc %date:~10,4%-%date:~4,2%-%date:~7,2%_RB750Gr3_Daily.rsc
Rename RB750Gr3_Version.txt %date:~10,4%-%date:~4,2%-%date:~7,2%_RB750Gr3_Version.txt

And the end of the month windows zip command file - runs at 2250 local time on the last day of each month.
"c:\program files\7-zip\7z" a -tzip monthly.zip *.backup
"c:\program files\7-zip\7z" a -tzip monthly.zip *.rsc
"c:\program files\7-zip\7z" a -tzip monthly.zip *.txt
Rename Monthly.zip %date:~10,4%-%date:~4,2%_Monthly.zip
del *.backup
del *.rsc
del *.txt

Who is online

Users browsing this forum: McSee, yonutm and 21 guests