Page 1 of 1
Error: Could not stat() command file '/usr/local/nagios/var/
Posted: Fri Feb 17, 2012 5:00 pm
by hotriver
I tried to use Re-schedule the next check of this service, but I got
Error: Could not stat() command file '/usr/local/nagios/var/rw/nagios.cmd'!
I searched from google and ran the following command.
chown nagios.nagcmd /usr/local/nagios/var/rw
chmod g+rwx /usr/local/nagios/var/rw
chmod g+s /usr/local/nagios/var/rw
[root@localhost libexec]# ls -lah /usr/local/nagios/var/rw
total 8.0K
drwxrwsr-x. 2 nagios nagcmd 4.0K Feb 17 15:18 .
drwxrwxr-x. 5 nagios nagios 4.0K Feb 17 15:22 ..
prw-rw----. 1 nagios nagcmd 0 Feb 17 15:18 nagios.cmd
But it still have the same problem. I use Centos 6.2 and Nagios Core 3.31
I also tried to change SELinux Context for /usr/local/nagios/var/rw, it did not work either.
I noticed that the /usr/local/nagios/var/rw/nagios.cmd is 0 byte in size, is this correct?
HELP
Thanks in advance
Re: Error: Could not stat() command file '/usr/local/nagios/
Posted: Sun Feb 19, 2012 6:24 pm
by jsmurphy
This is pretty much 100% of the time caused by a permissions issue, the .cmd file needs to be accessible by whatever you have defined as your command user/group and by the webserver. First of all take a peak at /etc/passwd and find the user account name for both nagios and your web server, then open /etc/group and locate your nagios group and your command group; nagios and nagcmd respectively for a default install. It should look something like this:
nagios

500:nagios,apache
nagcmd

501:nagios,apache
now check that rw and the .cmd file is owned by the nagios user and your nagios command group.
Re: Error: Could not stat() command file '/usr/local/nagios/
Posted: Tue Feb 21, 2012 10:56 am
by hotriver
Hi Jesmurphy,
Thank you very much for the help.
I checked etc/group and change nagios

500: to nagios

500:nagios,apache
But it did not work just after change. I had to change the SElinux Context for /usr/local/nagios/var/rw to httpd_user_rw_content_t, then it works.
Re: Error: Could not stat() command file '/usr/local/nagios/
Posted: Tue Feb 21, 2012 5:27 pm
by jsmurphy
Well on the plus side it was still a permissions issue

! What distro of Linux were you using? I've never seen SELinux interfere before... it would be good to know if it could be a distro specific thing.
Re: Error: Could not stat() command file '/usr/local/nagios/
Posted: Wed Feb 22, 2012 9:21 am
by hotriver
Hi Jsmerphy,
I use CentOS 6.2. It seems it added more oprions in the SELinux Context. I used 5.6 last year and did not need to change this option.
Re: Error: Could not stat() command file '/usr/local/nagios/
Posted: Thu Feb 23, 2012 11:22 am
by mguthrie
Yeah, I've concluded that the purpose of SELinux is just to silently break things. There's currently a bug in CentOS 6 that makes SSH keys useless if you have SELinux enabled, so I'm sure that's not the only issue that exists because of it ; )
Re: Error: Could not stat() command file '/usr/local/nagios/
Posted: Fri Mar 09, 2012 8:27 am
by estefania.rabadan
Hi all,
i have the same nagios.cmd problem. And i change the /et/group configuration, but i don't know where can i change SELinux Context from /usr/local/nagios/var/rw to httpd_user_rw_content_t. I'm using nagios 3.2.3 on Centos 6.2.
Thank you!
Re: Error: Could not stat() command file '/usr/local/nagios/
Posted: Thu May 24, 2012 8:59 am
by Hinze57
Okay, following what hotriver did and it not working on my install I spent some time in the man pages...
Here is what I did to get things working so far under SELinux. BTW, I am running RHEL 6.2 and Nagios 3.4.1 core.
First I modified the nagios folder structure's SELinux labels to allow httpd read access:
# chcon -R --reference=/var/www/html /usr/local/nagios/share
# chcon -R --reference=/var/www/html /usr/local/nagios/var
# chcon -R --reference=/var/www/cgi-bin /usr/local/nagios/sbin
Next I changed the ~var/rw folder to allow write access via the httpd_sys_rw_content_t label:
# chcon -R -t httpd_sys_rw_content_t /usr/local/nagios/var/rw
So far it seems to be working for me.
Cheers,
Re: Error: Could not stat() command file '/usr/local/nagios/
Posted: Fri Aug 24, 2012 7:30 am
by xmuwolf
Hinze57 wrote:Okay, following what hotriver did and it not working on my install I spent some time in the man pages...
Here is what I did to get things working so far under SELinux. BTW, I am running RHEL 6.2 and Nagios 3.4.1 core.
First I modified the nagios folder structure's SELinux labels to allow httpd read access:
# chcon -R --reference=/var/www/html /usr/local/nagios/share
# chcon -R --reference=/var/www/html /usr/local/nagios/var
# chcon -R --reference=/var/www/cgi-bin /usr/local/nagios/sbin
Next I changed the ~var/rw folder to allow write access via the httpd_sys_rw_content_t label:
# chcon -R -t httpd_sys_rw_content_t /usr/local/nagios/var/rw
So far it seems to be working for me.
Cheers,
Good job, well done!
Finnaly it worked when i did as you mentioned.
I have google for this case for a long time but it doesn't work always except setenforce=0.
Thanks a lot!
Re: Error: Could not stat() command file '/usr/local/nagios/
Posted: Fri Aug 24, 2012 7:32 am
by xmuwolf
Hinze57 wrote:Okay, following what hotriver did and it not working on my install I spent some time in the man pages...
Here is what I did to get things working so far under SELinux. BTW, I am running RHEL 6.2 and Nagios 3.4.1 core.
First I modified the nagios folder structure's SELinux labels to allow httpd read access:
# chcon -R --reference=/var/www/html /usr/local/nagios/share
# chcon -R --reference=/var/www/html /usr/local/nagios/var
# chcon -R --reference=/var/www/cgi-bin /usr/local/nagios/sbin
Next I changed the ~var/rw folder to allow write access via the httpd_sys_rw_content_t label:
# chcon -R -t httpd_sys_rw_content_t /usr/local/nagios/var/rw
So far it seems to be working for me.
Cheers,
Thanks a lot , it worked finally!