Page 1 of 1

Error: Could not open command file '/usr/local/nagios/var/rw

Posted: Fri Mar 22, 2013 6:08 am
by Rhobar
I have this errore in the web interface whene I try to enable notifications for check_http and check_ssh:

Error: Could not open command file '/usr/local/nagios/var/rw/nagios.cmd' for update!
The permissions on the external command file and/or directory may be incorrect. Read the FAQs on how to setup proper permissions.
An error occurred while attempting to commit your command for processing.
Return from whence you came

I read that is permission problem and I tried as this site suggests:
http://www.servernoobs.com/error-could- ... or-update/

but nothis has changed :(

some ideas?

Re: Error: Could not open command file '/usr/local/nagios/va

Posted: Fri Mar 22, 2013 7:01 am
by pep
su to your nagios user and run the command from cli

enable debug on conf file to check possible issues

Re: Error: Could not open command file '/usr/local/nagios/va

Posted: Fri Mar 22, 2013 7:27 am
by scottwilkerson
Rhobar wrote:Error: Could not open command file '/usr/local/nagios/var/rw/nagios.cmd' for update!
Was nagios running? the command pipe is only presend when nagios is running

Re: Error: Could not open command file '/usr/local/nagios/va

Posted: Fri Mar 22, 2013 10:02 am
by Rhobar
scottwilkerson wrote:
Rhobar wrote:Error: Could not open command file '/usr/local/nagios/var/rw/nagios.cmd' for update!
Was nagios running? the command pipe is only presend when nagios is running
yes, I have this problem on web interface
I foud this image on web :!:
Image
pep wrote:su to your nagios user and run the command from cli

enable debug on conf file to check possible issues
I'm sorry but I don't understand what you mean

Re: Error: Could not open command file '/usr/local/nagios/va

Posted: Fri Mar 22, 2013 4:37 pm
by scottwilkerson
please run the following

Code: Select all

service nagios status
and

Code: Select all

ls -l /usr/local/nagios/var/rw
And post the results of both

Re: Error: Could not open command file '/usr/local/nagios/va

Posted: Mon Mar 25, 2013 10:32 pm
by tlum
Are you running with SELinux active? If so, this is real common, you'll need to install a custom policy like:

Code: Select all

module NagiosRule 1.0;

require {
        type httpd_sys_script_t;
        type usr_t;
        class fifo_file { write getattr open };
}

#============= httpd_sys_script_t ==============
allow httpd_sys_script_t usr_t:fifo_file open;
#!!!! This avc is allowed in the current policy

allow httpd_sys_script_t usr_t:fifo_file { write getattr };
Also, with SELinux systems, people sometimes forget 'ls -Z' is your friend.

If no SELinux then never mind.

Re: Error: Could not open command file '/usr/local/nagios/va

Posted: Tue Mar 26, 2013 5:08 am
by Rhobar
scottwilkerson wrote:please run the following

Code: Select all

service nagios status
and

Code: Select all

ls -l /usr/local/nagios/var/rw
And post the results of both
here there is:

Code: Select all

[root@studentstation10 ~]# service nagios status
nagios (pid 2522) is running...
[root@studentstation10 ~]# ls -l /usr/local/nagios/var/rw
total 0
prw-rw----. 1 nagios nagcmd 0 Mar 22 11:40 nagios.cmd
[root@studentstation10 ~]# 

tlum wrote:Are you running with SELinux active? If so, this is real common, you'll need to install a custom policy like:

Code: Select all

module NagiosRule 1.0;

require {
        type httpd_sys_script_t;
        type usr_t;
        class fifo_file { write getattr open };
}

#============= httpd_sys_script_t ==============
allow httpd_sys_script_t usr_t:fifo_file open;
#!!!! This avc is allowed in the current policy

allow httpd_sys_script_t usr_t:fifo_file { write getattr };
Also, with SELinux systems, people sometimes forget 'ls -Z' is your friend.

If no SELinux then never mind.
First starting I do:
getenforce
setenforce 0

I don't know if it is useful

Re: Error: Could not open command file '/usr/local/nagios/va

Posted: Tue Mar 26, 2013 7:43 am
by scottwilkerson
Hmm, lets see if apache is part of the correct group

run

Code: Select all

cat /etc/group|grep nag

Re: Error: Could not open command file '/usr/local/nagios/va

Posted: Tue Mar 26, 2013 8:04 am
by Rhobar

Code: Select all

[root@studentstation10 ~]# cat /etc/group|grep nag
nagios:x:501:
nagcmd:x:502:nagios

Re: Error: Could not open command file '/usr/local/nagios/va

Posted: Tue Mar 26, 2013 9:12 am
by scottwilkerson
you need to add your apache user to the nagios and nagcmd group
eg.

Code: Select all

useradd -G nagios apache
useradd -G nagcmd apache