Logrotate for myslqd.log

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Deantwo
Posts: 52
Joined: Thu Mar 03, 2016 8:39 am

Logrotate for myslqd.log

Post by Deantwo »

Investigating disk space issues on our Nagios VM revealed a myslqd.log file with the size of 25GB. The log file has been growing since the server was setup in 2016.

Is there anyway to enable logrotation for the myslqd.log file? So it is saved in a new file every month or week, and files of x age be deleted.
If it isn't already possible, can I make this as a feature request?
User avatar
lmiltchev
Former Nagios Staff
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Logrotate for myslqd.log

Post by lmiltchev »

You should already have a logrotate script in the "/etc/logrotate.d/" directory, named "mysqld". Open it in a text editor, and comment out the section on the bottom:

Code: Select all

/var/log/mysqld.log {
        create 640 mysql mysql
        notifempty
        daily
        rotate 3
        missingok
        compress
    postrotate
        # just if mysqld is really running
        if test -x /usr/bin/mysqladmin && \
           /usr/bin/mysqladmin ping &>/dev/null
        then
           /usr/bin/mysqladmin flush-logs
        fi
    endscript
}
Change any options that you need to, e.g. "daily" to "weekly", etc.

In the "/etc/my.cnf" file, you would need to add a username/password, e.g:

Code: Select all

[mysqladmin]
password = nagiosxi
user= root
You can test the log rotation by running:

Code: Select all

logrotate -f /etc/logrotate.d/mysqld
Be sure to check out our Knowledgebase for helpful articles and solutions!
Deantwo
Posts: 52
Joined: Thu Mar 03, 2016 8:39 am

Re: Logrotate for myslqd.log

Post by Deantwo »

Ok, I have set it up like you suggested.
Thanks.

Just confused as to why this isn't standard on the NagiosXI VM.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Logrotate for myslqd.log

Post by lmiltchev »

Ok, I have set it up like you suggested.
Thanks.
I am glad I could help!
Just confused as to why this isn't standard on the NagiosXI VM.
It's a good question - I will discuss it with our developers.

I will be closing this topic now. If you have any further issues/questions, please start a new thread.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked