How to Fix Nagios “Could not open nagios.cmd command file for update” Error

Question: When I try to do certain operation from Nagios UI, I get “Error: Could not open command file ‘/usr/local/nagios/var/rw/nagios.cmd’ for update!” error. How do I fix this?

Answer: When you perform some activities in Nagios UI (for example: Re-schedule the next check of this service), you might get the following error message in the browser:

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.

As you can imagine, this is a permission issue. Let us look at the current permission of rw directory, and nagios.cmd file.

As you see below, rw directory and nagios.cmd file has nagios as the group. Make sure the group has “rwxs” permission for the /usr/local/nagios/var/rw folder.

# ls -ld /usr/local/nagios/var/rw
drwxrwsr-x. 2 nagios nagios 4096 Jul  1 10:47 /usr/local/nagios/var/rw

# ls -l /usr/local/nagios/var/rw
prw-rw----. 1 nagios nagios 0 Jul  1 10:21 nagios.cmd
srw-rw----. 1 nagios nagios 0 Jul  1 10:47 nagios.qh

The “rw” folder and nagios.cmd file should be owned by the nagioscmd group.

First, create the nagioscmd group, and nagios and apache user to this group as shown below.

groupadd nagcmd

usermod -G nagcmd nagios

usermod -G nagcmd apache

Next, change the group using chown command to fix the issue.

chown nagios:nagcmd /usr/local/nagios/var/rw 

chown nagios:nagcmd /usr/local/nagios/var/rw/nagios.cmd

Finally, restart the Apache and Nagios, you should not get that nagios.cmd error message anymore.

But, the correct way to solve this problem is to specify the nagioscmd group when you do the ./configure during installation itself.

During Nagios installation, instead of just specifing “./configure”, you should create the nagioscmd group, assign it to apache and nagios user, and specific the following “./configure”, which will set the permission for the “rw” directory, and nagios.cmd file correctly when you do make install.

./configure --with-command-group=nagcmd

Comments on this entry are closed.

  • Jose fiungo February 21, 2014, 2:03 am

    Great.
    I did the changes that you said, it’s Ok now. Thanks.