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

Error: Could not stat() command file ‘/var/lib/nagios3/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.

Return from whence you came

 

Just do the following

root@nagios:~# ls -l /var/lib/nagios3/rw/nagios.cmd
prw-rw---- 1 nagios nagios 0 Aug 11 22:27 /var/lib/nagios3/rw/nagios.cmd
root@nagios:~# chmod -R g+x /var/lib/nagios3/rw
root@nagios:~# ls -l /var/lib/nagios3/rw/nagios.cmd
prw-rwx--- 1 nagios nagios 0 Aug 11 22:27 /var/lib/nagios3/rw/nagios.cmd
root@nagios:~# service nagios3 restart

Also change group of the file

root@nagios:~# ls -l /var/lib/nagios3/rw/nagios.cmd
prw-rw---- 1 nagios nagios 0 Aug 11 22:27 /var/lib/nagios3/rw/nagios.cmd
root@nagios:~# chown nagios:www-data /var/lib/nagios3/rw/nagios.cmd

And also, you may need to do the following and restart apache afterwards

root@nagios:~# usermod -G nagios www-data
root@nagios:~# service apache2 restart

Note: This tutorial is written keeping in mind Ubuntu distribution, on CentOS, things are a little different

12 thoughts on “Error: Could not stat() command file ‘/var/lib/nagios3/rw/nagios.cmd’!

  • Billy Kan

    I have the same issue when having a fresh installation of Naigos Core 3.4.1 on Centos 6.3.

    Can you or someone help to resolve the issue?

    Billy

      • Manish

        I have changed ownership to Apache and it doesn’t work. Surprisingly I have ownership set to nagcmd on Ubuntu and it worked without changing ownership to ‘www-data’. Can you help me with this error. I get this when I am trying to enable notification or send custom notification.

  • Rainer

    Ab my system (Debian 2.6.32-46) I had to changed the permissions of the directory /var/lib/rw and not the file /var/lib/rw/nagios.cmd.
    The explanation is given in the file /etc/nagios3/nagios.cfg (in this file also the path for the command file can be set):
    # Permissions should be set at the directory level instead of on the file, as the file is deleted every time its contents are processed.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.