Page 1 of 1

log monitoring with rotation timestamp

Posted: Tue Jun 17, 2014 10:08 am
by erictse2
Hi,

I am using apache and configured logs with timestamp.
I am facing potential problem in adding these files Nagios file monitor
I don't know which is effective way I can use to add log files. same time it should not read old files.

error_log.1388707200 (this is unix system time stamp)

This file is not error_log that I can directly feed in the monitor.

Because it has timestamp error_log.{timestamp}
And the time stamp is changing everyday.

I am not sure if someone can point me out the directions how I can configure Nagios to point to the file with latest timestamp?

Thanks and regards,
Eric

Re: log monitoring with rotation timestamp

Posted: Tue Jun 17, 2014 2:04 pm
by scottwilkerson
What Nagios plugin are you using?

Re: log monitoring with rotation timestamp

Posted: Tue Jun 17, 2014 2:10 pm
by eloyd
One option would be to use logrotate instead of Apache's log format with timestamp. Then you would always have error_log as the current file. logrotate runs out of cron and will rotate old log files and kill -HUP apache to have it restart logging. This is pretty straightforward and there are many resources that show you how to do it.

Then your Nagios configuration would just need to look at the error_log file and not need to know about timestamps.

Re: log monitoring with rotation timestamp

Posted: Tue Jun 17, 2014 2:36 pm
by erictse2
Thank you very much for pointing the direction.

My apache is on windows. (sorry not linux)
Do you have any links to download logrotate for windows.?

Thanks and regards,
Eric

Re: log monitoring with rotation timestamp

Posted: Tue Jun 17, 2014 2:45 pm
by eloyd
A quick Google search for "logrotate for Windows" gave me this: http://sourceforge.net/projects/logrotatewin/. I have not looked at it or used it, but it looks like the same thing for Windows. You will need to use the Windows Task Scheduler to take the place of cron, but I am sure the documentation for logrotatewin will tell you how to do that.

Re: log monitoring with rotation timestamp

Posted: Tue Jun 17, 2014 5:01 pm
by erictse2
Thank you very much :)