Agenda: exercises-nagios-IX-optional.txt

File exercises-nagios-IX-optional.txt, 8.6 KB (added by b.candler, 6 years ago)
Line 
1Nagios Installation and Configuration
2
3Notes:
4------
5* Commands preceded with "$" imply that you should execute the command as
6  a general user - not as root.
7* Commands preceded with "#" imply that you should be working as root.
8* Commands with more specific command lines (e.g. "RTR-GW>" or "mysql>")
9  imply that you are executing commands on remote equipment, or within
10  another program.
11
12Exercises
13---------
14
15
16PART IX
17Optional Exercises
18-------------------------------------------------------------------------------
19
201. Check that nagios is Running
21-------------------------------
22
23As opposed to just checking that a web server is running on the classroom PCs,
24you could also check that t
25he nagios3 service is available, by requesting the
26/nagios3/ path. This means passing extra options to the check_http plugin.
27
28For a description of the available options, type this:
29
30      # /usr/lib/nagios/plugins/check_http                                      (short help)
31      # /usr/lib/nagios/plugins/check_http --help                       (detailed help)
32
33and of course you can browse the online nagios documentation or google
34for information on check_http. You can even run the plugin by hand to
35perform a one-shot service check:
36
37     # /usr/lib/nagios/plugins/check_http -H localhost -u /nagios3/
38
39So the goal is to configure nagios to call check_http in this way.
40
41        (hint, /etc/nagios-plugins/config/http.cfg)
42
43define command{
44        command_name    check_http_arg
45        command_line    /usr/lib/nagios/plugins/check_http -H '$HOSTADDRESS$' '$ARG1$'
46        }
47
48        (hint, /etc/nagios3/conf.d/services_nagios2.cfg_
49
50define service {
51        hostgroup_name                  nagios-servers
52        service_description             NAGIOS
53        check_command                   check_http_arg!-u /nagios3/
54        use                             generic-service
55}
56
57     and of course you'll need to create a hostgroup called nagios-servers to
58     link to this service check. (hint, /etc/nagios3/conf.d/hostgroups_nagios2.cfg)
59
60     Once you have done this, check that Nagios warns you about failing
61     authentication (because it's trying to fetch the page without providing
62     the username/password). There's an extra parameter you can pass to
63     check_http_arg to provide that info, see if you can find it.
64
65      WARNING: in the tradition of "Debian Knows Best", their definition of the
66      check_http command in /etc/nagios-plugins/config/http.cfg
67      is *not* the same as that recommended in the nagios3 documentation.
68      It is missing $ARG1$, so any parameters to pass to check_http are
69      ignored. So you might think you are monitoring /nagios3/ but actually
70      you are monitoring root!
71
72     This is why we had to make a new command definition "check_http_arg".
73     You could make a more specific one like "check_nagios", or you could
74     modify the Ubuntu check_http definition to fit the standard usage.
75
76
77
782. Check that SNMP is running on the classroom NOC
79----------------------------------------------------
80
81    - This exercise will not work if you did not complete the installation of additional
82      SNMP MIBs at the start of the week and configure /etc/snmp/snmp.conf properly. Please refer to the original snmp exercises if you are unsure.
83 
84    - First you will need to add in the appropriate service check for SNMP in the file
85      /etc/nagios3/conf.d/services_nagios2.cfg. This is where Nagios is impressive. There
86      are hundreds, if not thousands, of service checks available via the various Nagios
87      sites on the web. You can see what plugins are installed by Ubuntu in the nagios3
88      package that we've installed by looking in the following directory:
89
90    # ls /usr/lib/nagios/plugins
91
92      As you'll see there is already a check_snmp plugin available to us. If you are
93      interested in the options the plugin takes you can execute the plugin from the
94      command line by typing:
95
96    # /usr/lib/nagios/plugins/check_snmp                                                (short help)
97    # /usr/lib/nagios/plugins/check_snmp --help                                 (detailed help)
98
99      to see what options are available, etc. You can use the check_snmp plugin and
100      Nagios to create very complex or specific system checks.
101
102    - Now to see all the various service/host checks that have been created using the
103      check_snmp plugin you can look in /etc/nagios-plugins/config/snmp.cfg. You will
104      see that there are a lot of preconfigured checks using snmp, including:
105
106      snmp_load
107      snmp_cpustats
108      snmp_procname
109      snmp_disk
110      snmp_mem
111      snmp_swap
112      snmp_procs
113      snmp_users
114      snmp_mem2
115      snmp_swap2
116      snmp_mem3
117      snmp_swap3
118      snmp_disk2
119      snmp_tcpopen
120      snmp_tcpstats
121      snmp_bgpstate
122      check_netapp_uptime
123      check_netapp_cupuload
124      check_netapp_numdisks
125      check_compaq_thermalCondition
126     
127      And, even better, you can create additional service checks quite easily.
128      For the case of verifying that snmpd (the SNMP service on Linux) is running we
129      need to ask SNMP a question. If we don't get an answer, then Nagios can assume
130      that the SNMP service is down on that host. When you use service checks such as
131      check_http, check_ssh and check_telnet this is what they are doing as well.
132
133    - In our case, let's create a new service check and call it "check_system". This
134      service check will connect with the specified host, use the private community
135      string we have defined in class and ask a question of snmp on that host - in this
136      case we'll ask about the System Description, or the OID "sysDescr.0" -
137
138    - To do this start by editing the file /etc/nagios-plugins/config/snmp.cfg:
139
140    # editor /etc/nagios-plugins/config/snmp.cfg
141
142      At the top (or the bottom, your choice) add the following entry to the file:
143
144# 'check_system' command definition
145define command{
146       command_name    check_system
147       command_line    /usr/lib/nagios/plugins/check_snmp -H '$HOSTADDRESS$' -C '$ARG1$' -o sysDescr.0
148        }
149     
150      COPY and PASTE this. Do not type this by hand and make sure that the command_line line
151      does not wrap.
152
153          Note that "command_line" is a single line. If you copy and paste in
154          your editor, the line may not wrap properly and you may have to manually
155          "join" the two lines so they are one.
156         
157    - Now you need to edit the file /etc/nagios3/conf.d/services_nagios2.cfg and add
158      in this service check. We'll run this check against all our servers in the
159      classroom, or the hostgroup "debian-servers"
160
161    - Edit the file /etc/nagios3/conf.d/services_nagios2.cfg
162
163    # editor /etc/nagios3/conf.d/services_nagios2.cfg
164
165      At the bottom of the file add the following definition:
166
167# check that snmp is up on all servers
168define service {
169        hostgroup_name                  snmp-servers
170        service_description             SNMP
171        check_command                   check_system!xxxxxx
172        use                             generic-service
173        notification_interval           0 ; set > 0 if you want to be renotified
174}
175
176      The "xxxxxx" is the community string previously (or to be) defined in class.
177     
178      Note that we have included our own community string here vs. hard-coding
179      it in the snmp.cfg file earlier. You must change the "xxxxx" to be the snmp
180      community string given in class or this check will not work.
181     
182    - Now we must create the "snmp-servers" group in our hostgroups_nagios2.cfg file.
183      Edit the file /etc/nagios3/conf.d/hostgroups_nagios2.cfg and go to the end of the
184      file. Add in the following hostgroup definition:
185     
186# A list of snmp-enabled devices on which we wish to run the snmp service check
187define hostgroup {
188           hostgroup_name       snmp-servers
189                   alias        snmp servers
190                   members      noc,localhost,pc1,pc2,pc3,pc4...pc36,rtr1,rtr2,rtr3...rtr9
191          }
192         
193        - Note that for "members" you can add in all PCs and routers as they should all
194          have snmp up and running at this time. Remember to EXCLUDE our pc and use
195          localhost instead.
196       
197    - Now verify that your changes are correct and restart Nagios.
198   
199      # service nagios3 restart
200     
201        - **** Defect / Bug in Ubuntu 12.04 LTS ***
202            The net-snmp 5.6.x package appears to not install one of the IANA mibs (IANAifType-MIB).
203            This causes a MIB error, which, in turn causes the snmp check plugin to fail. To fix
204            this problem do the following (as root):
205
206                        # cd /usr/share/mibs
207                        # wget http://www.iana.org/assignments/ianaiftype-mib/ianaiftype-mib
208                        # mv ianaiftype-mib ianaiftype-mib.my
209
210            And, no you can continue.
211
212    - If you click on the Service Detail menu choice in web interface you should see
213      the SNMP check appear for the noc host, or for any other hosts you may have
214      included on the "members" line above.
215     
216
217