Fixing Nagios “error: Could not stat() command file”

One common configuration issue with Nagios 3 running on Ubuntu is getting the Service Commands menu to work correctly in the web portal.

By default, it is visible in the UI, but disabled on the server backend. In Ubuntu, you will recieve the cryptic error Could not stat() command file pointing to /var/lib/nagios3/rw/nagios.cmd. This can be fixed with the following steps:

sudo nano /etc/nagios3/nagios.cfg

Ensure the following value is set: check_external_commands=1

We now need to add the www-data user to the nagios group:

sudo usermod -a -G nagios www-data

We now need to grant execute permission to the nagios group on the following: /var/lib/nagios3/rw

sudo chmod g+x /var/lib/nagios3/rw

We now need to restart Nagios and Apache

sudo systemctl restart nagios3.service
sudo systemctl restart apache2.service

Leave a Reply

Your email address will not be published.

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