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

System: Ubuntu 9.10 | Nagios 3.x

This is another post that is more of a note to myself than anything else. Been doing a lot of Nagios configuring and decided to implement the ability to push commands from the web interface. I followed the basic instructions to configure "External Commands" but after doing and going to the web interface to test it, I got the following error message;

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.

The file was there so I did what any good geek should do, I did a quick google search. The closet thing I could find was some commands to fix the issue on Debian systems. Since I was running Ubuntu, which is for all intensive purposes Debian, I figured I would try it.  So I ran the following set of command;

sudo /etc/init.d/nagios3 stop
sudo dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw
sudo dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3
sudo /etc/init.d/nagios3 start

This worked like a charm and the web interface began accepting commands.

  • kub

    on ubunto 10.4

    sudo /etc/init.d/nagios3 stop
    sudo dpkg-statoverride –-update –-add nagios www-data 2710 /var/lib/nagios3/rw
    sudo dpkg-statoverride –-update –-add nagios nagios 751 /var/lib/nagios3
    sudo /etc/init.d/nagios3 start

    • Rumpole

      Unfortunately it’s stopped working for me 🙁 Updating my CentOS server using Yum Upgrade, then re-installed dpkg-statoverride, and re-run the commands. Nagios Web Interface is still unable to write to the cmd file 🙁

  • Alex Yarochkin

    Works for me!

  • Love C4

    I tried given above cmd but it is not working, it is showing error as command not found.

  • Love C4

    I need on CENTOS 5.5

    • Anonymous

      I assume the command you are referring to is dpkg-statoverride. Haven’t needed to do this on a CENTOS (or any other Red Hat derived) machine. Can you install from yum? Is it include in the dpkg package? I did do a quick Google for dpkg-statoverride and got a ton of results.

      When I get sometime I will spin up a CentOS VM and see if I can figure out what package you need.

  • Niraj8241

    works for me

  • Leon

    Still helps after all these years… 

    • shocm

      Awesome to hear. Glade it was helpful.

  • Billy Kan

    I am using Naigos Core 3.4.1 on Centos 6.3.  How should I fix the error?


  • Gerard

    Cleanest description I’ve seen ‘in the wild’ .. thanx a lot!