Share, , Google Plus, Pinterest,

Print

Posted in:

Nagios Error: Could not open command file for update

Are you using Nagios is IT Infrastructure Monitoring Tool and you are seeing this Nagios error Error: Could not open command file ‘/usr/local/nagios/var/rw/nagios.cmd’ for update! when trying to submit commands to your Nagios instance?

It is a common Nagios /usr/local/nagios/var/rw/ directory ownership problem on most Linux distributions. In this post we will explain how to fix this Nagios error Error: Could not open command file ‘/usr/local/nagios/var/rw/nagios.cmd’ for update! in CentOS and Ubuntu Linux distributions. There is a quick fix – an easy one-liner so you should have no problem with it!

Nagios Error: Could not open command file for update!
Nagios Error: Could not open command file for update!

Let’s fix Nagios Error: Could not open command file ‘/usr/local/nagios/var/rw/nagios.cmd’ for update!

This is a fix for CentOS 6 and Ubuntu Server 12.04 LTS. You must always stop the Nagios service before changing ownership. For CentOS 6 you need to restart Apache service also.

Fix for Ubuntu Server 12.04 LTS:

We must change the group ownership of the /usr/local/nagios/var/rw/ directory. First stop the Nagios service and then change the group ownership and start Nagios service again:

geekpeeknet@foo1:~$ sudo chown -R nagios:www-data /usr/local/nagios/var/rw/

 

Fix for CentOS 6:

In CentOS 6 we must to add apache user to nagios group and restart Nagios and Apache service:

[root@foo1 nagios]# usermod -a -G nagios apache

 

The end! This should resolve your Nagios Error: Could not open command file ‘/usr/local/nagios/var/rw/nagios.cmd’ for update! error! Do not forget to restart the needed services! If you try to Enable or Disable the notifications for specific host or service in your Nagios instance after you have fixed permission issues, your command request should be submitted successfully:

Command request was successfully submitted to Nagios
Command request was successfully submitted to Nagios