Agenda: exercises-nagios.txt

File exercises-nagios.txt, 27.7 KB (added by b.candler, 8 years ago)
Line 
1Registry Operations Curriculum
2Nagios Installation and Configuration
3
4Notes:
5------
6* Commands preceded with "$" imply that you should execute the command as
7  a general user - not as root.
8* Commands preceded with "#" imply that you should be working as root.
9* Commands with more specific command lines (e.g. "RTR-GW>" or "mysql>")
10  imply that you are executing commands on remote equipment, or within
11  another program.
12
13Exercises
14---------
15
16Exercises Part I
17----------------
18
190. Log in to your PC or open a terminal window as the sysadmin user.
20
21
221. You could install Nagios version 3. You would do this as root or as the sysadmin
23   user and use the "sudo" command:
24
25    # apt-get install nagios3
26
27   Unless you already have an MTA installed, nagios3 will install
28   postfix as a dependency. Select "Internet Site" option. (If you had wanted
29   to use a different MTA like you'd install it before nagios3)
30
31   You will be prompted for nagiosadmin password. Give it the normal
32   workshop password.
33
34   To get the documentation in /usr/share/doc/nagios3-doc/html/ (which
35   can also be read via the nagios web interface), do:
36
37    # apt-get install nagios3-doc
38
39
402. Look at the file which contains the password. It's hashed (encrypted)
41
42    # cat /etc/nagios3/htpasswd.users
43
44
453. You should already have a working Nagios!
46
47    - Open a browser, and go to
48
49    http://pcX.mgmt/nagios3/
50
51    - At the login prompt, login as:
52
53        user: nagiosadmin
54        pass:
55
56    Browse to the "Host Detail" page to see what's already configured.
57
58
594. Let's look at the configuration layout...
60
61    # cd /etc/nagios3
62    # ls -l
63
64    -rw-r--r-- 1 root root    1882 2008-12-18 13:42 apache2.conf
65    -rw-r--r-- 1 root root   10524 2008-12-18 13:44 cgi.cfg
66    -rw-r--r-- 1 root root    2429 2008-12-18 13:44 commands.cfg
67    drwxr-xr-x 2 root root    4096 2009-02-14 12:33 conf.d
68    -rw-r--r-- 1 root root      26 2009-02-14 12:36 htpasswd.users
69    -rw-r--r-- 1 root root   42539 2008-12-18 13:44 nagios.cfg
70    -rw-r----- 1 root nagios  1293 2008-12-18 13:42 resource.cfg
71    drwxr-xr-x 2 root root    4096 2009-02-14 12:32 stylesheets
72
73    # cd conf.d
74    # ls -l   
75
76    -rw-r--r-- 1 root root 1695 2008-12-18 13:42 contacts_nagios2.cfg
77    -rw-r--r-- 1 root root  418 2008-12-18 13:42 extinfo_nagios2.cfg
78    -rw-r--r-- 1 root root 1152 2008-12-18 13:42 generic-host_nagios2.cfg
79    -rw-r--r-- 1 root root 1803 2008-12-18 13:42 generic-service_nagios2.cfg
80    -rw-r--r-- 1 root root  210 2009-02-14 12:33 host-gateway_nagios3.cfg
81    -rw-r--r-- 1 root root  976 2008-12-18 13:42 hostgroups_nagios2.cfg
82    -rw-r--r-- 1 root root 2167 2008-12-18 13:42 localhost_nagios2.cfg
83    -rw-r--r-- 1 root root 1005 2008-12-18 13:42 services_nagios2.cfg
84    -rw-r--r-- 1 root root 1609 2008-12-18 13:42 timeperiods_nagios2.cfg
85
86    Notice that the package installs files with "nagios2" in their name.
87    This is because they are the same files as were used for the Nagios
88    version 2 Debian package. However there was a change made to the
89    host-gateway configuration file, so this has a new name.
90
91
925. You have a config which is already monitoring your own system
93(localhost_nagios2.cfg) and your upstream default gateway
94(host-gateway_nagios3.cfg).
95
96Have a look at the config file for the default gateway: it's very simple.
97(Note: tab completion is useful here. Type cat host-g then hit tab; the
98filename will be filled in for you)
99
100    # cat host-gateway_nagios3.cfg
101
102    # a host definition for the gateway of the default route
103    define host {
104            host_name   gateway
105            alias       Default Gateway
106            address     10.10.X.254
107            use         generic-host
108            }
109
110It should point to the virtual Cisco router which is upstream of your VM.
111
112
1136. You should be ssh'd into your VM on its management address
114   (10.10.0.10X or pcX.mgmt). If so, it is safe to break its external
115   connectivity but still reach it on its management IP. (This is why we
116   build separate management LANs :-)
117
118   Break the connectivity like this, and double-check that you can no
119   longer reach anything outside.
120
121    # ifdown eth2
122    # ping 10.10.254.200    # should not get any response
123    connect: Network is unreachable
124
125   Now monitor your Nagios host detail page, refresh it from time to time.
126   After a few minutes, you should see the problem detected and shown.
127
128   Once you've seen this, restore the connectivity on your VM.
129
130    # ifup eth2
131
132   and check the problem is cleared.
133
134
135
136PART II
137Configuring Equipment
138-----------------------------------------------------------------------------
139
1400. Order of configuration
141
142Conceptually we will build our configuration files from the "nearest" device
143then the further away ones.
144
145By going in this order you will have defined the devices that act as parents
146for other devices.
147
148Your upstream Cisco virtual router is already defined.
149
150
1511. Let's configure Nagios to start monitoring the classroom backbone switch,
152with your virtual Cisco as its parent (since from your point of view,
153the backbone is reached through your local Cisco)
154
155    # cd /etc/nagios3/conf.d/
156
157    # vi switches.cfg
158
159define host {
160    use         generic-host
161    host_name   bb-sw
162    alias       backbone switch
163    address     10.10.254.253
164    parents     gateway
165}
166
167Notice the "parents" entry. This must point at a device or devices which are
168also defined.  "gateway" is already defined in host-gateway_nagios3.cfg, so
169this will work.
170
171
172STEPS 2a - 2c SHOULD BE REPEATED WHENEVER YOU UPDATE THE CONFIGURATION!
173   
174
1752a. Verify that your configuration files are OK:
176
177    # nagios3 -v /etc/nagios3/nagios.cfg
178
179    ... You should get :
180Warning: Host 'bb-sw' has no services associated with it!
181...
182Total Warnings: 1
183Total Errors:   0
184
185Things look okay - No serious problems were detected during the check.
186Nagios is saying that it's unusual to monitor a device just for its
187existence on the network, without also monitoring some service.
188
189
1902b. Reload/Restart Nagios
191
192    # /etc/init.d/nagios3 restart
193
194Not always 100% reliable to use the "restart" option due to a bug in the Nagios init script.
195To be sure you may want to get used to doing:
196
197    # /etc/init.d/nagios3 stop
198    # /etc/init.d/nagios3 start
199
200
2012c. Go to the web interface (http://pcX.mgmt/nagios3) and check that the hosts
202   you just added are now visible in the interface. Click on the "Host Detail" item
203   on the left of the Nagios screen to see this. You may see it in "PENDING"
204   status until the check is carried out.
205
206
207HINT: You will be doing this a lot. If you do it all on online line, like this,
208then you can hit cursor-up and rerun all in one go:
209
210    nagios3 -v /etc/nagios3/nagios.cfg && /etc/init.d/nagios3 restart
211
212The '&&' ensures that the restart only happens if the config is valid.
213
214
2153. Configure our classroom router
216
217Now configure our classroom border router. If the switch went down we
218wouldn't be able to reach the router, so we configure the switch as
219a parent of the router.
220
221    # cd /etc/nagios3/conf.d/
222
223    # vi routers.cfg
224
225define host {
226    use         generic-host
227    host_name   bb-gw
228    alias       backbone router
229    address     10.10.254.254
230    parents     bb-sw
231}
232
233(The filenames 'switches.cfg' and 'routers.cfg' are arbitrary. It's up to
234you how you organise your devices between config files)
235
236Now repeat step 2, and check that the router is being monitored.
237
238
2394. Create entries for other routers and PCs in the classroom
240
241Now that we have our routers and switches defined it is quite easy to create
242entries for all our PCs.  Think about the parent relationships:
243
244
245         +--------------------------------+
246         | B A C K B O N E    S W I T C H |
247         +--------------------------------+
248             ^          |         |
249             |          v         v
250         Your router   NOC   remote router
251             ^                    |
252             |                    v
253          Your PC             remote PC
254
255
256The parent of the NOC is the backbone switch. The parent of a remote router
257is also the backbone switch.  The parent of the other PC is the remote
258router.
259
260Below are three sample entries. One for the NOC, one for pc1 and one for
261pc16.  You should be able to use this example to create entries for all 16
262classroom pcs plus the NOC:
263
264We could put these entries in to separate files, but as our network is small we'll use a single
265file called pcs.cfg.
266
267NOTE! You do not add in an entry for your own PC or router. This has already
268been defined in the file /etc/nagios3/conf.d/localhost_nagios2.cfg.  This definition is what
269defines the Nagios network viewpoint. So, when you come to the spot where you might add an entry for your PC
270you should skip this and go on to the next PC in the list.
271
272        # vi pcs.cfg
273       
274# Our classroom NOC
275
276define host {
277    use         generic-host
278    host_name   noc
279    alias       Workshop NOC machine
280    address     10.10.254.200
281    parents     bb-sw
282}
283
284# Group 1 devices
285
286define host {
287    use         generic-host
288    host_name   r1
289    alias       pc1 router
290    address     10.10.254.1
291    parents     bb-sw
292}
293define host {
294    use         generic-host
295    host_name   pc1
296    alias       pc1 outside interface
297    address     10.10.1.1
298    parents     r1
299}
300
301# Group 16 devices
302
303define host {
304    use         generic-host
305    host_name   r16
306    alias       pc16 router
307    address     10.10.254.16
308    parents     bb-sw
309}
310define host {
311    use         generic-host
312    host_name   pc16
313    alias       pc16 outside interface
314    address     10.10.16.1
315    parents     r16
316}
317
318Take the three entries above and now expand this to create the remaining entries
319for pc2-pc15. If you have any questions about IP addresses, etc. you can review the Network
320Diagram for the class linked off the classroom wiki main page at
321http://nsrc.org/workshops/2010/menog7/attachment/wiki/Agenda/lab-numbering.txt
322
323Exit and save the file pcs.cfg
324
325As before, repeat steps 2a-2c to verify your configuration, correct any
326errors, and activate it.
327
328
3295. Look at your Nagios instance on the web. Note that "Status Map" gives
330you a graphical view of the parent-child relationships you have defined.
331
332
333PART III
334Configure Service check for your the classroom NOC
335-----------------------------------------------------------------------------
336
3370. Configuring
338
339Now that we have our hardware configured we can start telling Nagios what services to monitor
340on the configured hardware, how to group the hardware in interesting ways, how to group
341services, etc.
342
3431. Associate a service check for our classroom NOC
344
345    # vi hostgroups_nagios2.cfg
346
347    - Find the hostgroup named "ssh-servers". In the members section of the defintion
348      change the line:
349
350members                 localhost
351
352    to
353
354members                 localhost,noc
355
356Exit and save the file.
357
358Verify that your changes are OK:
359
360        # nagios3 -v /etc/nagios3/nagios.cfg
361       
362Restart Nagios to see the new service assocation with your host:
363
364        # /etc/init.d/nagios3 Restart
365
366Click on the "Service Detail" link in the Nagios web interface to see your new entry.
367
368
369PART IV
370Defining Services for all PCs
371-----------------------------------------------------------------------------
372
3730. For services, the default normal_check_interval is 5 (minutes) in
374   generic-service_nagios2.cfg. You may wish to change this to 1 to speed up
375   how quickly service issues are detected, at least in the workshop.
376
3771. Determine what services to define for what devices
378
379   - This is core to how you use Nagios and network monitoring tools in
380     general. So far we are simply using ping to verify that physical hosts
381     are up on our network and we have started monitoring a single service on
382     a single host (your PC). The next step is to decide what services you wish
383     to monitor for each host in the classroom.
384
385   - In this particular class we have:
386
387     routers:  running ssh and snmp
388     switches: running telnet and possibly ssh as well as snmp
389     pcs:      All PCs are running ssh and http and should be running snmp
390               The NOC is currently running an snmp daemon
391             
392     So, let's configure Nagios to check for these services for these
393     devices.
394
3952.) Verify that SSH is running on the routers and workshop PCs images
396
397   - In the file services_nagios2.cfg there is already an entry for the SSH
398     service check, so you do not need to create this step. Instead, you
399     simply need to re-define the "ssh-servers" entry in the file
400     /etc/nagios3/conf./hostgroups_nagios2.cfg. The initial entry in the file
401     looked like:
402
403# A list of your ssh-accessible servers
404define hostgroup {
405        hostgroup_name  ssh-servers
406                alias           SSH servers
407                members         localhost,noc
408        }
409
410     What do you think you should change? Correct, the "members" line. You should
411     add in entries for all the classroom pcs, routers and  the switches that run ssh.
412     With this information and the network diagram you should be able complete this entry.
413     
414     The entry will look something like this:
415
416define hostgroup {
417        hostgroup_name  ssh-servers
418                alias           SSH servers
419                members         localhost,pc1,pc2,pc3,pc4....,bb-gw
420        }
421
422         Note: leave in "localhost" - This is your PC and represents Nagios' network point of
423         view. So, for instance, if you are on "pc3" you would not include "pc3" in the list
424         of all the classroom pcs as it is represented by the "localhost" entry.
425         
426         The "members" entry will be a long line and will likely wrap on the screen.
427
428         Remember to include all your PCs.
429
430    - Once you are done, run the pre-flight check:
431
432    # nagios3 -v /etc/nagios3/nagios.cfg
433
434    If everything looks good, then restart Nagios
435
436    # /etc/init.d/nagios3 stop
437    # /etc/init.d/nagios3 start
438
439    and view your changes in the Nagios web interface.
440
4413.) Check that http is running on all the classroom PCs.
442
443    - This is almost identical to the previous exercise. Just make the change to the
444      HTTP service adding in each PC (no routers or switches). Remember, you don't need
445      to add your machine as it is already defined as "localhost".     
446
4474.)  OPTIONAL EXTRA: as opposed to just checking that a web server is
448     running on the classroom PCs, we could also check that the nagios3
449     service is available, by requesting the /nagios3/ path.
450
451     You can get information about the check_http plugin like this:
452
453      # /usr/lib/nagios/plugins/check_http --help
454
455     and/or use google to find out what extra arguments you need to pass
456     to monitor a particular path.
457
458     Once you have done this, check that Nagios warns you about failing
459     authentication (because it's trying to fetch the page without providing
460     the username/password). There's an extra parameter you can pass to
461     check_http to provide that info.
462
463      WARNING: in the tradition of "Debian Knows Best", their definition of the
464      check_http command in /etc/nagios-plugins/config/http.cfg
465      is *not* the same as that recommended in the nagios3 documentation.
466      It is missing $ARG1$, so any parameters to pass to check_http are
467      ignored. So you might think you are monitoring /nagios3/ but actually
468      you are monitoring root!
469
470      Either fix the command definition, or define a new command like
471      "check_nagios".
472
473
474
475PART V
476Create More Host Groups
477-----------------------------------------------------------------------------
478
4790. In the web view, look at the pages "Hostgroup Overview", "Hostgroup
480   Summary", "Hostgroup Grid". This gives a convenient way to group together
481   hosts which are related (e.g. in the same site, serving the same purpose).
482
4831. Update /etc/nagios3/conf.d/hostgroups_nagios2.cfg
484
485    - For the following exercises it will be very useful if we have created
486      or update the following hostgroups:
487
488      debian-servers
489      routers
490      switches
491 
492      If you edit the file /etc/nagios3/conf.d/hostgroups_nagios2.cfg you
493      will see an entry for debian-servers that just contains localhost.
494      Update this entry to include all the classroom PCs, including the
495      noc (this assumes that you created a "noc" entry in your pcs.cfg
496      file). Remember to skip your PC entry as it is represented by the
497      localhost entry.
498
499    # vi /etc/nagios3/conf.d/hostgroups_nagios2.cfg
500
501     Update the entry that says:
502
503
504# A list of your Debian GNU/Linux servers
505define hostgroup {
506        hostgroup_name  debian-servers
507                alias           Debian GNU/Linux Servers
508                members         localhost
509        }
510     
511      So that the "members" parameter contains something like this. Use your
512      classroom network diagram to confirm the exact number of machines and names
513      in your workshop.
514
515                members         localhost,pc1,pc2,pc3,pc4,pc5,pc6,pc7,pc8,pc9
516                                pc10,pc11,pc12,pc13,pc14,pc15,pc16,pc17,pc18
517
518        Be sure that the line wraps and is not on two separate lines. Otherwise
519        you will get an error when you go to restart Nagios. Remember that
520        your own PC is "localhost".
521
522      - Once you have done this, add in two more host groups, one for routers and
523        one for switches. Call these entries "routers" and "switches".
524
525      - When you are done be sure to verify your work and restart Nagios.
526 
5272. Go back to the web interface and look at your new hostgroups
528
529
530PART VI
531Extended Host Information ("making your graphs pretty")
532-----------------------------------------------------------------------------
533
5341. Update extinfo_nagios2.cfg
535
536    - If you would like to use appropriate icons for your defined hosts in
537      Nagios this is where you do this. We have the three types of devices:
538
539      Cisco routers
540      Cisco switches
541      Ubuntu servers
542
543      There is a fairly large repository of icon images available for you to
544      use located here:
545
546      /usr/share/nagios/htdocs/images/logos/
547
548      these were installed by default as dependent packages of the nagios3
549      package in Ubuntu. In some cases you can find model-specific icons for
550      your hardware, but to make things simpler we will use the following
551      icons for our hardware:
552
553      /usr/share/nagios/htodcs/images/logos/base/debian.*
554      /usr/share/nagios/htdocs/images/logos/cook/router.*
555      /usr/share/nagios/htdocs/images/logos/cook/switch.*
556
557    - The next step is to edit the file /etc/nagios3/conf.d/extinfo_nagios2.cfg
558      and tell nagios what image you would like to use to represent your devices.
559
560    # vi /etc/nagios3/conf.d/extinfo_nagios2.cfg
561
562      Here is what an entry for your routers looks like (there is already an entry
563      for debian-servers that will work as is). Note that the router model (3600)
564      is not all that important. The image used represents a router in general.
565
566define hostextinfo {
567        hostgroup_name   routers
568        icon_image       cook/router.png
569        icon_image_alt   Cisco Routers (3600)
570        vrml_image       router.png
571        statusmap_image  cook/router.gd2
572}
573
574      Now add an entry for your switches. Once you are done check your
575      work and restart Nagios. Take a look at the Status Map in the web interface.
576      It should be much nicer, with real icons instead of question marks.
577
578
579PART VII
580Create Service Groups
581-----------------------------------------------------------------------------
582
5831. Create service groups for ssh and http for each set of pcs.
584
585   - The idea here is to create three service groups. Each service group will
586     be for a quarter of the classroom. We want to see these PCs grouped together
587     and include status of their ssh and http services. To do this edit
588     and create the file:
589
590   # vi /etc/nagios3/conf.d/servicegroups.cfg
591
592     Here is a sample of the service group for group 1:
593
594define servicegroup {
595        servicegroup_name       group1-servers
596        alias                   group 1 servers
597        members                 pc1,SSH,pc1,HTTP,pc2,SSH,pc2,HTTP,pc3,SSH,pc3,HTTP,pc4,SSH,pc4
598        }
599
600        - Note that the members line should wrap and not be on two lines.
601       
602        - Note that "SSH" and "HTTP" need to be uppercase as this is how the service_description is
603          written in the file /etc/nagios3/conf.d/services_nagios2.cfg
604         
605        - You should create an entry for other groups of servers too
606
607    - Save your changes, verify your work and restart Nagios. Now if you click on
608      the Servicegroup menu items in the Nagios web interface you should see
609      this information grouped together.
610
611
612
613PART VIII
614Configure Guest Access to the Nagios Web Interface
615-----------------------------------------------------------------------------
616
6171. Edit /etc/nagios3/cgi.cfg to give read only guest user access to the Nagios
618   web interface.
619
620    - By default Nagios is configured to give full r/w access via the Nagios
621      web interface to the user nagiosadmin. You can change the name of this
622      user, add other users, change how you authenticate users, what users
623      have access to what resources and more via the cgi.cfg file.
624
625    - First, lets create a "guest" user and password in the htpasswd.users
626      file.
627     
628    # htpasswd /etc/nagios3/htpasswd.users guest
629
630      You can use any password you want (or none). A password of "guest" is
631      not a bad choice.
632
633    - Next, edit the file /etc/nagios3/cgi.cfg and look for what type of access
634      has been given to the nagiosadmin user. By default you will see the following
635      directives (note, there are comments between each directive):
636
637      authorized_for_system_information=nagiosadmin
638      authorized_for_configuration_information=nagiosadmin
639      authorized_for_system_commands=nagiosadmin
640      authorized_for_all_services=nagiosadmin
641      authorized_for_all_hosts=nagiosadmin
642      authorized_for_all_service_commands=nagiosadmin
643      authorized_for_all_host_commands=nagiosadmin
644
645      Now lets tell Nagios to allow the "guest" user some access to
646      information via the web interface. You can choose whatever you would
647      like, but what is pretty typical is this:
648
649      authorized_for_system_information=nagiosadmin,guest
650      authorized_for_configuration_information=nagiosadmin,guest
651      authorized_for_system_commands=nagiosadmin
652      authorized_for_all_services=nagiosadmin,guest
653      authorized_for_all_hosts=nagiosadmin,guest
654      authorized_for_all_service_commands=nagiosadmin
655      authorized_for_all_host_commands=nagiosadmin
656
657    - Once you make the changes, save the file cgi.cfg, verify your
658      work and restart Nagios.
659
660    - To see if you can log in as the "guest" user you may need to clear
661      the cookies in your web browser. You will not notice any difference
662      in the web interface. The difference is that a number of items that
663      are available via the web interface (forcing a service/host check,
664      scheduling checks, comments, etc.) will not work for the guest
665      user.
666
667
668OPTIONAL
669--------
670
671* Check that SNMP is running on the classroom NOC
672
673    - First you will need to add in the appropriate service check for SNMP in the file
674      /etc/nagios3/conf.d/services_nagios2.cfg. This is where Nagios is impressive. There
675      are hundreds, if not thousands, of service checks available via the various Nagios
676      sites on the web. You can see what plugins are installed by Ubuntu in the nagios3
677      package that we've installed by looking in the following directory:
678
679    # ls /usr/lib/nagios/plugins
680
681      As you'll see there is already a check_snmp plugin available to us. If you are
682      interested in the options the plugin takes you can execute the plugin from the
683      command line by typing:
684
685    # /usr/lib/nagios/plugins/check_snmp
686    # /usr/lib/nagios/plugins/check_snmp --help
687
688      to see what options are available, etc. You can use the check_snmp plugin and
689      Nagios to create very complex or specific system checks.
690
691    - Now to see all the various service/host checks that have been created using the
692      check_snmp plugin you can look in /etc/nagios-plugins/config/snmp.cfg. You will
693      see that there are a lot of preconfigured checks using snmp, including:
694
695      snmp_load
696      snmp_cpustats
697      snmp_procname
698      snmp_disk
699      snmp_mem
700      snmp_swap
701      snmp_procs
702      snmp_users
703      snmp_mem2
704      snmp_swap2
705      snmp_mem3
706      snmp_swap3
707      snmp_disk2
708      snmp_tcpopen
709      snmp_tcpstats
710      snmp_bgpstate
711      check_netapp_uptime
712      check_netapp_cupuload
713      check_netapp_numdisks
714      check_compaq_thermalCondition
715     
716      And, even better, you can create additional service checks quite easily.
717      For the case of verifying that snmpd (the SNMP service on Linux) is running we
718      need to ask SNMP a question. If we don't get an answer, then Nagios can assume
719      that the SNMP service is down on that host. When you use service checks such as
720      check_http, check_ssh and check_telnet this is what they are doing as well.
721
722    - In our case, let's create a new service check and call it "check_system". This
723      service check will connect with the specified host, use the private community
724      string we have defined in class and ask a question of snmp on that ask - in this
725      case we'll ask about the System Description, or the OID "sysDescr.0" -
726
727    - To do this start by editing the file /etc/nagios-plugins/config/snmp.cfg:
728
729    # vi /etc/nagios-plugins/config/snmp.cfg
730
731      At the top (or the bottom, your choice) add the following entry to the file:
732
733# 'check_system' command definition
734define command{
735       command_name    check_system
736       command_line    /usr/lib/nagios/plugins/check_snmp -H '$HOSTADDRESS$' -C
737'$ARG1$' -o sysDescr.0
738        }
739     
740      You may wish to copy and past this vs. trying to type this out.
741
742          Note that "command_line" is a single line. If you copy and paste in vi the line
743          may not wrap properly and you may have to manually add the part:
744         
745                        '$ARG1$' -o sysDescr.0
746                       
747          to the end of the line.
748
749    - Now you need to edit the file /etc/nagios3/conf.d/services_nagios2.cfg and add
750      in this service check. We'll run this check against all our servers in the
751      classroom, or the hostgroup "debian-servers"
752
753    - Edit the file /etc/nagios3/conf.d/services_nagios2.cfg
754
755    # vi /etc/nagios3/conf.d/services_nagios2.cfg
756
757      At the bottom of the file add the following definition:
758
759# check that snmp is up on all servers
760define service {
761        hostgroup_name                  snmp-servers
762        service_description             SNMP
763        check_command                   check_system!xxxxxx
764        use                             generic-service
765        notification_interval           0 ; set > 0 if you want to be renotified
766}
767
768      The "xxxxxx" is the community string previously (or to be) defined in class.
769     
770      Note that we have included our private community string here vs. hard-coding
771      it in the snmp.cfg file earlier. You must change the "xxxxx" to be the snmp
772      community string given in class or this check will not work.
773     
774    - Now we must create the "snmp-servers" group in our hostgroups_nagios2.cfg file.
775      Edit the file /etc/nagios3/conf.d/hostgroups_nagios2.cfg and go to the end of the
776      file. Add in the following hostgroup definition:
777     
778# A list of snmp-enabled devices on which we wish to run the snmp service check
779define hostgroup {
780           hostgroup_name       snmp-servers
781                   alias        snmp servers
782                   members      noc
783          }
784         
785        - Note that for "members" you could, also, add in the switches and routers for
786          group 1 and 2. But, the particular item (MIB) we are checking for "sysDescr.0"
787          may not be available on the switches and/or routers, so the check would then fail.
788
789    - Now verify that your changes are correct and restart Nagios.
790
791    - If you click on the Service Detail menu choice in web interface you should see
792      the SNMP check appear for the noc host.
793     
794    - After we do the SNMP presentation and exercises in class, then you could come
795      back to this exercise and add in all the classroom PCs to the members list in the
796      hostgroups_nagios2.cfg file, snmp-servers hostgroup definition. Remember to list
797      your PC as "localhost".
798
799