Page 1 of 1

NagiosXI logrotate not working

Posted: Fri Nov 17, 2023 1:20 am
by elpakko
I read somewhere that NagiosXI should have automatic Logrotation feature. I have noticed that perhaps the logrotate is not working, because my log files are getting big. I have not touched the logrotate conf files, but is there something I should configure for the logrotate to start working?

The settings are at the moment:

PRODDIR/var/*log {
missingok
notifempty
size 5M
copytruncate
su NAGIOSUSER NAGIOSGROUP
rotate 1
compress
}

PRODDIR/var/xidebug.log {
missingok
notifempty
size 100M
copytruncate
create 0660 APACHEUSER NAGIOSGROUP
su APACHEUSER NAGIOSGROUP
rotate 1
compress
}

PRODDIR/var/xidebug.log.backtrace {
missingok
notifempty
size 100M
copytruncate
create 0660 APACHEUSER NAGIOSGROUP
su APACHEUSER NAGIOSGROUP
rotate 1
compress
}

PRODDIR/var/components/auditlog.log {
missingok
notifempty
size 100M
copytruncate
create 0660 APACHEUSER NAGIOSGROUP
su APACHEUSER NAGIOSGROUP
rotate 1
compress
}

PRODDIR/tmp/phpmailer.log {
missingok
notifempty
size 100M
copytruncate
create 0660 APACHEUSER NAGIOSGROUP
su APACHEUSER NAGIOSGROUP
rotate 1
compress
}

When I run

"logrotate -d /etc/logrotate.d/nagiosxi"

I get:

reading config file /etc/logrotate.d/nagiosxi
error: /etc/logrotate.d/nagiosxi:1 unknown option 'PRODDIR' -- ignoring line
error: /etc/logrotate.d/nagiosxi:6 unknown user 'NAGIOSUSER'

Re: NagiosXI logrotate not working

Posted: Fri Nov 17, 2023 9:50 am
by lgute
Hi @elpakko, thanks for reaching out.

What version of XI are you using and what OS & version? There have been a few fixes released lately that may address this issue for you.

This post may also address the issues you are having.

Re: NagiosXI logrotate not working

Posted: Mon Nov 20, 2023 1:52 am
by elpakko
Hi, thanks for your message.

I'm using the latest NagiosXI version 5.11.3 and Ubuntu 22.04 LTS with all the latest updates installed. I think this problem has been around for awhile, because sysstat.log is more than 13G in size.

Re: NagiosXI logrotate not working

Posted: Fri Nov 24, 2023 1:39 am
by elpakko
@lgute

Any ideas on what to do? Should I try the command from the other post you suggested?

Re: NagiosXI logrotate not working

Posted: Mon Nov 27, 2023 9:59 am
by lgute
Hi @elpakko,

Please run the following to correct the log rotation issue. It does appear to be the same issue as the post I linked to.

Code: Select all

. /usr/local/nagiosxi/etc/xi-sys.cfg
sed -i "s|APACHEUSER|$apacheuser|;s|NAGIOSGROUP|$nagiosgroup|;s|NAGIOSUSER|$nagiosuser|;s|PRODDIR|$proddir|" /etc/logrotate.d/nagiosxi
One more question. Is this a new install or an upgrade? If upgrade, what was the last version you upgraded from?

Re: NagiosXI logrotate not working

Posted: Tue Nov 28, 2023 12:58 am
by elpakko
Thanks, I ran the command and now the logrotate seems to be working again. The previous version was 5.11.2 but according to lograte info, the last succesfull rotation was 17.5.2023. So looking at my upgrade history, it seems that it was broken in the upgrade from 5.9.3 to 5.10.0

Re: NagiosXI logrotate not working

Posted: Tue Nov 28, 2023 10:11 am
by lgute
@elpakko,

Thank you for the update. I am glad that resolved your issue.