Nagios Installation and Configuration ===================================== Notes: ------ * Commands preceded with "$" imply that you should execute the command as a general user - not as root. * Commands preceded with "#" imply that you should be working as root. * Commands with more specific command lines (e.g. "RTR-GW>" or "mysql>") imply that you are executing commands on remote equipment, or within another program. Exercises --------- PART I ---------------- 0. Log in to your virtual machine as the sysadm user. 1. Install Nagios Version 3 --------------------------- Become the root user: $ sudo bash # apt-get install nagios3 nagios3-doc During installation you will be prompted for the "Nagios web administration password:" - This will be for the Nagios user "nagiosadmin". When prompted enter in ╥afnog╙ as the password. Note: if you have not already done so, you may be asked to configure the Postfix Mail Transport Agent during the Nagios installation process. Just accept the default "Internet Site". 2. See Initial Nagios Configuration ------------------------------------ Open a browser, and go to your machine like this: http://pcX.sse.ws.afnog.org/nagios3/ At the login prompt, login as: User Name: nagiosadmin Password: afnog Click on the "Hosts" link on the left of the initial Nagios page to see what has already been configured. 3. Update the File hostgroups_nagios2.cfg ----------------------------------------- # cd /etc/nagios3/conf.d # nano hostgroups_nagios2.cfg The file contains some default entries. Locate the line starting with: ΓÇ£# A list of your Debian GNU/Linux serversΓÇ¥ Add 5 servers to be monitored so that the entry looks like follows: # A list of your Debian GNU/Linux servers define hostgroup { hostgroup_name debian-servers alias Debian GNU/Linux Servers members localhost,server1,server2,server3,server4,server5 } Now save and exit the from the file. 4. Add Routers and Servers -------------------------------- We will create two files, routers.cfg and servers.cfg and make entries for the hardware in our classroom. 5a. Creating the routers.cfg file --------------------------------- We will have 2 routers and assume that one router is the external device in the network gw-rtr-1 and that to get to it, one must go to gw-rtr-2. We will define that by having gw-rtr-1 as the parent of gw-rtr-2. Remember, COPY and PASTE! # nano routers.cfg define host { use generic-host host_name gw-rtr-1 alias Classrooom Gateway Router address 197.4.11.140 } define host { use generic-host host_name gw-rtr-2 alias Classrooom Gateway Router address 197.4.11.139 parents gw-rtr-1 } Now save and exit from the file. 5b. Creating the servers.cfg File ----------------------------- Now we will create entries for 5 servers. Below we give you the first few entries. You can complete the file with as many Servers as you wish to add. We recommend that, at least, you add the 5 PCs and define gw-rtr-2 as the parent of each server (remember to COPY and PASTE!): # nano servers.cfg define host { use generic-host host_name server1 alias pc1 address pc1.sse.ws.afnog.org parents gw-rtr-2 } define host { use generic-host host_name server2 alias pc2 address pc2.sse.ws.afnog.org parents gw-rtr-2 } define host { use generic-host host_name server3 alias pc3 address pc3.sse.ws.afnog.org parents gw-rtr-2 } define host { use generic-host host_name server4 alias pc4 address pc4.sse.ws.afnog.org parents gw-rtr-2 } define host { use generic-host host_name server5 alias pc5 address pc5.sse.ws.afnog.org parents gw-rtr-2 } You can save and exit from the file now, or you can continue to add more PC entries. If you have not added PCs for your group be sure to do that before you exit from the file. STEPS 6a - 6c SHOULD BE REPEATED WHENEVER YOU UPDATE THE CONFIGURATION! ======================================================================= 6a. Verify that your configuration files are OK ----------------------------------------------- # nagios3 -v /etc/nagios3/nagios.cfg ... You should get some warnings like : Checking services... Checked 7 services. Checking hosts... Warning: Host 'gw-rtr-1ΓÇÖ has no services associated with it! etc.... ... Total Warnings: N Total Errors: 0 Things look okay - No serious problems were detected during the check. Nagios is saying that it's unusual to monitor a device just for its existence on the network, without also monitoring some service. 6b. Reload/Restart Nagios ------------------------- # service nagios3 restart HINT: You will be doing this a lot. If you do it all on one line, like this, then you can hit cursor-up and rerun all in one go: 6c. Verify via the Web Interface -------------------------------- Go to the web interface (http://pcX.sse.ws.afnog.org/nagios3) and check that the hosts you just added are now visible in the interface. Click on the "Hosts" item on the left of the Nagios screen to see this. You may see it in "PENDING" status until the check is carried out. 7. View Status Map -------------------- Go to http://pcX.sse.ws.afnog.org/nagios3 Click on the "Map" item on the left. You should see all your hosts with the Nagios process in the middle with gw-rtr-2 in the middle PART II Configure Service check for DNS and Radius ----------------------------------------------------------------------------- 0. Configuring Now that we have our hardware configured we can start telling Nagios what services to monitor on the configured hardware, how to group the hardware in interesting ways, how to group services, etc. 1. Associate a service check for our servers. We will monitor 2 services: DNS and Radius # nano hostgroups_nagios2.cfg - add the following at the end of the file: # A list of your DNS servers define hostgroup { hostgroup_name dns-servers alias DNS servers members localhost,server1,server2,server3,server4,server5 } # A list of your Radius servers define hostgroup { hostgroup_name radius-servers alias Radius servers members localhost,server1,server2,server3,server4,server5 } # A list of your Routers servers define hostgroup { hostgroup_name my-routers alias Routers members gw-rtr-1,gw-rtr-2 } # A list of your Web servers define hostgroup { hostgroup_name web-servers alias Web servers members localhost,server1,server2,server3,server4,server5 } # A list of your HTTPS servers define hostgroup { hostgroup_name https-servers alias HTTPS servers members localhost,server1,server2,server3,server4,server5 } # A list of your EMAIL servers define hostgroup { hostgroup_name email-servers alias EMAIL servers members localhost,server1,server2,server3,server4,server5 } Exit and save the file. Now edit services-nagios.cfg and add the new service for DNS and Radius check # nano services_nagios2.cfg # check that DNS services are running define service { hostgroup_name dns-servers service_description DNS check_command check_dns use generic-service notification_interval 0 ; set > 0 if you want to be renotified } # check that Radius services are running define service { hostgroup_name radius-servers service_description Radius check_command check_radius use generic-service notification_interval 0 ; set > 0 if you want to be renotified # check that EMAIL services are running define service { hostgroup_name email-servers service_description EMAIL Service check_command check_smtp use generic-service notification_interval 0 ; set > 0 if you want to be renotified } # check that Web services are running define service { hostgroup_name web-servers service_description HTTP Service check_command check_http use generic-service notification_interval 0 ; set > 0 if you want to be renotified } # check that Web services are running define service { hostgroup_name https-servers service_description HTTPS service check_command check_https use generic-service notification_interval 0 ; set > 0 if you want to be renotified } Verify that your changes are OK: # nagios3 -v /etc/nagios3/nagios.cfg Restart Nagios to see the new service association with your host: # service nagios3 restart Click on the "Services" link in the Nagios web interface to see your new entries ========ADDITIONAL - Configuring the map icons====== Nags ships with a few logos for generic devices like routers and switches that will appear on the map. Let us change the icon for the 2 routers # nano extinfo_nagios2.cfg define hostextinfo{ hostgroup_name my-routers notes Routers # notes_url http://webserver.localhost.localdomain/hostinfo.pl?host=netware1 icon_image base/router40.png icon_image_alt Debian GNU/Linux vrml_image router40.png statusmap_image base/router40.gd2 } Save and Exit the file Check that the config is ok #nagios3 -v /etc/nagios3/conf.d/nagios.cfg Then reload Nagios #service nagios3 restart