Nagios Won’t Start or Stop – Troubleshooting Guide

centoslinuxnagios

I ran an update on a CentOS server running Nagios, after the update, Nagios failed to start.

The error in the logs was:

Failed to obtain lock on file /var/run/nagios.pid: Permission denied

So, I checked and there was no pid file for Nagios in /var/run. I created one and gave it the following permissions:

-rwxr–r– 1 nagios nagios 6 May 31 11:58 nagios.pid

Nagios then started and seems to be running normally.

The only problem is, it refuses to stop now, so I can't re-start it to add new servers and services to be monitored!

When I issue the command "service nagios stop", I get [FAILED], but nothing at all gets outputted to the log, and the service remains up.

Any ideas on how I can get the service to stop now?

I'm running the RPM version which was installed via yum from the RPMForge repositories. The server is CenotOS 5.5.

Best Answer

If you don't want to change the permissions on the /var/run folder itself, you can configure nagios to store the lock file anywhere on the system by adding the line below to your nagios.cfg file. As long as you point the lock_file option to a directory that nagios has access to create, modify and delete files then you should be good to go.

You could even store the lock file within your nagios installation directory by creating a a directory like: /usr/lib/nagios/var

lock_file=/usr/lib/nagios/var
Related Topic