Error: Could not open command file '/usr/local/nagios-4.0.7/

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.
tokiwinter
Posts: 7
Joined: Fri Jul 11, 2014 6:33 am

Error: Could not open command file '/usr/local/nagios-4.0.7/

Post by tokiwinter »

Hi,

I'm receiving the well-known "Error: Could not open command file '/usr/local/nagios/var/rw/nagios.cmd' for update!" error message on Nagios Core 4.0.7 on Ubuntu 14.04 LTS running under Nginx.

Code: Select all

# ls -ld /usr/local/nagios/var/rw
drwxrwsr-x 2 nagios nagcmd 4096 Jul 11 21:32 /usr/local/nagios/var/rw
# ls -l /usr/local/nagios/var/rw
total 0
prw-rw---- 1 nagios nagcmd 0 Jul 11 21:32 nagios.cmd
srw-rw---- 1 nagios nagcmd 0 Jul 11 21:32 nagios.qh
# groups www-data
www-data : www-data nagcmd
I can su to the www-data user and create files in that directory, as well as echo data to the pipe.

Any ideas as to where the problem may be? I'm pretty sure everything is set up correctly and I've performed many Nagios installations previously without encountering this problem.

I've tried it with Apparmor disabled too in case that was a problem, which it isn't.

Cheers,
Toki
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Error: Could not open command file '/usr/local/nagios-4.

Post by sreinhardt »

I just want to start by clarifing, are you seeing:

"Error: Could not open command file '/usr/local/nagios/var/rw/nagios.cmd' for update!"
OR
"Error: Could not open command file '/usr/local/nagios-4.0.7/var/rw/nagios.cmd' for update!"

I only ask because the title seems rather specific and different from what you were showing in the post.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
tokiwinter
Posts: 7
Joined: Fri Jul 11, 2014 6:33 am

Re: Error: Could not open command file '/usr/local/nagios-4.

Post by tokiwinter »

Thanks for the reply. I'm seeing ""Error: Could not open command file '/usr/local/nagios-4.0.7/var/rw/nagios.cmd' for update!"" - but /usr/local/nagios is just a symlink to /usr/local/nagios-4.0.7.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Error: Could not open command file '/usr/local/nagios-4.

Post by abrist »

Is the nagcmd group configured?

Code: Select all

grep nag /etc/group
Did you configure with the command grouop option?

Code: Select all

./configure --with-command-group=nagcmd
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
tokiwinter
Posts: 7
Joined: Fri Jul 11, 2014 6:33 am

Re: Error: Could not open command file '/usr/local/nagios-4.

Post by tokiwinter »

Hi,

The group is configured:

Code: Select all

# grep nagcmd /etc/group
nagcmd:x:1001:nagios,www-data
And I did configure with the --with-command-group option:

Code: Select all

# history | grep -- --with-command-group
   70  ./configure --prefix=/usr/local/nagios-4.0.7 --sysconfdir=/etc/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios --with-command-group=nagcmd
As a workaround, I can:

Code: Select all

 chgrp www-data nagios.cmd
But it should work fine without that - any more ideas?

Cheers,
Toki
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Error: Could not open command file '/usr/local/nagios-4.

Post by lmiltchev »

70 ./configure --prefix=/usr/local/nagios-4.0.7 --sysconfdir=/etc/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios --with-command-group=nagcmd
You would normally use

Code: Select all

./configure --with-command-group=nagcmd
when you compile nagios, and

Code: Select all

./configure --with-nagios-user=nagios --with-nagios-group=nagios
when you compile nagios plugins... It seems you used them all in one go... Is there any reason why you used "--with-command-user=nagios"?
Be sure to check out our Knowledgebase for helpful articles and solutions!
tokiwinter
Posts: 7
Joined: Fri Jul 11, 2014 6:33 am

Re: Error: Could not open command file '/usr/local/nagios-4.

Post by tokiwinter »

Thanks for getting back to me. I saw '--with-command-user=nagios' as a configure option and used it - although looking at the Quickstart guide it seems this isn't required and is perhaps the cause of my issue. Should I recompile Nagios with these options (including the --with-nagios-group and --with-nagios-user options) removed from the configure?
tokiwinter
Posts: 7
Joined: Fri Jul 11, 2014 6:33 am

Re: Error: Could not open command file '/usr/local/nagios-4.

Post by tokiwinter »

Looking at the output at the end of configure, it defaults to using these values anyway:

Code: Select all

 
...
General Options:
 -------------------------
        Nagios executable:  nagios
        Nagios user/group:  nagios,nagios
       Command user/group:  nagios,nagcmd
...
I've reconfigured after a make clean with:

Code: Select all

./configure --prefix=/usr/local/nagios-4.0.7 --with-command-group=nagcmd --sysconfdir=/etc/nagios
Then make all, make install, make install-commandmode

And the problem persists:

Code: Select all

Error: Could not open command file '/usr/local/nagios-4.0.7/var/rw/nagios.cmd' for update!
Cheers,
Toki
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Error: Could not open command file '/usr/local/nagios-4.

Post by abrist »

Does your nagios.cfg have the correct path for the "command_file" directive?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
tokiwinter
Posts: 7
Joined: Fri Jul 11, 2014 6:33 am

Re: Error: Could not open command file '/usr/local/nagios-4.

Post by tokiwinter »

It does:

Code: Select all

# grep command_file /etc/nagios/nagios.cfg
command_file=/usr/local/nagios-4.0.7/var/rw/nagios.cmd
# ls -l /usr/local/nagios-4.0.7/var/rw/nagios.cmd
prw-rw---- 1 nagios nagcmd 0 Jul 16 11:38 /usr/local/nagios-4.0.7/var/rw/nagios.cmd
Locked