Closed peteruithoven closed 8 years ago
Enabling logrotate in Openwrt and using it i.c.w. cron looks like a suitable approach. The manual can be found here.
Parameters we should find good values for (including proposals):
1MB + (700kB + 14kB) * num_minutes
- that is: inital filling of gcode buffer generates about 1MB of logging, then while printing this stabilizes to around 700kB for the print3d log and 14kB for the firmware log per minute).Further aspects to consider:
When rotation is in place, there are two further things to implement:
info/logfiles
endpoint.With keeping the first lines you mean keeping the logs related to the initialization of the firmware / print3d?
Indeed, I've updated the comment.
(It's also relevant for the firmware (wifibox.log), because of the wifi related initialization.)
Good point.
With the early logrotation changes we did a big print on the Ultimaker2 and I did notice some momentary freezes, this might be caused by the copytruncate
trick. These freezes are visible in the prints in the form of blobs:
Are the blobs in the photo only occurring when logging extensively? Or is also a problem in normal use?
We have not tested this yet without heavy logging.
I would also suspect the compress option, this can quickly be disabled (it might be wise to also lower the rotate setting to 1 then). In either case, rotating earlier (e.g. at 500k) could reduce the freezing.
I could not reproduce this. The printer did not stutter visibly or audibly while logrotate was running. Inspecting top
during the rotation, I could see gzip
running for a few seconds, taking about 80% of CPU, but it did not seem to have any impact on printing.
The stuttering might have had to do with a higher setting of Printer.MAX_LINES_PER_POST in the client.
Closing this for now.
Even though we couldn't reproduce the blobs with a regular MAX_LINES_PER_POST there are still little things to fix for logrotation.
The important aspects have all been implemented (see merge commit here).
We have decided not to implement log reopening on sighup/sigusr1 in print3d and firmware, assuming the copytruncate option will work well.
I looked at the memory usage by doing "while true; do date; free; sleep 5; done" within the SSH of the WiFi-Box. The free memory goes down for about 3 minutes than log rotation comes in and the free memory goes up again. Most of the time the memory is between 2000 en 3000 (2 MB / 3MB) before it goes up again. This was while printing on the Ultimaker 2.
On the test WiFi-Box I've lowered the logrotate size from 1000k to 500k. Hopefully this will give us a bit more playroom.
The 3 minute interval however is a lower bound by the cron configuration so perhaps we should also lower that a bit.
@woutgg What do you mean with lower bound
?
It will only run every 3 minutes, so regardless of actual log size, the logs will never be rotated sooner than the next time cron runs logrotate.
Ah, I was convinced it was 3min. In that case, shouldn't we first lower just the interval? Because every rotate costs processing power. I've created a easier to use check that allows sorting:
while true; do echo "$(cat /proc/meminfo | grep MemFree | sed -E 's/^[^0-9]+//') $(date '+%H:%M:%S')";
Yes, 3 minutes indeed. And I think we can safely lower it. Logrotate will only actually do something when the files are larger than the limit we set so it's rather cheap to run.
Like @mpbomil noticed, currently our print3D logfiles keep growing on the limited RAM space of the WiFi-Box. One solution would be to implement some kind of log rotation. This means older logs are automatically removed.
It would be important to keep the first 100 / 200 lines, since this contains information about the 3D printer and how we've made the connection.
We can implement something ourselves, but we should probably use the regular logrotate utility, see: http://groenholdt.net/Computers/OpenWRT/openwrt-logrotate.html http://www.thegeekstuff.com/2010/07/logrotate-examples/ http://linux.die.net/man/8/logrotate http://manpages.ubuntu.com/manpages/saucy/en/man8/logrotate.8.html