Page 1 of 1

Monitor Apache logs

Posted: Wed Apr 09, 2014 4:29 pm
by jkinning
I am trying to figure out how I can get or what I need to do in order to have Nagios monitor my Apache logs (access logs primarily). I just encountered an issue where it appears log rotate had hung up and prevented anything from writing to my websites access logs. The server, SUSE (SLES) 11sp3, was rebooted after having some patches and an updated kernel. Once the system was rebooted data was writing to the access logs again. I would like to use Nagios to monitor this log file so that if nothing is writing to it an alert is generated. It sounds easy enough but not sure how to go about setting up the monitoring. I would be using Nagios XI.

If there is some other means or better method to make sure that my Apache websites are writing logs that would work as well. We use these access logs to send to WebTrends for analysis. 3 weeks worth of data is a pretty big deal so I really need to prevent this from happening in the future. I am working on root cause but having a Nagios "safety net" in place would allow me to sleep better at night. :)

Re: Monitor Apache logs

Posted: Wed Apr 09, 2014 4:39 pm
by slansing
The easiest thing may be checking the "date modified" with a simple plugin such as:

http://exchange.nagios.org/directory/Pl ... ck/details

That way you will know if anything has been written to it during the specified period of time. It is presumably a web server so this should be happening almost constantly I would think.

Re: Monitor Apache logs

Posted: Thu Apr 10, 2014 6:43 am
by jkinning
Most of my checks are done via ssh. So I would need to install the nrpe agent? I didn't see how I could use this plugin to monitor a remote system.

Re: Monitor Apache logs

Posted: Thu Apr 10, 2014 9:34 am
by tmcdonald
jkinning wrote:Most of my checks are done via ssh.
In this case I would just use SSH to run the script as you would with any other.

Re: Monitor Apache logs

Posted: Thu Apr 10, 2014 10:33 am
by jkinning
Not to sound stupid but how would I go about doing that?

I tried check_by_ssh -H <host> -C check_file_age -f <file location> -w 1440 -c 2880 and got invalid option -- w so I tried without the -w and -c and received wrong argument! (arg1=check_file_age)

Re: Monitor Apache logs

Posted: Thu Apr 10, 2014 10:43 am
by tmcdonald
Have you check out our Monitoring Hosts Using SSH doc?

You will need to put the python plugin on the remote system, as well as have python installed to run it.

Re: Monitor Apache logs

Posted: Thu Apr 10, 2014 11:13 am
by jkinning
Thanks for the link. Working like a charm now.

Appreciate the assistance!

Re: Monitor Apache logs

Posted: Thu Apr 10, 2014 11:15 am
by tmcdonald
No problem at all. I'll be locking this thread now, but feel free to open another if you need anything else in the future!