Here we are again, back witho ur old friend Nagios. If you've been following you know I have covered quite a bit of ground with this outstanding network monitoring tool (check all Ghacks Nagios articles). There is a reason for this, Nagios is an incredible tool. But for many of you, you might have come across an error when attempting to run a few of the more powerful features. This error happens when you attempt to use any of Nagios' external commands. But what are these external commands? Nagios is capable of running commands from external applications. This allows Nagios to expand farther than it could otherwise.
But when you see this error you know that your Nagios installation isn't able to use any external commands. Fear not, this error is simple to over come, and in this article I am going to walk you through the fix.
This how to will assume that you have a working Nagios installation as well as root or sudo access to your server. This article also assumes you have tried to use features that require external commands. If not, let's take a look at how.
If you point your browser to your Nagios server, click on the Service Detail link and then click on one of the services (such as HTTP or SSH). On this page you will see the Service Commands box. If you click on one of those links and you get the error - you need the fix!
Saved by zero right? Sort of. The first thing to check is in the /etc/nagios3/nagios.cfg file. Look for a line like:
If that line is either commented out or set to "0", change it to look like the entry above. Once you have done that, save and close the file. Now restart Nagios with the command sudo /etc/init.d/nagios3 restart. You're not done yet.
The next step is to open up the /etc/nagios3/cgi.cfg file. You will most likely find these two lines:
After these two lines, you need to add the following:
Save and close this file. Now restart Apache with the command sudo /etc/init.d/apache2 restart.
Still not done. Now you have to make a slight change to /etc/groups. Open up this file, with your favorite text editor, and look for a line that looks like:
Change this line to look like:
Now save and close this file. Almost done. But the next step is a bit more challenging the previous.
In the directory /var/lib/nagios3/rw is a file nagios.cmd. This file most likely doesn't have the correct permissions set. By default only the user nagios has access to these files. Since we can't change this to the www-data user (it would break other features of Nagios), we need to just add the executable group bit to the file like so:
sudo chmod g+x /var/lib/nagios/rw
That's it. Now go back to that Service Commands section and click on one of the links. You should no longer get that error.
You may have thought your Nagios installation was pretty useful. Now that you can execute external commands, you will find your Nagios install to be far more useful.
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.