Safe way to clear a couple of logs

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
PhilG
Posts: 286
Joined: Thu Jan 16, 2014 10:24 am

Safe way to clear a couple of logs

Post by PhilG »

Hello:
We are running Nagios XI 5.2.7 and had to run a backup and then run a repair after noting the following log entry in "/var/log/mysqld.log":
"... [ERROR] /usr/libexec/mysqld: Table './nagios/nagios_logentries' is marked as crashed and last (automatic?) repair failed"

The repair appears to have worked.

I noted that "/var/log/mysqld.log" is a little larger than what I would like:
463467556 Jul 25 13:29 mysqld.log

Also, the disk space directory culprit is "/var/log/httpd":
342896 /var/log/httpd/ssl_request_log.1
318992 /var/log/httpd/ssl_access_log.1

What is the "safe" way to clear the mysqld log that is in use, and where do we set a cap on the logs?

Thank you in advance for your assistance.
Newbie '14
PhilG
Posts: 286
Joined: Thu Jan 16, 2014 10:24 am

Re: Safe way to clear a couple of logs

Post by PhilG »

I stand corrected regarding that the repair worked. I noted that "Notifications are disabled for this host" for ALL Hosts and that the Host appears in the Service Status window with a grey background (Host check is pending...", and stays the same even after forcing an immediate check.
Newbie '14
PhilG
Posts: 286
Joined: Thu Jan 16, 2014 10:24 am

Re: Safe way to clear a couple of logs

Post by PhilG »

UPDATE: Nevermind. I did a server restart and the problem does not appear anymore.
PhilG wrote:I stand corrected regarding that the repair worked. I noted that "Notifications are disabled for this host" for ALL Hosts and that the Host appears in the Service Status window with a grey background (Host check is pending...", and stays the same even after forcing an immediate check.
Newbie '14
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Safe way to clear a couple of logs

Post by ssax »

You can clear /var/log/mysqld.log with this command:

Code: Select all

> /var/log/mysqld.log
But you may want to setup logrotate to handle it automatically, I think you can uncomment this section in your /etc/logrotate.d/mysqld:

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
#}
So that it looks like this:

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
}
That should take care of it.
PhilG
Posts: 286
Joined: Thu Jan 16, 2014 10:24 am

Re: Safe way to clear a couple of logs

Post by PhilG »

Which command, please, since only the log file and path appear in the code section?
ssax wrote:You can clear /var/log/mysqld.log with this command:

Code: Select all

> /var/log/mysqld.log
....
Newbie '14
bolson

Re: Safe way to clear a couple of logs

Post by bolson »

It isn't a command... It's the right arrow key (greater than sign) as shown.
PhilG
Posts: 286
Joined: Thu Jan 16, 2014 10:24 am

Re: Safe way to clear a couple of logs

Post by PhilG »

Thank you.
You may close this post.
Newbie '14
bolson

Re: Safe way to clear a couple of logs

Post by bolson »

Closing topic as resolved.

Thank you for using the Nagios Support Forum!
Locked