Nagios Installation and Configuration PART V Create More Host Groups ----------------------------------------------------------------------------- 0. In the web view, look at the pages "Hostgroup Overview", "Hostgroup Summary", "Hostgroup Grid". This gives a convenient way to group together hosts which are related (e.g. in the same site, serving the same purpose). 1. Update /etc/nagios3/conf.d/hostgroups_nagios2.cfg - For the following exercises it will be very useful if we have created or update the following hostgroups: debian-servers routers switches If you edit the file /etc/nagios3/conf.d/hostgroups_nagios2.cfg you will see an entry for debian-servers that just contains localhost. Update this entry to include all the classroom PCs, including the noc (this assumes that you created a "noc" entry in your pcs.cfg file). Remember to skip your PC entry as it is represented by the localhost entry. # editor /etc/nagios3/conf.d/hostgroups_nagios2.cfg Update the entry that says: # A list of your Debian GNU/Linux servers define hostgroup { hostgroup_name debian-servers alias Debian GNU/Linux Servers members localhost } So that the "members" parameter contains something like this. Use your classroom network diagram if in doubt. members localhost,pc1,pc2,pc3,pc4,pc5,pc6 Remember to replace the pc1 -- 6 with the pcs on your table. Be sure that the line wraps and is not on two separate lines. Otherwise you will get an error when you go to restart Nagios. Remember that your own PC is "localhost". - Once you have done this, add in two more host groups, one for routers and one for switches. Call these entries "routers" and "switches". - When you are done be sure to verify your work and restart Nagios. - Remember to skip your pc entry as it is represented by the localhost entry. 2. Go back to the web interface and look at your new hostgroups PART VI Create Service Groups ----------------------------------------------------------------------------- 1. Create service groups for ssh and http for each set of pcs. - The idea here is to create five service groups. Each service group will be for a table. We want to see these PCs grouped together by table and include status of their ssh and http services. To do this edit and create the file: # editor /etc/nagios3/conf.d/servicegroups.cfg Here is a sample of the service group for group 1: define servicegroup { servicegroup_name group1-servers alias group 1 servers members pc1,SSH,pc1,HTTP,pc2,SSH,pc2,HTTP,pc3,SSH,pc3,HTTP,pc4,SSH,pc4 } - Note that the members line should wrap and not be on two lines. - Note that "SSH" and "HTTP" need to be uppercase as this is how the service_description is written in the file /etc/nagios3/conf.d/services_nagios2.cfg - You should create an entry for other groups of servers too - Save your changes, verify your work and restart Nagios. Now if you click on the Servicegroup menu items in the Nagios web interface you should see this information grouped together. OPTIONAL -------- * Check that SNMP is running on the classroom NOC - First you will need to add in the appropriate service check for SNMP in the file /etc/nagios3/conf.d/services_nagios2.cfg. This is where Nagios is impressive. There are hundreds, if not thousands, of service checks available via the various Nagios sites on the web. You can see what plugins are installed by Ubuntu in the nagios3 package that we've installed by looking in the following directory: # ls /usr/lib/nagios/plugins As you'll see there is already a check_snmp plugin available to us. If you are interested in the options the plugin takes you can execute the plugin from the command line by typing: # /usr/lib/nagios/plugins/check_snmp # /usr/lib/nagios/plugins/check_snmp --help to see what options are available, etc. You can use the check_snmp plugin and Nagios to create very complex or specific system checks. - Now to see all the various service/host checks that have been created using the check_snmp plugin you can look in /etc/nagios-plugins/config/snmp.cfg. You will see that there are a lot of preconfigured checks using snmp, including: snmp_load snmp_cpustats snmp_procname snmp_disk snmp_mem snmp_swap snmp_procs snmp_users snmp_mem2 snmp_swap2 snmp_mem3 snmp_swap3 snmp_disk2 snmp_tcpopen snmp_tcpstats snmp_bgpstate check_netapp_uptime check_netapp_cupuload check_netapp_numdisks check_compaq_thermalCondition And, even better, you can create additional service checks quite easily. For the case of verifying that snmpd (the SNMP service on Linux) is running we need to ask SNMP a question. If we don't get an answer, then Nagios can assume that the SNMP service is down on that host. When you use service checks such as check_http, check_ssh and check_telnet this is what they are doing as well. - In our case, let's create a new service check and call it "check_system". This service check will connect with the specified host, use the private community string we have defined in class and ask a question of snmp on that ask - in this case we'll ask about the System Description, or the OID "sysDescr.0" - - To do this start by editing the file /etc/nagios-plugins/config/snmp.cfg: # joe /etc/nagios-plugins/config/snmp.cfg At the top (or the bottom, your choice) add the following entry to the file: # 'check_system' command definition define command{ command_name check_system command_line /usr/lib/nagios/plugins/check_snmp -H '$HOSTADDRESS$' -C '$ARG1$' -o sysDescr.0 } You may wish to copy and paste this vs. trying to type this out. Note that "command_line" is a single line. If you copy and paste in joe the line may not wrap properly and you may have to manually add the part: '$ARG1$' -o sysDescr.0 to the end of the line. - Now you need to edit the file /etc/nagios3/conf.d/services_nagios2.cfg and add in this service check. We'll run this check against all our servers in the classroom, or the hostgroup "debian-servers" - Edit the file /etc/nagios3/conf.d/services_nagios2.cfg # joe /etc/nagios3/conf.d/services_nagios2.cfg At the bottom of the file add the following definition: # check that snmp is up on all servers define service { hostgroup_name snmp-servers service_description SNMP check_command check_system!xxxxxx use generic-service notification_interval 0 ; set > 0 if you want to be renotified } The "xxxxxx" is the community string previously (or to be) defined in class. Note that we have included our private community string here vs. hard-coding it in the snmp.cfg file earlier. You must change the "xxxxx" to be the snmp community string given in class or this check will not work. - Now we must create the "snmp-servers" group in our hostgroups_nagios2.cfg file. Edit the file /etc/nagios3/conf.d/hostgroups_nagios2.cfg and go to the end of the file. Add in the following hostgroup definition: # A list of snmp-enabled devices on which we wish to run the snmp service check define hostgroup { hostgroup_name snmp-servers alias snmp servers members noc } - Note that for "members" you could, also, add in the switches and routers for group 1 and 2. But, the particular item (MIB) we are checking for "sysDescr.0" may not be available on the switches and/or routers, so the check would then fail. - Now verify that your changes are correct and restart Nagios. - If you click on the Service Detail menu choice in web interface you should see the SNMP check appear for the noc host. - After we do the SNMP presentation and exercises in class, then you could come back to this exercise and add in all the classroom PCs to the members list in the hostgroups_nagios2.cfg file, snmp-servers hostgroup definition. Remember to list your PC as "localhost".