I.T. Security and Linux Administration

Mar 21 2011   2:35PM GMT

Installing Nagios on Linux Part 2: Installing the Plugins

Eric Hansen Eric Hansen Profile: Eric Hansen

In part one of this series, Installing Nagios Part 1: Handling the Core, I talked about how to install Nagios’ core to get the fundamentals up and running.  This time, I will be covering installing the plug ins that are required to monitor systems and do other essential things.

Step 1: Download and Extract

There’s only one download for the essential plugins, which makes this task a lot easier.

  1. Download nagios-plugins-1.4.15.tar.gz
    1. wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
  2. Extract the tar.gz file
    1. tar xf nagios-plugins-1.4.15.tar.gz
  3. Go to the newly created directory
    1. cd nagios-plugins-1.4.15/
Step 2: Configure and Make
This is a pretty short step, and takes a bit of less time here than doing the core package.
  1. ./configure –with-nagios-user=nagios –with-nagios-group=nagios
    1. There’s more configuration options available, but this is the essential list that I feel is needed
  2. make && make install
    1. If you’ve never used the “&&” option on CLI, it basically runs the first command (“make”), and ONLY IF that succeeds, it’ll run the other command (“make install”).
After this, the plug ins will be ready to use.  We only have a couple of more steps before Nagios is up and working as it should.
Step 3: Configure Contact Information and Web Server (Apache and Lighttpd)
The first step will be to configure the contact information for nagiosadmin.  This is done because alerts will be sent from this account, and you don’t want your SMTP server to be continuously keeping bad e-mails in the queue.  After that, we’ll configure both Apache and Lighttpd to use Nagios.  Since they both do things differently, and Lighttpd is used among popular websites (i.e.: YouTube, various BitTorrent tracker sites, etc…), it should be noted here.
  1. cd /usr/local/nagios/etc/objects
  2. Open up “contacts.cfg” in your editor (I use nano personally)
  3. Edit line 35, where it asks for the e-mail.  I put in a generic alerts e-mail here, but you can put whatever you want in it really.
After that, save the file and exit out of the editor.  Since Apache is a major web server to this date, I’ll cover how to configure Nagios with that first, then with Lighttpd.  Before doing this, make sure that Nagios isn’t running (/etc/init.d/nagios stop).
  1. Make note of line 22 (“AuthUserFile”) in /etc/httpd/conf.d/extra/nagios.conf.  Mine says /usr/local/nagios/etc/htpasswd.users but yours could be different.
    1. If /etc/httpd/conf.d/extra/nagios.conf doesn’t exist, check to see if nagios-3.2.3/sample-config/httpd.conf exists.  If it does, move it to /etc/httpd/conf/extra/nagios.conf
  2. Use htpasswd to generate an account that’ll be able to access Nagios
    1. htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
      1. nagiosadmin can be any username really, as the default nagios.conf file only asks for a valid user
  3. Edit httpd.conf to include nagios.conf
    1. Near the bottom of httpd.conf, there’ll be a bunch of “Include […].conf” lines, somewhere in there, put “Include conf/extra/nagios.conf” without quotes.
  4. Make sure /usr/local/nagios is owned by nagios:nagios by doing this: chown -R nagios:nagios /usr/local/nagios
  5. (Re)start httpd
    1. /etc/init.d/httpd restart
Here’s how to do this for Lighttpd:
  1. Edit your lighttpd.conf file, and make sure that you have the following modules enabled (uncommented):
    1. mod_alias
    2. mod_auth
    3. mod_cgi
  2. Configure alias.url to be like this:
    1. alias.url = ( “/nagios/cgi-bin” => “/usr/local/nagios/sbin”, “/nagios” => “/usr/local/nagios/share” )
  3. Make sure Lighttpd doesn’t run Nagios’ compiled CGI programs through Perl
    1. $HTTP[“url”] =~ “^/nagios/cgi-bin” { cgi.assign = ( “” => “” ) }
  4. Since Lighttpd doesn’t come with a htpasswd program, I put a script at the bottom of this post for a simple one you can use (it’s from the following post: Minimalistic HIDS: OSSEC)
    1. htpasswd “nagiosadmin” “Nagios Access” “nagiosadmin password” >> /etc/lighttpd/nagios.users
      1. Replace “nagiosadmin password” with the account’s password, but remember to keep the quotes there
  5. Configure Lighttpd for authentication
      $HTTP["url"] =~ "nagios" {
      auth.backend = "htpasswd"
      auth.backend.htpasswd.userfile = "/etc/lighttpd/nagios.users"
      auth.require = ( "" => (
      "method" => "basic",
      "realm" => "nagios",
      "require" => "user=nagiosadmin"
  6. Restart Lighttpd
      1. /etc/init.d/lighttpd restart
After you configure your web server, you should be able to access http://localhost/nagios/ with the username nagiosadmin and the password you assigned it to the password file.  If you’re getting an error saying that the documents can’t be found, make sure that /usr/local/nagios/ is owned by nagios (including the files inside of share).  Also make sure you have PHP set up for your server, and that the configuration files are correctly set.

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: