Nagios

From Gentoo Wiki
Jump to: navigation, search
Resources

Nagios offers complete monitoring and alerting for servers, switches, applications, and services.

Installation

Web server

Decide which web server will be to used and set it up:

Once finished return here to and continue reading.

USE flags

Set the proper USE flags for Nagios before it emerging it:

USE flags for net-analyzer/nagios-core Nagios core - monitoring daemon, web GUI, and documentation

apache2 Add Apache2 support global
classicui use the classic web theme local
lighttpd install www-servers/lighttpd config local
perl Add optional support/bindings for the Perl language global
vim-syntax Pulls in related vim syntax scripts global
web enable web interface local

Do not forget to enable the right USE flags for Nagios plugins (net-analyzer/nagios-plugins).

Emerge

Finally install net-analyzer/nagios:

root #emerge --ask net-analyzer/nagios

Configuration

Apache

Enable the Nagios module for Apache:

FILE /etc/conf.d/apache2
APACHE2_OPTS="... -D NAGIOS"

Since Nagios requires PHP for its web interface, it may needed to be enabled as well if it has not been previously. One way is to simply add -D PHP5 to APACHE2_OPTS and edit /etc/php/apache2-php<YOUR_PHP_VERSION>/php.ini This should be fine unless PHP is needed for purposes other than hosting Nagios.

If using Apache 2.4 (which is still marked unstable as of April 2015) the /etc/apache2/modules.d/99_nagios3.conf file may need to be modified to fit the new authorization directives of Apache 2.4.

Remember to add the apache user to group nagios:

root #usermod -a -G nagios apache

Restart the Apache service to have it recognize the group change:

root #rc-service apache2 restart

Lighttpd

Enable the Nagios configuration for Lighttpd:

FILE /etc/lighttpd/lighttpd.conf
include "nagios.conf"

Configure authentication. More information on how to set this up can be found in the Lighttpd documentation.

FILE /etc/lighttpd/nagios.conf
$HTTP["url"] =~ "nagios" {
    auth.backend ="plain"    # The password is stored as plain text as user:password in...
    auth.backend.plain.userfile = "/etc/nagios/passwd"  # this file
    auth.require = ( "" => (
        "method" => "digest",
        "realm" => "nagios",
        "require" => "user=nagiosadmin"
        )
    )
    setenv.add-environment = ( "REMOTE_USER" => "user" )
}

Restart the Lighttpd service:

root #rc-service lighttpd restart

Permissions

Add the user name(s) to the nagios group, whom are allowed access to the Nagios service:

root #gpasswd -a <USER_NAME> nagios

Once done, completely sign out from all shells and re-login for the update to apply.

Boot service

Start Nagios:

root #rc-service nagios start

To start Nagios at boot time, add it the default runlevel:

root #rc-update add nagios default

Testing

Open a browser and navigate to http://localhost/nagios

Troubleshooting

See also