xqms / rosmon

ROS node launcher & monitoring daemon
Other
180 stars 47 forks source link

Disable/reduce log data #132

Closed d-walsh closed 1 year ago

d-walsh commented 4 years ago

I am using rosmon on a machine that doesn't get reboot often (clearing tmp) and the nodes that are managed by rosmon can run for days. This leads to very large amounts of data being written to /tmp/rosmon* until I eventually get the error:

terminate called after throwing an instance of 'fmt::v6::system_error'
  what():  cannot write to file: No space left on device

It would be good to be able to disable logging. Or only log recent data (maybe 1 hr?). Also it would be good to handle this error where there is no space available.

xqms commented 4 years ago

Thanks for the report!

I guess you can already disable logging through mon launch --log=/dev/null .... Do you think we need an explicit option for this?

For log rotation (e.g. keep the last day of logs), you can use an external helper like logrotate.

What do you think would be a good recovery behavior if the disk is full?

amilcarlucas commented 4 years ago

@xqms can you provide more details about the logrotate solution? What copy mode should be used?

amilcarlucas commented 3 years ago

Would be nice to get an answer :(

xqms commented 3 years ago

@amilcarlucas sorry, didn't get around to replying yet.

Well, the solution obviously depends on your application... One configuration I can think of is using --log /path/file to force rosmon to write its logfile to a particular location. Then use logrotate with its copytruncate option to periodically "cut" the logfile into segments. The usual options can then be used to delete old log file segments.

amilcarlucas commented 3 years ago

@xqms nope, that does not work. I used your idea and this configuration

copytruncate
nocompress
notifempty
olddir /media/ubuntu/sdcard/logs/2021-07-05-1409
/tmp/iav-*.log { }
/media/ubuntu/sdcard/.ros/log/*.log { }
/media/ubuntu/sdcard/.ros/log/latest/*.log { }

But the log file generated by rosmon still has a ton of zeros in the beginning of the file. Looks like the fseek is somehwere inside the file and so a new file gets created with a bunch of zeros. The file size increases, instead of going back to zero. Any other ideas?

I am using rosmon c9f49cb33404c267 with logrotate 3.11.0 (ubuntu 18.04)

amilcarlucas commented 3 years ago

I got some more info:

amilcarlucas commented 3 years ago

I try to address this on https://github.com/xqms/rosmon/pull/154

xqms commented 1 year ago

rosmon now supports --log=syslog, which logs to the systemd journal under Ubuntu. The journal has its own settings for log retention and is a superior solution to logrotate & friends. I'll therefore close this issue. Feel free to comment further if there is still a problem.