Nagios exercise
PART I
-----------------------------------------------------------------------------
1. Install Nagios
Do this as root.
# apt-get install nagios2
- You will be asked for a password for the nagios admin Web user
- remember it!
Now do this so that we can have pretty icons
# apt-get install nagios-images
2. Create the Web user password file:
# htpasswd -c /etc/nagios2/htpasswd.users nagiosadmin
New password:
Re-type new password:
2. You should already have a working Nagios!
- Open a browser, and go to
http://localhost/nagios2/
- At the login prompt, login as:
user: nagiosweb
pass:
3. Let's look at the interface together...
# cd /etc/nagios2/
# ls -l
-rw-r--r-- 1 root root 1598 2007-09-01 00:03 apache2.conf
-rw-r--r-- 1 root root 9573 2006-12-20 22:20 cgi.cfg
-rw-r--r-- 1 root root 4653 2006-12-20 22:20 commands.cfg
drwxr-xr-x 2 root root 4096 2007-09-01 00:03 conf.d
-rw-r--r-- 1 root root 26 2007-09-01 00:05 htpasswd.users
-rw-r--r-- 1 root root 30431 2006-12-20 22:20 nagios.cfg
-rw-r----- 1 root nagios 1293 2006-12-20 22:19 resource.cfg
drwxr-xr-x 2 root root 4096 2006-12-20 22:20 stylesheets
# ls -l conf.d/
-rw-r--r-- 1 root root 1687 2006-12-20 22:19 contacts_nagios2.cfg
-rw-r--r-- 1 root root 413 2006-12-20 22:19 extinfo_nagios2.cfg
-rw-r--r-- 1 root root 1152 2006-12-20 22:19 generic-host_nagios2.cfg
-rw-r--r-- 1 root root 1803 2006-12-20 22:19 generic-service_nagios2.cfg
-rw-r--r-- 1 root root 210 2007-09-01 00:03 host-gateway_nagios2.cfg
-rw-r--r-- 1 root root 976 2006-12-20 22:19 hostgroups_nagios2.cfg
-rw-r--r-- 1 root root 2163 2006-12-20 22:19 localhost_nagios2.cfg
-rw-r--r-- 1 root root 806 2006-12-20 22:19 services_nagios2.cfg
-rw-r--r-- 1 root root 1609 2006-12-20 22:19 timeperiods_nagios2.cfg
PART II
-----------------------------------------------------------------------------
1. According to what we saw in class, let's add a new host
- Pick any PC in the room, i.e. something other than pc10!
# cd /etc/nagios2/conf.d/
# vi pc10.cfg
define host {
use generic-host
host_name pc10
alias PC 10 at Apricot
address _______________ [pc10'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 apricot-pcs
alias Apricot PCs
members pc10
}
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, apricot-pcs
4. Verify that your configuration file is OK:
# nagios2 -v /etc/nagios2/nagios.cfg
... You should get :
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the check.
5. Reload Nagios
# /etc/init.d/nagios2 reload
6. Go to the web interface (http://localhost/nagios2) and check the host
you just added
7. Add ALL the PCs in the room!
- Add all the PCs in the room to the config
- Check HTTP for all PCs in the room
- Remember to verify the configuration file!
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!
8. Let's make a new plugin!
- We'll do this together.