External commands - bug?



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.
drwxrwsr-x 2 nagios nagiocmd 80 Sep 5 09:52 rw
drwxrwsr-x 2 nagios nagiocmd 80 Sep 5 09:52 rw

Permissions on /usr/local/nagios/var/rw
wsr-x 2 nagios nagiocmd 80 Sep 5 09:52 rw

Apache user is nobody and tail /etc/group :


Everything is by the book but still it doesnt’ work. Of course, apache server was restarted… (about million of time *sigh)


Mine looks like this

prw-rw---- 1 nagios nagcmd 0 Sep 6 14:16 nagios.cmd

Try that.


Have you got any Further with this issue ???


When first starting on Nagios I saw this and like you incorrectly attempted to create the file. The file should actually be created by the Nagios start up.

What I found eventually was that doing the restart option of the nagios init script was the problem. The restart sometimes starts Nagios before it has actually finished stopping all the processes. On my FreeBSD I do:

/usr/local/etc/rc.d/nagios.sh stop
Then do:
ps -aux |grep nagios

Only after the ps shows no nagios commands (other than my grep) do I then do:
/usr/local/etc/rc.d/nagios.sh start

You may need to actually delete the file you created for the above to work.

P.S. Of course what I really need to do is edit the restart section of the script to do this test for me but just never got around to it.


Sorry for delay.


mine is the same
prw-rw---- 1 nagios nagiocmd 0 Sep 14 11:49 nagios.cmd

nagios.cmd IS created by nagios itself and deleted when nagios is killed.
Did what you said but still the same.


I had the same problem and fixed it by making sure the group that was set in nagios.cfg was the actual group that nagios was using, otherwise i would have to chown -R nagios.nagiocmd the /usr/local/nagios/var/rw/ every time to get it to work.


Yeah, the group is nagios and the user is nagios… nagiocmd is member of nagios and nobody … God damn this annoys me big time.


edit your /etc/group
make sure that nagios and the apache user are members of the group nagiocmd. By the sounds of your last post, you have the user nagioscmd as a member of the group nagios and nobody.
From your first post though, it looked ok.
Follow docs step by step again.
First make sure you know what user apache is running as. If you get that wrong, you aren’t going to get this working.
ps -ef|grep httpd
apache 24944 2895 0 Sep11 ? 00:00:00 /usr/sbin/httpd
So my apache is running with the user apache, not nobody. What is your output of ps?
Edited Thu Sep 15 2005, 06:25AM ]


Here is what my /etc/group looks like if that will help



That looks fine, if and only if, nagios is the user running nagios, and nobody is the user running apache.
Why is there a www-data user in there?


Ok i did it once again, as instruced inapache (user is nobody, checked) and nagios (checked in nagios.cfg) ARE members of group nagiocmd. Again, here is the tail of /etc/group :

ps -ef | grep httpd
nobody 30440 30437 0 09:49 ? 00:00:00 /usr/local/apache2/bin/httpd -k start

ls -la /usr/local/nagios/var/

drwxrws— 2 nagios nagiocmd 80 Sep 16 09:49 rw


Any1? Please. I’m desperate. Tried every possible combination that i could remember of but no success…


In your first post "
Permissions on /usr/local/nagios/var/rw
wsr-x 2 nagios nagiocmd 80 Sep 5 09:52 rw"
But now the permissions are not the same.
What exactly are your permissions?
Please go over this doc. You must have a type or something.


Your apache error log will tell you alot about your problem.


Yeah, the permissions are different because in the first post i gave you the permissions of /usr/local/nagios/var and in the second i gave you the perm. of the nagios.cmd file itself…
I did it once again, followed that link. This must be the 10th time i did it and it’s still the same.
There is nothing in the apache error log.
Once again here are my permissions on the /usr/local/nagios/var/ directory:

drwxrws— 2 nagios nagiocmd 80 Sep 23 09:41 rw

tail /etc/group :

tail /etc/passwd :

ps aux | grep httpd :
nobody 18718 0.0 0.3 11396 7488 ? S 09:40 0:00 /usr/local/apache2/bin/httpd -k start

and the apache error log since restarting :
[Fri Sep 23 09:40:40 2005] [notice] SIGHUP received. Attempting to restart
[Fri Sep 23 09:40:40 2005] [notice] Digest: generating secret for digest authentication …
[Fri Sep 23 09:40:40 2005] [notice] Digest: done
[Fri Sep 23 09:40:40 2005] [notice] Apache/2.0.54 (Uni:evil: DAV/2 PHP/4.4.0 mod_perl/2.0.1 Perl/v5.8.5 configured – resuming normal operations
[Fri Sep 23 09:41:03 2005] [error] [client] File does not exist: /usr/local/apache2/htdocs/favicon.ico, referer: logikom.net/nagios/


So when you try to use the external command file, you get no error in apache?
tail -f /etc/httpd/logs/error_log
Now that you are watching the log file, try to use the external command.
Edited Fri Sep 23 2005, 02:50AM ]


Yes, that is correct. No errors in apache when try to use the ext. command.
Tried what you said but nothing happened… There are NO errors… But one thing. The error now is different than before. Now it’s :

Error: Could not stat() command file ‘/usr/local/nagios/var/rw/nagios.cmd’!

The external command file may be missing, Nagios may not be running, and/or Nagios may not be checking external commands.

An error occurred while attempting to commit your command for processing.

nagios IS runing :

ps ax | grep nagios
18829 ? Ss 0:12 nagios -d /usr/local/nagios/etc/nagios.cfg

and there is nagios.cmd in /usr/local/nagios/var/rw/


check_external_commands = ??? in your nagios.cfg


check_external_commands=1 in the nagios.cfg


Still waiting for someone to give me an idea…