Nagios Exercises




PART I
-----------------------------------------------------------------------------

1. Install Nagios version 3
   
    Do this as root.

    # apt-get install nagios3

2. Create the Web user password file:

    # htpasswd -c /etc/nagios3/htpasswd.users nagiosadmin

New password:         
Re-type new password: 

   Please use the class password.


2. You should already have a working Nagios!

    - Open a browser, and go to

    http://localhost/nagios3/

    - At the login prompt, login as:

        user: nagiosadmin
        pass: 

3. Let's look at the interface together...

    # cd /etc/nagios3/

    # ls -l 
    -rw-r--r-- 1 root root    1882 2008-12-18 13:42 apache2.conf
    -rw-r--r-- 1 root root   10524 2008-12-18 13:44 cgi.cfg
    -rw-r--r-- 1 root root    2429 2008-12-18 13:44 commands.cfg
    drwxr-xr-x 2 root root    4096 2009-02-14 12:33 conf.d
    -rw-r--r-- 1 root root      26 2009-02-14 12:36 htpasswd.users
    -rw-r--r-- 1 root root   42539 2008-12-18 13:44 nagios.cfg
    -rw-r----- 1 root nagios  1293 2008-12-18 13:42 resource.cfg
    drwxr-xr-x 2 root root    4096 2009-02-14 12:32 stylesheets
    
    # ls -l conf.d/

	 -rw-r--r-- 1 root root 1695 2008-12-18 13:42 contacts_nagios2.cfg
	 -rw-r--r-- 1 root root  418 2008-12-18 13:42 extinfo_nagios2.cfg
	 -rw-r--r-- 1 root root 1152 2008-12-18 13:42 generic-host_nagios2.cfg
	 -rw-r--r-- 1 root root 1803 2008-12-18 13:42 generic-service_nagios2.cfg
	 -rw-r--r-- 1 root root  210 2009-02-14 12:33 host-gateway_nagios3.cfg
	 -rw-r--r-- 1 root root  976 2008-12-18 13:42 hostgroups_nagios2.cfg
	 -rw-r--r-- 1 root root 2167 2008-12-18 13:42 localhost_nagios2.cfg
	 -rw-r--r-- 1 root root 1005 2008-12-18 13:42 services_nagios2.cfg
	 -rw-r--r-- 1 root root 1609 2008-12-18 13:42 timeperiods_nagios2.cfg

    Notice that the package does not have renamed filenames for the conf.d 
    directory - they are the same files as used for the Nagios version 2
    Ubuntu package. There was an update made to the host-gateway configuration
    file so this has been renamed.

PART II
-----------------------------------------------------------------------------

1. According to what we saw in class, let's add a new host

    - Pick any PC in the room.

    # cd /etc/nagios3/conf.d/

    # vi pc1N.cfg        (Where N is some number)

define host {
    use         generic-host
    host_name   pcN
    alias       PC N at Network Design Workshop
    address     _______________       [pN's IP address here]
}

    ... Save and quit

2. Let's create a new hostgroup for the occasion, and add our host
   to it

    - Edit the file hostgroups_nagios2.cfg and add a new group:

    # vi hostgroups_nagios2.cfg

define hostgroup {
    hostgroup_name  servers
    alias           Network Design PCs
    members         pcN
}

3. Now let's associate some services to that host

    # vi services_nagios2.cfg

    - Find the section called "check that ssh services are running",
      and change the line:

hostgroup_name                  ssh-servers

    to

hostgroup_name                  ssh-servers, servers



4. Verify that your configuration file is OK:

    # nagios3 -v /etc/nagios3/nagios.cfg 

    ... You should get :

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the check.


5. Reload/Restart Nagios

    # /etc/init.d/nagios3 restart

6. Go to the web interface (http://localhost/nagios3) and check the host
   you just added


7. Add ALL the PCs at your table!

    - Add all the PCs at your table to the config

    - Remember to verify the configuration file!

    - I suggest that you create a single config file called pcs.cfg
      to do this.

    NOTE:

    - This requires a bit of planning, but you should have all the elements
      for doing this...

    - Think well about the logical structure of the files -- it should be
      possible for you to do this without doing too much work!









Last update 24 July 2009 by HA