Hi team,
I've been having issues with logrotate for Nagios. If I check at the status it says that the logs have been rotated, however when I check the size the files are still growing (they should be rotated if size is bigger than 5M):
usr/local/nagiosxi/var# cat /var/lib/logrotate/status | grep -i nag
"/usr/local/nagiosxi/var/reportengine.log" 2023-1-11-17:39:57
"/usr/local/nagiosxi/var/xidebug.log.backtrace" 2022-3-15-0:0:0
"/usr/local/nagiosxi/var/feedproc.log" 2023-1-11-17:39:57
"/usr/local/nagiosxi/var/cleaner.log" 2023-1-16-0:0:1
"/usr/local/nagiosxi/var/scheduledreporting.log" 2022-3-15-0:0:0
"/usr/local/nagiosxi/var/eventman.log" 2023-1-11-17:39:57
"/usr/local/nagiosxi/var/load_url.log" 2023-1-11-17:39:57
"/usr/local/nagiosxi/var/components/auditlog.log" 2023-1-11-17:39:57
"/usr/local/nagiosxi/var/sysstat.log" 2023-1-16-0:0:1
"/usr/local/nagiosxi/var/cmdsubsys.log" 2023-1-11-17:39:57
"/usr/local/nagiosxi/var/deadpool.log" 2023-1-11-17:39:57
"/usr/local/nagiosxi/var/event_handler.log" 2023-1-11-17:39:57
"/usr/local/nagiosxi/var/xidebug.log" 2022-3-15-0:0:0
"/usr/local/nagiosxi/var/wkhtmltox.log" 2022-3-15-0:0:0
"/usr/local/nagiosxi/var/dbmaint.log" 2023-1-11-17:39:57
"/usr/local/nagiosxi/var/perfdataproc.log" 2023-1-11-17:39:57
"/usr/local/nagiosxi/var/nom.log" 2023-1-11-17:39:57
"/usr/local/nagiosxi/var/recurringdowntime.log" 2023-1-11-17:39:57
"/usr/local/nagiosxi/var/snmptt_service_results.log" 2022-3-15-0:0:0
Using sysstat as an example It says that the sysstat was rotated at 2023-1-16-0:0:1 however if I check at the size of the file its way bigger than 5M:
/usr/local/nagiosxi/var# ls -lahSr
-rw-rw-r-- 1 nagios nagios 121M Jan 16 15:21 sysstat.log
Here are the settings nagios logrotate (I have tried with and without copytruncate):
cat /etc/logrotate.d/nagiosxi
/usr/local/nagiosxi/var/*log {
missingok
notifempty
size 5M
su nagios nagios
rotate 1
compress
}
/usr/local/nagiosxi/var/xidebug.log {
missingok
notifempty
size 100M
copytruncate
create 0660 www-data nagios
su www-data nagios
rotate 1
compress
}
/usr/local/nagiosxi/var/xidebug.log.backtrace {
missingok
notifempty
size 100M
copytruncate
create 0660 www-data nagios
su www-data nagios
rotate 1
compress
}
/usr/local/nagiosxi/var/components/auditlog.log {
missingok
notifempty
size 100M
copytruncate
create 0660 www-data nagios
su www-data nagios
rotate 1
compress
}
If I force logrotate to run manually running logrotate -f -v --log /tmp/logrotate_results.txt /etc/logrotate.d/nagiosxi it does work and the file gets rotated, but it is not working when the cron job runs daily.
Logrotate not working on /usr/local/nagiosxi/var/*log
Re: Logrotate not working on /usr/local/nagiosxi/var/*log
Update:
The problem seems to be within the logorate service itself.
Logrotate is starting but failing:
root@:/run/log/journal# systemctl status logrotate.service
● logrotate.service - Rotate log files
Loaded: loaded (/lib/systemd/system/logrotate.service; static; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2023-01-16 00:00:02 UTC; 18h ago
TriggeredBy: ● logrotate.timer
Docs: man:logrotate(8)
man:logrotate.conf(5)
Process: 1645196 ExecStart=/usr/sbin/logrotate /etc/logrotate.conf (code=exited, status=1/FAILURE)
Main PID: 1645196 (code=exited, status=1/FAILURE)
Jan 16 00:00:01 systemd[1]: Starting Rotate log files...
Jan 16 00:00:01 logrotate[1645196]: error: error renaming /usr/local/nagiosxi/var/cleaner.log.1.gz to /usr/local/nagiosxi/var/cleaner.log.2.gz: Read-only file system
Jan 16 00:00:01 logrotate[1645196]: error: error renaming /usr/local/nagiosxi/var/sysstat.log.1.gz to /usr/local/nagiosxi/var/sysstat.log.2.gz: Read-only file system
Jan 16 00:00:02 systemd[1]: logrotate.service: Main process exited, code=exited, status=1/FAILURE
Jan 16 00:00:02 systemd[1]: logrotate.service: Failed with result 'exit-code'.
Jan 16 00:00:02 systemd[1]: Failed to start Rotate log files.
I have checked permissions here is what I have found (I didn not find any apparent issues):
root:/etc/logrotate.d# ls -lahrt nagiosxi
-rw-r--r-- 1 root root 687 Jan 16 16:14 nagiosxi
root:/etc/logrotate.d# ls -ldhrt /etc/cron.daily
drwxr-xr-x 2 root root 4.0K Mar 7 2022 /etc/cron.daily
root:/etc/cron.daily# ls -ldhrt logrotate
-rwxr-xr-x 1 root root 377 Jan 21 2019 logrotate
root:/usr/local/nagiosxi/var# ls -ldhrt sysstat.log
-rw-rw-r-- 1 nagios nagios 124M Jan 16 18:47 sysstat.log
The problem seems to be within the logorate service itself.
Logrotate is starting but failing:
root@:/run/log/journal# systemctl status logrotate.service
● logrotate.service - Rotate log files
Loaded: loaded (/lib/systemd/system/logrotate.service; static; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2023-01-16 00:00:02 UTC; 18h ago
TriggeredBy: ● logrotate.timer
Docs: man:logrotate(8)
man:logrotate.conf(5)
Process: 1645196 ExecStart=/usr/sbin/logrotate /etc/logrotate.conf (code=exited, status=1/FAILURE)
Main PID: 1645196 (code=exited, status=1/FAILURE)
Jan 16 00:00:01 systemd[1]: Starting Rotate log files...
Jan 16 00:00:01 logrotate[1645196]: error: error renaming /usr/local/nagiosxi/var/cleaner.log.1.gz to /usr/local/nagiosxi/var/cleaner.log.2.gz: Read-only file system
Jan 16 00:00:01 logrotate[1645196]: error: error renaming /usr/local/nagiosxi/var/sysstat.log.1.gz to /usr/local/nagiosxi/var/sysstat.log.2.gz: Read-only file system
Jan 16 00:00:02 systemd[1]: logrotate.service: Main process exited, code=exited, status=1/FAILURE
Jan 16 00:00:02 systemd[1]: logrotate.service: Failed with result 'exit-code'.
Jan 16 00:00:02 systemd[1]: Failed to start Rotate log files.
I have checked permissions here is what I have found (I didn not find any apparent issues):
root:/etc/logrotate.d# ls -lahrt nagiosxi
-rw-r--r-- 1 root root 687 Jan 16 16:14 nagiosxi
root:/etc/logrotate.d# ls -ldhrt /etc/cron.daily
drwxr-xr-x 2 root root 4.0K Mar 7 2022 /etc/cron.daily
root:/etc/cron.daily# ls -ldhrt logrotate
-rwxr-xr-x 1 root root 377 Jan 21 2019 logrotate
root:/usr/local/nagiosxi/var# ls -ldhrt sysstat.log
-rw-rw-r-- 1 nagios nagios 124M Jan 16 18:47 sysstat.log
Re: Logrotate not working on /usr/local/nagiosxi/var/*log
Thanks for reaching out @rcs123,
This sounds like a known issue that is getting fixed in the upcoming 5.11.2 release.
If you want to fix the issue now try:
If that doesn't work, let me know
This sounds like a known issue that is getting fixed in the upcoming 5.11.2 release.
If you want to fix the issue now try:
Code: Select all
echo "ReadWritePaths=/usr/local/nagiosxi/var /usr/local/nagiosxi/tmp" >> /usr/lib/systemd/system/logrotate.service