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

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Rhobar
Posts: 41
Joined: Sat Mar 16, 2013 9:23 am
Location: Rome, Italy

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

Post 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?
pep
Posts: 11
Joined: Wed Mar 13, 2013 11:26 am

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

Post by pep »

su to your nagios user and run the command from cli

enable debug on conf file to check possible issues
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Rhobar
Posts: 41
Joined: Sat Mar 16, 2013 9:23 am
Location: Rome, Italy

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

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
tlum
Posts: 16
Joined: Thu Jun 28, 2012 9:07 pm

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

Post 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.
Rhobar
Posts: 41
Joined: Sat Mar 16, 2013 9:23 am
Location: Rome, Italy

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

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post by scottwilkerson »

Hmm, lets see if apache is part of the correct group

run

Code: Select all

cat /etc/group|grep nag
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Rhobar
Posts: 41
Joined: Sat Mar 16, 2013 9:23 am
Location: Rome, Italy

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

Post by Rhobar »

Code: Select all

[root@studentstation10 ~]# cat /etc/group|grep nag
nagios:x:501:
nagcmd:x:502:nagios
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked