Agenda: exercises-nagios-afnog2011.2.txt

File exercises-nagios-afnog2011.2.txt, 31.2 KB (added by hervey, 8 years ago)
Line 
1
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 sysadm user.
20
211. You may need to install Nagios version 3. You would do this as root or as the sysadmin
22   user and use the "sudo" command. As sysadm:
23
24   $ sudo apt-get install nagios3
25
26   Unless you already have an MTA installed, nagios3 will install
27   postfix as a dependency. Select "Internet Site" option. (If you had wanted
28   to use a different MTA likely you'd install it before nagios3)
29
30   You will be prompted for nagiosadmin password. Give it the normal
31   workshop password.
32
33   To get the documentation in /usr/share/doc/nagios3-doc/html/ (which
34   can also be read via the nagios web interface), do:
35
36    $ sudo apt-get install nagios3-doc
37
38
392. Look at the file which contains the password. It's hashed (encrypted)
40
41    $ cat /etc/nagios3/htpasswd.users
42
43
443. You should already have a working Nagios!
45
46    - Open a browser, and go to your machine like this:
47
48    http://pcN.ws.nsrc.org/nagios3/
49
50    - At the login prompt, login as:
51
52        user: nagiosadmin
53        pass: <CLASS PASSWORD>
54
55    Browse to the "Host Detail" page to see what's already configured.
56
57
584. Let's look at the configuration layout... But, first, let's become the root
59   user on your machine:
60
61    $ sudo bash
62
63    # cd /etc/nagios3
64    # ls -l
65
66    -rw-r--r-- 1 root root    1882 2008-12-18 13:42 apache2.conf
67    -rw-r--r-- 1 root root   10524 2008-12-18 13:44 cgi.cfg
68    -rw-r--r-- 1 root root    2429 2008-12-18 13:44 commands.cfg
69    drwxr-xr-x 2 root root    4096 2009-02-14 12:33 conf.d
70    -rw-r--r-- 1 root root      26 2009-02-14 12:36 htpasswd.users
71    -rw-r--r-- 1 root root   42539 2008-12-18 13:44 nagios.cfg
72    -rw-r----- 1 root nagios  1293 2008-12-18 13:42 resource.cfg
73    drwxr-xr-x 2 root root    4096 2009-02-14 12:32 stylesheets
74
75    # cd conf.d
76    # ls -l   
77
78    -rw-r--r-- 1 root root 1695 2008-12-18 13:42 contacts_nagios2.cfg
79    -rw-r--r-- 1 root root  418 2008-12-18 13:42 extinfo_nagios2.cfg
80    -rw-r--r-- 1 root root 1152 2008-12-18 13:42 generic-host_nagios2.cfg
81    -rw-r--r-- 1 root root 1803 2008-12-18 13:42 generic-service_nagios2.cfg
82    -rw-r--r-- 1 root root  210 2009-02-14 12:33 host-gateway_nagios3.cfg
83    -rw-r--r-- 1 root root  976 2008-12-18 13:42 hostgroups_nagios2.cfg
84    -rw-r--r-- 1 root root 2167 2008-12-18 13:42 localhost_nagios2.cfg
85    -rw-r--r-- 1 root root 1005 2008-12-18 13:42 services_nagios2.cfg
86    -rw-r--r-- 1 root root 1609 2008-12-18 13:42 timeperiods_nagios2.cfg
87
88    Notice that the package installs files with "nagios2" in their name.
89    This is because they are the same files as were used for the Nagios
90    version 2 Debian package. However there was a change made to the
91    host-gateway configuration file, so this has a new name.
92
93
945. You have a config which is already monitoring your own system
95(localhost_nagios2.cfg) and your upstream default gateway
96(host-gateway_nagios3.cfg).
97
98Have a look at the config file for the default gateway: it's very simple.
99(Note: tab completion is useful here. Type cat host-g then hit tab; the
100filename will be filled in for you)
101
102    # cat host-gateway_nagios3.cfg
103
104    # a host definition for the gateway of the default route
105    define host {
106            host_name   gateway
107            alias       Default Gateway
108            address     10.10.0.254
109            use         generic-host
110            }
111
112
113
114PART II
115Configuring Equipment
116-----------------------------------------------------------------------------
117
1180. Order of configuration
119
120Conceptually we will build our configuration files from the "nearest" device
121then the further away ones.
122
123By going in this order you will have defined the devices that act as parents
124for other devices.
125
126Remember to refer to the Network Diagram for our classroom if you get confused.
127
128We recommend creating instances like this:
129
130rtr     (the gateway router: 10.10.0.254)
131sw      (the gateway switch: 10.10.0.253, parent: rtr)
132rtr1    (group 1 router: 10.10.1.254, parent: sw)
133rtr2    (group 2 router: 10.10.2.254, parent: sw))
134rtr3    (group 3 router: 10.10.3.254, parent: sw))
135rtr4    (group 4 router: 10.10.4.254, parent: sw))
136rtr5    (group 5 router: 10.10.5.254, parent: sw))
137rtr6    (group 6 router: 10.10.6.254, parent: sw))
138
139pc1     (pc in group 1: 10.10.1.1, parent: rtr1)
140.
141pc2     (pc in group 2: 10.10.2.2, parent: rtr2)
142.
143pc9     (pc in group 3: 10.10.3.9, parent: rtr3)
144.
145pc10    (pc in group 4: 10.10.4.10, parent: rtr4)
146.
147pc17    (pc in group 5: 10.10.5.17, parent: rtr5)
148.
149pc18    (pc in group 6: 10.10.6.18, parent: rtr6)
150.
151.
152pc26
153
154s1      (on backbone: 10.10.0.241, parent: sw)
155s2      (on backbone: 10.10.0.242, parent: sw)
156noc     (on backbone: 10.10.0.250, parent: sw)
157ap1     (on backbone: 10.10.0.251, parent: sw)
158ap2     (on backbone: 10.10.0.252, parent: sw)
159
160We recommend placing these items in the files:
161
162routers.cfg             (rtr, rtr1...rtr6)
163switches.cfg            (sw)
164pcs.cfg                 (pc1...pc26, s1, s2, noc, ap1, ap2)
165
166
1671. First we need to tell Nagios to monitor the gateway router for
168   our classroom which is 10.10.0.254:
169
170   # cd /etc/nagios3/conf.d/
171
172Create the routers gateway like this:
173
174   # vi routers.cfg
175
176define host {
177    use         generic-host
178    host_name   rtr
179    alias       Gateway Router
180    address     10.10.0.254
181}
182
183In the same file create the 6 entries for the group routers:
184
185define host {
186    use         generic-host
187    host_name   rtr1
188    alias       Group 1 Router
189    address     10.10.1.254
190    parents     sw
191}
192
193repeate this for ap1, ap2, rtr2, rtr3, rtr4, rtr5, rtr6, rtr7, rtr8, rtr9.
194        note ap1 IP - 10.10.0.244
195        note ap2 IP - 10.10.0.245
196
197Note that the entry for "sw" our gateway switch has not yet been created. That is
198next.
199
200Exit and save this file.
201
202
2032. Create a file called switches.cfg and add an entry for this item:
204
205   # vi switches.cfg
206
207define host {
208    use         generic-host
209    host_name   sw
210    alias       Backbone Switch
211    address     10.10.0.253
212    parents     rtr
213}
214
215At this point Nagios is configured to monitor whether our core hosts (the parents)
216are up on our classroom network. Your next steps are to add in the individual hosts
217such as the classroom virtual PC images (pc1 to pc26), the Wireless Access Points
218(ap1 and ap2), the servers s1, s2 and the noc:
219
220Be sure you add in a proper "parents" entry for each host.
221
222Remember, if you don't understand the parent relations in our network you can
223review the logical network diagram here:
224
225        http://noc.ws.nsrc.org/wiki/wiki/NetworkDiagram
226
227Note the Nagios parent bullet points:
228
229Nagios Parent Relationships
230
231
232STEPS 2a - 2c SHOULD BE REPEATED WHENEVER YOU UPDATE THE CONFIGURATION!
233   
234
2352a. Verify that your configuration files are OK:
236
237    # nagios3 -v /etc/nagios3/nagios.cfg
238
239    ... You should get some warnings like :
240Warning: Host 'rtr' has no services associated with it!
241Warning: Host 'sw' has no services associated with it!
242etc....
243...
244Total Warnings: N
245Total Errors:   0
246
247Things look okay - No serious problems were detected during the check.
248Nagios is saying that it's unusual to monitor a device just for its
249existence on the network, without also monitoring some service.
250
251
2522b. Reload/Restart Nagios
253
254    # /etc/init.d/nagios3 restart
255
256Not always 100% reliable to use the "restart" option due to a bug in the Nagios init script.
257To be sure you may want to get used to doing:
258
259    # /etc/init.d/nagios3 stop
260    # /etc/init.d/nagios3 start
261
262
2632c. Go to the web interface (http://pcN.ws.nsrc.org/nagios3) and check that the hosts
264   you just added are now visible in the interface. Click on the "Host Detail" item
265   on the left of the Nagios screen to see this. You may see it in "PENDING"
266   status until the check is carried out.
267
268
269HINT: You will be doing this a lot. If you do it all on one line, like this,
270then you can hit cursor-up and rerun all in one go:
271
272    nagios3 -v /etc/nagios3/nagios.cfg && /etc/init.d/nagios3 restart
273
274The '&&' ensures that the restart only happens if the config is valid.
275
276
2773. Create entries for the classroom PCs
278
279Now that we have our routers and switches defined it is quite easy to create
280entries for all our PCs.  Think about the parent relationships:
281
282Remember, if you do not understand the parent relationship refer back to the
283classroom network diagram here:
284
285        http://noc.ws.nsrc.org/wiki/wiki/NetworkDiagram
286
287Below are three sample entries. One for the NOC, one for pc1 and one for
288pc26.  You should be able to use this example to create entries for all
289classroom PCs plus the NOC.
290
291We could put these entries in to separate files, but as our network is small
292we'll use a single file called pcs.cfg.
293
294NOTE! You do not add in an entry for your own PC or router. This has already
295been defined in the file /etc/nagios3/conf.d/localhost_nagios2.cfg.  This
296definition is what defines the Nagios network viewpoint. So, when you come to
297the spot where you might add an entry for your PC you should skip this and go
298on to the next PC in the list. ***** Let us first describe the machines in our
299noc which at the moment comprises of one machine
300
301        # vi noc.cfg
302       
303# Our classroom NOC
304
305define host {
306    use         generic-host
307    host_name   noc
308    alias       Workshop NOC machine
309    address     10.10.0.254
310    parents     sw
311}
312
313
314Save and exit the file. Next, create a file to describe the devices in group one
315as follows:
316
317        # vi group1pcs.cfg
318# PCs
319
320define host {
321    use         generic-host
322    host_name   pc1
323    alias       pc1
324    address     10.10.1.1
325    parents     rtr1
326}
327
328define host {
329    use         generic-host
330    host_name   pc3
331    alias       pc3
332    address     10.10.1.3
333    parents     rtr1
334        }
335
336
337
338Do this for all the PCs in group1, note that the parent is maintained. When done, save and exit the file.
339
340Do the same for group2 pcs:
341
342        # vi group2pcs.cfg
343
344define host {
345    use         generic-host
346    host_name   pc2
347    alias       pc2
348    address     10.10.2.2
349    parents     rtr2
350        }
351
352
353define host {
354    use         generic-host
355    host_name   pc4
356    alias       pc4
357    address     10.10.2.4
358    parents     rtr2
359        }
360
361
362Do this for all the PCs in group2, note that the parent is maintained. When done, save and exit the file.
363
364
365Pay attention to the parent entries and the IP addresses.
366
367Take the three entries above and expand to create the remaining
368entries organized per group for all active PCs. That is, fill in for PCs 1 through 39 (rememember to
369skip your PC) per group
370
371
372As before, repeat steps 2a-2c to verify your configuration, correct any
373errors, and activate it.
374
3755. Look at your Nagios instance on the web. Note that "Status Map" gives
376you a graphical view of the parent-child relationships you have defined.
377
378
379PART III
380Configure Service check for the classroom NOC
381-----------------------------------------------------------------------------
382
3830. Configuring
384
385Now that we have our hardware configured we can start telling Nagios what services to monitor
386on the configured hardware, how to group the hardware in interesting ways, how to group
387services, etc.
388
3891. Associate a service check for our classroom NOC
390
391    # vi hostgroups_nagios2.cfg
392
393    - Find the hostgroup named "ssh-servers". In the members section of the defintion
394      change the line:
395
396members                 localhost
397
398    to
399
400members                 localhost,noc
401
402Exit and save the file.
403
404Verify that your changes are OK:
405
406        # nagios3 -v /etc/nagios3/nagios.cfg
407       
408Restart Nagios to see the new service assocation with your host:
409
410        # /etc/init.d/nagios3 restart
411
412Click on the "Service Detail" link in the Nagios web interface to see your new entry.
413
414
415PART IV
416Defining Services for all PCs
417-----------------------------------------------------------------------------
418
4190. For services, the default normal_check_interval is 5 (minutes) in
420   generic-service_nagios2.cfg. You may wish to change this to 1 to speed up
421   how quickly service issues are detected, at least in the workshop.
422
4231. Determine what services to define for what devices
424
425   - This is core to how you use Nagios and network monitoring tools in
426     general. So far we are simply using ping to verify that physical hosts
427     are up on our network and we have started monitoring a single service on
428     a single host (your PC). The next step is to decide what services you wish
429     to monitor for each host in the classroom.
430
431   - In this particular class we have:
432
433     routers:  running ssh and snmp
434     switches: running telnet and possibly ssh as well as snmp
435     pcs:      All PCs are running ssh and http and should be running snmp
436               The NOC is currently running an snmp daemon
437             
438     So, let's configure Nagios to check for these services for these
439     devices.
440
4412.) Verify that SSH is running on the routers and workshop PCs images
442
443   - In the file services_nagios2.cfg there is already an entry for the SSH
444     service check, so you do not need to create this step. Instead, you
445     simply need to re-define the "ssh-servers" entry in the file
446     /etc/nagios3/conf.d/hostgroups_nagios2.cfg. The initial entry in the file
447     looked like:
448
449# A list of your ssh-accessible servers
450define hostgroup {
451        hostgroup_name  ssh-servers
452                alias           SSH servers
453                members         localhost,noc
454        }
455
456     What do you think you should change? Correct, the "members" line. You should
457     add in entries for all the classroom pcs, routers and  the switches that run ssh.
458     With this information and the network diagram you should be able complete this entry.
459     
460     The entry will look something like this:
461
462define hostgroup {
463        hostgroup_name  ssh-servers
464                alias           SSH servers
465                members         localhost,pc1,pc2,pc3,pc4...,pc26,....ap1,ap2,s1,s2,noc,rtr1
466        }
467
468         Note: leave in "localhost" - This is your PC and represents Nagios' network point of
469         view. So, for instance, if you are on "pc3" you would not include "pc3" in the list
470         of all the classroom pcs as it is represented by the "localhost" entry.
471         
472         The "members" entry will be a long line and will likely wrap on the screen.
473
474         Remember to include all your PCs and all your routers that you have defined. Do no
475         include any entries if they are not already defined in pcs.cfg, switches.cfg or
476         routers.cfg.
477
478    - Once you are done, run the pre-flight check:
479
480    # nagios3 -v /etc/nagios3/nagios.cfg
481
482    If everything looks good, then restart Nagios
483
484    # /etc/init.d/nagios3 stop
485    # /etc/init.d/nagios3 start
486
487    and view your changes in the Nagios web interface.
488
489To continue with hostgroups you can add additional groups for later use, such as all our virtual
490servers. Go ahead and edit the file hostgroups_nagios2.cfg again:
491
492     # vi hostgroups_nagios2.cfg
493
494and add the following to the end of the file:
495
496# A list of our virtual routers
497define hostgroup {
498        hostgroup_name  cisco7200
499                alias           Cisco 7200 Routers
500                members         rtr1,rtr2,rtr3,rtr4,rtr5,rtr6,rtr7,rtr8,rtr9
501        }
502
503Save and exit from the file. Verify that everything is OK:
504
505    # nagios3 -v /etc/nagios3/nagios.cfg
506
507    If everything looks good, then restart Nagios
508
509    # /etc/init.d/nagios3 stop
510    # /etc/init.d/nagios3 start
511
5123.) Check that http is running on all the classroom PCs.
513
514    - This is almost identical to the previous exercise. Just make the change to the
515      HTTP service adding in each PC (no routers or switches). Remember, you don't need
516      to add your machine as it is already defined as "localhost".     
517
5184.)  OPTIONAL EXTRA: as opposed to just checking that a web server is
519     running on the classroom PCs, you could also check that the nagios3
520     service is available, by requesting the /nagios3/ path. This means
521     passing extra options to the check_http plugin.
522
523     For a description of the available options, type this:
524
525      # /usr/lib/nagios/plugins/check_http
526      # /usr/lib/nagios/plugins/check_http --help
527
528     and of course you can browse the online nagios documentation or google
529     for information on check_http. You can even run the plugin by hand to
530     perform a one-shot service check:
531
532     # /usr/lib/nagios/plugins/check_http -H localhost -u /nagios3/
533
534     So the goal is to configure nagios to call check_http in this way. Create
535a file to store the information, lets call it afnog.cfg
536       
537# vi afnog.cfg
538
539       
540define command{
541        command_name    check_http_arg
542        command_line    /usr/lib/nagios/plugins/check_http -H '$HOSTADDRESS$' $ARG1$
543        }
544
545define service {
546        hostgroup_name                  nagios-servers
547        service_description             NAGIOS
548        check_command                   check_http_arg!-u /nagios3/
549        use                             generic-service
550}
551
552
553        Save and exit the file and of course you'll need to create a hostgroup called nagios-servers to
554     link to this service check.
555
556        # vi hostgroups_nagios2.cfg
557
558At the bottom add the following:
559
560        define hostgroup {
561        hostgroup_name  nagios-servers
562        alias Servers running Nagios
563        members localhost,pc1,pc2,pc3,pc4
564        }
565       
566        Add all the servers in the room (upto 39)
567
568     Once you have done this, check that Nagios warns you about failing
569     authentication (because it's trying to fetch the page without providing
570     the username/password). There's an extra parameter you can pass to
571     check_http_arg to provide that info, see if you can find it.
572
573      WARNING: in the tradition of "Debian Knows Best", their definition of the
574      check_http command in /etc/nagios-plugins/config/http.cfg
575      is *not* the same as that recommended in the nagios3 documentation.
576      It is missing $ARG1$, so any parameters to pass to check_http are
577      ignored. So you might think you are monitoring /nagios3/ but actually
578      you are monitoring root!
579
580     This is why we had to make a new command definition "check_http_arg".
581     You could make a more specific one like "check_nagios", or you could
582     modify the Ubuntu check_http definition to fit the standard usage.
583
584
585
586PART V
587Create More Host Groups
588-----------------------------------------------------------------------------
589
5900. In the web view, look at the pages "Hostgroup Overview", "Hostgroup
591   Summary", "Hostgroup Grid". This gives a convenient way to group together
592   hosts which are related (e.g. in the same site, serving the same purpose).
593
5941. Update /etc/nagios3/conf.d/hostgroups_nagios2.cfg
595
596    - For the following exercises it will be very useful if we have created
597      or update the following hostgroups:
598
599      debian-servers
600      routers
601      switches
602 
603      If you edit the file /etc/nagios3/conf.d/hostgroups_nagios2.cfg you
604      will see an entry for debian-servers that just contains localhost.
605      Update this entry to include all the classroom PCs, including the
606      noc (this assumes that you created a "noc" entry in your pcs.cfg
607      file). Remember to skip your PC entry as it is represented by the
608      localhost entry.
609
610    # vi /etc/nagios3/conf.d/hostgroups_nagios2.cfg
611
612     Update the entry that says:
613
614
615# A list of your Debian GNU/Linux servers
616define hostgroup {
617        hostgroup_name  debian-servers
618                alias           Debian GNU/Linux Servers
619                members         localhost
620        }
621     
622      So that the "members" parameter contains something like this. Use your
623      classroom network diagram to confirm the exact number of machines and names
624      in your workshop.
625
626                members         localhost,pc1,pc2,pc3,pc4,pc5,pc6,pc7,pc8,pc9
627                                pc10,pc11,pc12,pc13,pc14,pc15,pc16,pc17,pc18,
628                                pc19,pc20,pc21,pc22,pc23,pc24,pc25,pc26
629
630        Be sure that the line wraps and is not on two separate lines. Otherwise
631        you will get an error when you go to restart Nagios. Remember that
632        your own PC is "localhost".
633
634      - Once you have done this, add in two more host groups, one for routers and
635        one for switches. Call these entries "routers" and "switches".
636
637      - When you are done be sure to verify your work and restart Nagios.
638
639      - Remember to skip your pc entry as it is represented by the localhost entry.
640 
6412. Go back to the web interface and look at your new hostgroups
642
643
644PART VI
645Extended Host Information ("making your graphs pretty")
646-----------------------------------------------------------------------------
647
6481. Update extinfo_nagios2.cfg
649
650    - If you would like to use appropriate icons for your defined hosts in
651      Nagios this is where you do this. We have the three types of devices:
652
653      Cisco routers
654      Cisco switches
655      Ubuntu servers
656
657      There is a fairly large repository of icon images available for you to
658      use located here:
659
660      /usr/share/nagios3/htdocs/images/logos/
661
662      these were installed by default as dependent packages of the nagios3
663      package in Ubuntu. In some cases you can find model-specific icons for
664      your hardware, but to make things simpler we will use the following
665      icons for our hardware:
666
667      /usr/share/nagios3/htdocs/images/logos/base/debian.*
668      /usr/share/nagios3/htdocs/images/logos/cook/router.*
669      /usr/share/nagios3/htdocs/images/logos/cook/switch.*
670
671    - The next step is to edit the file /etc/nagios3/conf.d/extinfo_nagios2.cfg
672      and tell nagios what image you would like to use to represent your devices.
673
674    # vi /etc/nagios3/conf.d/extinfo_nagios2.cfg
675
676      Here is what an entry for your routers looks like (there is already an entry
677      for debian-servers that will work as is). Note that the router model (3600)
678      is not all that important. The image used represents a router in general.
679
680define hostextinfo {
681        hostgroup_name   routers
682        icon_image       cook/router.png
683        icon_image_alt   Cisco Routers (3600)
684        vrml_image       router.png
685        statusmap_image  cook/router.gd2
686}
687
688      Now add an entry for your switches. Once you are done check your
689      work and restart Nagios. Take a look at the Status Map in the web interface.
690      It should be much nicer, with real icons instead of question marks.
691
692
693PART VII
694Create Service Groups
695-----------------------------------------------------------------------------
696
6971. Create service groups for ssh and http for each set of pcs.
698
699   - The idea here is to create three service groups. Each service group will
700     be for a quarter of the classroom. We want to see these PCs grouped together
701     and include status of their ssh and http services. To do this edit
702     and create the file:
703
704   # vi /etc/nagios3/conf.d/servicegroups.cfg
705
706     Here is a sample of the service group for group 1:
707
708define servicegroup {
709        servicegroup_name       group1-servers
710        alias                   group 1 servers
711        members                 pc1,SSH,pc1,HTTP,pc2,SSH,pc2,HTTP,pc3,SSH,pc3,HTTP,pc4,SSH,pc4
712        }
713
714        - Note that the members line should wrap and not be on two lines.
715       
716        - Note that "SSH" and "HTTP" need to be uppercase as this is how the service_description is
717          written in the file /etc/nagios3/conf.d/services_nagios2.cfg
718         
719        - You should create an entry for other groups of servers too
720
721    - Save your changes, verify your work and restart Nagios. Now if you click on
722      the Servicegroup menu items in the Nagios web interface you should see
723      this information grouped together.
724
725
726
727PART VIII
728Configure Guest Access to the Nagios Web Interface
729-----------------------------------------------------------------------------
730
7311. Edit /etc/nagios3/cgi.cfg to give read-only guest user access to the Nagios
732   web interface.
733
734    - By default Nagios is configured to give full r/w access via the Nagios
735      web interface to the user nagiosadmin. You can change the name of this
736      user, add other users, change how you authenticate users, what users
737      have access to what resources and more via the cgi.cfg file.
738
739    - First, lets create a "guest" user and password in the htpasswd.users
740      file.
741     
742    # htpasswd /etc/nagios3/htpasswd.users guest
743
744      You can use any password you want (or none). A password of "guest" is
745      not a bad choice.
746
747    - Next, edit the file /etc/nagios3/cgi.cfg and look for what type of access
748      has been given to the nagiosadmin user. By default you will see the following
749      directives (note, there are comments between each directive):
750
751      authorized_for_system_information=nagiosadmin
752      authorized_for_configuration_information=nagiosadmin
753      authorized_for_system_commands=nagiosadmin
754      authorized_for_all_services=nagiosadmin
755      authorized_for_all_hosts=nagiosadmin
756      authorized_for_all_service_commands=nagiosadmin
757      authorized_for_all_host_commands=nagiosadmin
758
759      Now let's tell Nagios to allow the "guest" user some access to
760      information via the web interface. You can choose whatever you would
761      like, but what is pretty typical is this:
762
763      authorized_for_system_information=nagiosadmin,guest
764      authorized_for_configuration_information=nagiosadmin,guest
765      authorized_for_system_commands=nagiosadmin
766      authorized_for_all_services=nagiosadmin,guest
767      authorized_for_all_hosts=nagiosadmin,guest
768      authorized_for_all_service_commands=nagiosadmin
769      authorized_for_all_host_commands=nagiosadmin
770
771    - Once you make the changes, save the file cgi.cfg, verify your
772      work and restart Nagios.
773
774    - To see if you can log in as the "guest" user you may need to clear
775      the cookies in your web browser. You will not notice any difference
776      in the web interface. The difference is that a number of items that
777      are available via the web interface (forcing a service/host check,
778      scheduling checks, comments, etc.) will not work for the guest
779      user.
780
781
782OPTIONAL
783--------
784
785* Check that SNMP is running on the classroom NOC
786
787    - First you will need to add in the appropriate service check for SNMP in the file
788      /etc/nagios3/conf.d/services_nagios2.cfg. This is where Nagios is impressive. There
789      are hundreds, if not thousands, of service checks available via the various Nagios
790      sites on the web. You can see what plugins are installed by Ubuntu in the nagios3
791      package that we've installed by looking in the following directory:
792
793    # ls /usr/lib/nagios/plugins
794
795      As you'll see there is already a check_snmp plugin available to us. If you are
796      interested in the options the plugin takes you can execute the plugin from the
797      command line by typing:
798
799    # /usr/lib/nagios/plugins/check_snmp
800    # /usr/lib/nagios/plugins/check_snmp --help
801
802      to see what options are available, etc. You can use the check_snmp plugin and
803      Nagios to create very complex or specific system checks.
804
805    - Now to see all the various service/host checks that have been created using the
806      check_snmp plugin you can look in /etc/nagios-plugins/config/snmp.cfg. You will
807      see that there are a lot of preconfigured checks using snmp, including:
808
809      snmp_load
810      snmp_cpustats
811      snmp_procname
812      snmp_disk
813      snmp_mem
814      snmp_swap
815      snmp_procs
816      snmp_users
817      snmp_mem2
818      snmp_swap2
819      snmp_mem3
820      snmp_swap3
821      snmp_disk2
822      snmp_tcpopen
823      snmp_tcpstats
824      snmp_bgpstate
825      check_netapp_uptime
826      check_netapp_cupuload
827      check_netapp_numdisks
828      check_compaq_thermalCondition
829     
830      And, even better, you can create additional service checks quite easily.
831      For the case of verifying that snmpd (the SNMP service on Linux) is running we
832      need to ask SNMP a question. If we don't get an answer, then Nagios can assume
833      that the SNMP service is down on that host. When you use service checks such as
834      check_http, check_ssh and check_telnet this is what they are doing as well.
835
836    - In our case, let's create a new service check and call it "check_system". This
837      service check will connect with the specified host, use the private community
838      string we have defined in class and ask a question of snmp on that ask - in this
839      case we'll ask about the System Description, or the OID "sysDescr.0" -
840
841    - To do this start by editing the file /etc/nagios-plugins/config/snmp.cfg:
842
843    # joe /etc/nagios-plugins/config/snmp.cfg
844
845      At the top (or the bottom, your choice) add the following entry to the file:
846
847# 'check_system' command definition
848define command{
849       command_name    check_system
850       command_line    /usr/lib/nagios/plugins/check_snmp -H '$HOSTADDRESS$' -C
851'$ARG1$' -o sysDescr.0
852        }
853     
854      You may wish to copy and paste this vs. trying to type this out.
855
856          Note that "command_line" is a single line. If you copy and paste in joe the line
857          may not wrap properly and you may have to manually add the part:
858         
859                        '$ARG1$' -o sysDescr.0
860                       
861          to the end of the line.
862
863    - Now you need to edit the file /etc/nagios3/conf.d/services_nagios2.cfg and add
864      in this service check. We'll run this check against all our servers in the
865      classroom, or the hostgroup "debian-servers"
866
867    - Edit the file /etc/nagios3/conf.d/services_nagios2.cfg
868
869    # joe /etc/nagios3/conf.d/services_nagios2.cfg
870
871      At the bottom of the file add the following definition:
872
873# check that snmp is up on all servers
874define service {
875        hostgroup_name                  snmp-servers
876        service_description             SNMP
877        check_command                   check_system!xxxxxx
878        use                             generic-service
879        notification_interval           0 ; set > 0 if you want to be renotified
880}
881
882      The "xxxxxx" is the community string previously (or to be) defined in class.
883     
884      Note that we have included our private community string here vs. hard-coding
885      it in the snmp.cfg file earlier. You must change the "xxxxx" to be the snmp
886      community string given in class or this check will not work.
887     
888    - Now we must create the "snmp-servers" group in our hostgroups_nagios2.cfg file.
889      Edit the file /etc/nagios3/conf.d/hostgroups_nagios2.cfg and go to the end of the
890      file. Add in the following hostgroup definition:
891     
892# A list of snmp-enabled devices on which we wish to run the snmp service check
893define hostgroup {
894           hostgroup_name       snmp-servers
895                   alias        snmp servers
896                   members      noc
897          }
898         
899        - Note that for "members" you could, also, add in the switches and routers for
900          group 1 and 2. But, the particular item (MIB) we are checking for "sysDescr.0"
901          may not be available on the switches and/or routers, so the check would then fail.
902
903    - Now verify that your changes are correct and restart Nagios.
904
905    - If you click on the Service Detail menu choice in web interface you should see
906      the SNMP check appear for the noc host.
907     
908    - After we do the SNMP presentation and exercises in class, then you could come
909      back to this exercise and add in all the classroom PCs to the members list in the
910      hostgroups_nagios2.cfg file, snmp-servers hostgroup definition. Remember to list
911      your PC as "localhost".