skip navigation

www.Hilands.com


Content:: Installing Nagios

Installing Nagios on Debian



Table of Contents
Installing Nagios Server

For the Nagios server we will run # apt-get install nagios3-core nagios-plugins nagios-nrpe-plugin


Make sure we can see the help documents on the nagios page. # apt-get install nagios3-doc

Test the installation by going to the website http://<ipaddress>/nagios3/
The default administrative user is nagiosadmin

* If you are not prompted for a username and password you may need to create one with the htpasswd command. # htpasswd -c /etc/nagios3/htpasswd.users nagiosadmin
Configure Nagios Server

The configurations for the Nagios Server can be found in /etc/nagios3.

We will need to add our new hosts in the /etc/nagios3/conf.d/ directory. # cd /etc/nagios3/conf.d/ Create a new file, I generally name mine after the DNS record for the server and append .cfg to it. # nano server1.example.com.cfg The first portion of the file contains the information on the host. This will do a simple ping test to see if the system is alive.
define host{
        use     generic-host
        host_name       server1.example.com
        alias           server1
        address 192.168.0.1
}
We can add additional services by configuring the plugins. You can find your plugins in the /usr/lib/nagios/plugins directory.
define service{
        use     generic-service
        host_name       server1.example.com
        service_description     HTTP-Server
        check_command   check_http
}
define service{
        use     generic-service
        host_name       server1.example.com
        service_description     HTTPS-Server
        check_command   check_https
}
If a plugin doesn't exist or you'd like to simply check to see if the tcp port is alive we can use check_tcp
define service{
        use     generic-service
        host_name       server1.example.com
        service_description     SSH-PortAlive
        check_command   check_tcp!22
}
Using check_http will do a thorough validation of the HTTP port and validate return data. If you have a server that is protected by an htaccess password you may want to check to see if the port is alive instead.
define service{
        use     generic-service
        host_name       server1.example.com
        service_description     HTTP-PortAlive
        check_command   check_tcp!80
}


For our contacts we will need to edit /etc/nagios3/conf.d/contacts_nagios2.cfg. # nano contacts_nagios2.cfg
Simply copy the default root contact
Change the contact_name, alias, and email field.(in red)
define contact{
        contact_name                    phil
        alias                           phil
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,r
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
        email                           phil@hilands.com
        }
In the define contactgroup simply add your new contact name to the "members" section. (in red)
define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 root,phil
        }


Restart the nagios server. /etc/init.d/nagios3 restart
Installing Nagios client

For the Nagios client or client server we will run # apt-get install nagios-nrpe-server nagios-plugins
Configure Nagios Client

There are two locations for configurations. /etc/nagios /etc/init.d/nagios-nrpe-server restart
References

Last Modified: 2013-09-24