Nagios – Error: Could not stat() command file
So there I was. I just installed Nagios on a brand new Debian (6.0.3) host, I was greeted with the following error message after logging into the Nagios web interface and clicking a link that uses external commands:
Error: Could not stat() command file '/var/lib/nagios3/rw/nagios.cmd'
What? Well, after making sure my configuration is correct, I figured that this must be some kind of permission problem…
So the problem is that Nagios cannot write to the command file (which is a pipe according to the documentation):
This is the file that Nagios will check for external commands to process. The command CGI writes commands to this file. The external command file is implemented as a named pipe (FIFO), which is created when Nagios starts and removed when it shuts down.
A quick search through Google (I don’t want to imagine what I would do without google), I came across the blog of Lars Schenk, where I found the clean way to fix this problem:
# dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw
# dpkg-statoverride --update --add nagios www-data 751 /var/lib/nagios3
After applying this fix, restart the service
# /etc/init.d/nagios3 restart
and you are good to go!