Page 1 of 2
Error: Could not open command file '/usr/local/nagios-4.0.7/
Posted: Fri Jul 11, 2014 6:38 am
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
Re: Error: Could not open command file '/usr/local/nagios-4.
Posted: Fri Jul 11, 2014 1:04 pm
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.
Re: Error: Could not open command file '/usr/local/nagios-4.
Posted: Fri Jul 11, 2014 8:20 pm
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.
Re: Error: Could not open command file '/usr/local/nagios-4.
Posted: Mon Jul 14, 2014 11:26 am
by abrist
Is the nagcmd group configured?
Did you configure with the command grouop option?
Code: Select all
./configure --with-command-group=nagcmd
Re: Error: Could not open command file '/usr/local/nagios-4.
Posted: Tue Jul 15, 2014 2:31 am
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:
But it should work fine without that - any more ideas?
Cheers,
Toki
Re: Error: Could not open command file '/usr/local/nagios-4.
Posted: Tue Jul 15, 2014 4:19 pm
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"?
Re: Error: Could not open command file '/usr/local/nagios-4.
Posted: Tue Jul 15, 2014 8:31 pm
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?
Re: Error: Could not open command file '/usr/local/nagios-4.
Posted: Tue Jul 15, 2014 8:37 pm
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
Re: Error: Could not open command file '/usr/local/nagios-4.
Posted: Wed Jul 16, 2014 7:47 pm
by abrist
Does your nagios.cfg have the correct path for the "command_file" directive?
Re: Error: Could not open command file '/usr/local/nagios-4.
Posted: Wed Jul 16, 2014 9:29 pm
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