Could not Stat Command File

OK so here I am trying to get the damn external commands file to work. This is the error I am receiving eventhough I have followed the directions(in my eyes anyway). There must be something stupidly simple that I am missing.

Configuration
Kernel 2.6.9-5
Nagios 2.0b3
Apache 2.0.52

nagios.cfg
check_external_commands=1
command_check_interval=-1
command_file=/usr/local/nagios/var/rw/nagios.cmd

ls -la …/var/rw
drwxrwsr-x 2 nagios nagcmd 4096 Apr 7 13:30 rw
/etc/group entry
nagiocmd:x:505:nagios,nobody

webserver has been restarted

ls -l …/var/rw
prw-rw---- 1 nagios nagcmd 0 Apr 7 13:30 nagios.cmd

As far as I can tell I have made all the necessary changes to enable the external command file. However I still receive the error cannot stat file when I try to submit any commands to it.

Any ideas on what is going down here?

is the web server running as nobody? possibly it’s running as apache or www-user…

Luca

I’ve had the same trouble when there is more than one nagios running, so if the above doesn’t work, try this.
/etc/rc.d/init.d/nagios stop
ps -ef|grep nagios
make sure that there is no nagios running.
/etc/rc.d/init.d/nagios start
try again from web interface.

Hi Luca and Jakkedup,

Thanks for your replies. I thought I was on to something with Luca as the webserver was running as apache user apache group. However making the changes and restarting the httpd and nagios has yeilded on change in the error. I have even chmod the command file to a+rw. Still the same error. I did have it working yesterday for a short time but I have no idea why. It has to be something really stupidly simple.

I have figured what I did yesterday to enable the commands file to work. setenforce 0. Turning off the SELinux. I have to research this some more to figure out why this is standing in my way. I do not know too much about SELinux at this point.

There was another problem in this forum about cgi’s not working, several in fact. They had the same trouble with selinux, and they may help you out. Do a search for Redhat, or selinux, and you should find a couple.

[quote=“msouthco”]Hi Luca and Jakkedup,

Thanks for your replies. I thought I was on to something with Luca as the webserver was running as apache user apache group. However making the changes and restarting the httpd and nagios has yeilded on change in the error. I have even chmod the command file to a+rw. Still the same error. I did have it working yesterday for a short time but I have no idea why. It has to be something really stupidly simple.[/quote]

not sure what you did… did you add the apache user to the nagios group? :slight_smile:

Luca

If he did, he did it wrong. You add the apache user to the group nagcmd, per his permissions on the rw directory.
Wait a minute. Take a close look at his permissions. Her is a quote:
"ls -la …/var/rw
drwxrwsr-x 2 nagios nagcmd 4096 Apr 7 13:30 rw
/etc/group entry
nagiocmd:x:505:nagios,nobody

webserver has been restarted

ls -l …/var/rw
prw-rw---- 1 nagios nagcmd 0 Apr 7 13:30 nagios.cmd"
Notice how he has a group named “nagiocmd” but yet his permission are
"ls -la …/var/rw
drwxrwsr-x 2 nagios nagcmd 4096 Apr 7 13:30 rw"
That is wrong. It should be
drwxrwsr-x 2 nagios nagiocmd 4096 Apr 7 13:30 rw

Whatever user is running apache, add them to the group nagiocmd and fix those permissions. That is not the correct group name.

whoops my mistake. nagioscmd is the group, nagios is only the user.
And as you noticed he uses nagcmd instead of nagiocmd as he defined the group… :slight_smile:

Luca

[quote=“luca”]whoops my mistake. nagioscmd is the group, nagios is only the user.
And as you noticed he uses nagcmd instead of nagiocmd as he defined the group… :slight_smile:

Luca[/quote]

OOPs, another typo. “nagioscmd is the group”. Actually, it should be “nagiocmd” . I know, I’m being anal, but hey, the mistake he made was a typo also, so we don’t want to compound the problem. So maybe anal is ok, in this case, I hope. hehe