1 | |
---|
2 | Nagios Installation and Configuration |
---|
3 | |
---|
4 | |
---|
5 | PART V |
---|
6 | Create More Host Groups |
---|
7 | ----------------------------------------------------------------------------- |
---|
8 | |
---|
9 | 0. In the web view, look at the pages "Hostgroup Overview", "Hostgroup |
---|
10 | Summary", "Hostgroup Grid". This gives a convenient way to group together |
---|
11 | hosts which are related (e.g. in the same site, serving the same purpose). |
---|
12 | |
---|
13 | 1. Update /etc/nagios3/conf.d/hostgroups_nagios2.cfg |
---|
14 | |
---|
15 | - For the following exercises it will be very useful if we have created |
---|
16 | or update the following hostgroups: |
---|
17 | |
---|
18 | debian-servers |
---|
19 | routers |
---|
20 | switches |
---|
21 | |
---|
22 | If you edit the file /etc/nagios3/conf.d/hostgroups_nagios2.cfg you |
---|
23 | will see an entry for debian-servers that just contains localhost. |
---|
24 | Update this entry to include all the classroom PCs, including the |
---|
25 | noc (this assumes that you created a "noc" entry in your pcs.cfg |
---|
26 | file). Remember to skip your PC entry as it is represented by the |
---|
27 | localhost entry. |
---|
28 | |
---|
29 | # editor /etc/nagios3/conf.d/hostgroups_nagios2.cfg |
---|
30 | |
---|
31 | Update the entry that says: |
---|
32 | |
---|
33 | |
---|
34 | # A list of your Debian GNU/Linux servers |
---|
35 | define hostgroup { |
---|
36 | hostgroup_name debian-servers |
---|
37 | alias Debian GNU/Linux Servers |
---|
38 | members localhost |
---|
39 | } |
---|
40 | |
---|
41 | So that the "members" parameter contains something like this. Use your |
---|
42 | classroom network diagram if in doubt. |
---|
43 | |
---|
44 | members localhost,pc1,pc2,pc3,pc4,pc5,pc6 |
---|
45 | |
---|
46 | Remember to replace the pc1 -- 6 with the pcs on your table. |
---|
47 | |
---|
48 | Be sure that the line wraps and is not on two separate lines. Otherwise |
---|
49 | you will get an error when you go to restart Nagios. Remember that |
---|
50 | your own PC is "localhost". |
---|
51 | |
---|
52 | - Once you have done this, add in two more host groups, one for routers and |
---|
53 | one for switches. Call these entries "routers" and "switches". |
---|
54 | |
---|
55 | - When you are done be sure to verify your work and restart Nagios. |
---|
56 | |
---|
57 | - Remember to skip your pc entry as it is represented by the localhost entry. |
---|
58 | |
---|
59 | 2. Go back to the web interface and look at your new hostgroups |
---|
60 | |
---|
61 | |
---|
62 | PART VI |
---|
63 | Create Service Groups |
---|
64 | ----------------------------------------------------------------------------- |
---|
65 | |
---|
66 | 1. Create service groups for ssh and http for each set of pcs. |
---|
67 | |
---|
68 | - The idea here is to create five service groups. Each service group will |
---|
69 | be for a table. We want to see these PCs grouped together by table |
---|
70 | and include status of their ssh and http services. To do this edit |
---|
71 | and create the file: |
---|
72 | |
---|
73 | # editor /etc/nagios3/conf.d/servicegroups.cfg |
---|
74 | |
---|
75 | Here is a sample of the service group for group 1: |
---|
76 | |
---|
77 | define servicegroup { |
---|
78 | servicegroup_name group1-servers |
---|
79 | alias group 1 servers |
---|
80 | members pc1,SSH,pc1,HTTP,pc2,SSH,pc2,HTTP,pc3,SSH,pc3,HTTP,pc4,SSH,pc4 |
---|
81 | } |
---|
82 | |
---|
83 | - Note that the members line should wrap and not be on two lines. |
---|
84 | |
---|
85 | - Note that "SSH" and "HTTP" need to be uppercase as this is how the service_description is |
---|
86 | written in the file /etc/nagios3/conf.d/services_nagios2.cfg |
---|
87 | |
---|
88 | - You should create an entry for other groups of servers too |
---|
89 | |
---|
90 | - Save your changes, verify your work and restart Nagios. Now if you click on |
---|
91 | the Servicegroup menu items in the Nagios web interface you should see |
---|
92 | this information grouped together. |
---|
93 | |
---|
94 | |
---|
95 | |
---|
96 | OPTIONAL |
---|
97 | -------- |
---|
98 | |
---|
99 | * Check that SNMP is running on the classroom NOC |
---|
100 | |
---|
101 | - First you will need to add in the appropriate service check for SNMP in the file |
---|
102 | /etc/nagios3/conf.d/services_nagios2.cfg. This is where Nagios is impressive. There |
---|
103 | are hundreds, if not thousands, of service checks available via the various Nagios |
---|
104 | sites on the web. You can see what plugins are installed by Ubuntu in the nagios3 |
---|
105 | package that we've installed by looking in the following directory: |
---|
106 | |
---|
107 | # ls /usr/lib/nagios/plugins |
---|
108 | |
---|
109 | As you'll see there is already a check_snmp plugin available to us. If you are |
---|
110 | interested in the options the plugin takes you can execute the plugin from the |
---|
111 | command line by typing: |
---|
112 | |
---|
113 | # /usr/lib/nagios/plugins/check_snmp |
---|
114 | # /usr/lib/nagios/plugins/check_snmp --help |
---|
115 | |
---|
116 | to see what options are available, etc. You can use the check_snmp plugin and |
---|
117 | Nagios to create very complex or specific system checks. |
---|
118 | |
---|
119 | - Now to see all the various service/host checks that have been created using the |
---|
120 | check_snmp plugin you can look in /etc/nagios-plugins/config/snmp.cfg. You will |
---|
121 | see that there are a lot of preconfigured checks using snmp, including: |
---|
122 | |
---|
123 | snmp_load |
---|
124 | snmp_cpustats |
---|
125 | snmp_procname |
---|
126 | snmp_disk |
---|
127 | snmp_mem |
---|
128 | snmp_swap |
---|
129 | snmp_procs |
---|
130 | snmp_users |
---|
131 | snmp_mem2 |
---|
132 | snmp_swap2 |
---|
133 | snmp_mem3 |
---|
134 | snmp_swap3 |
---|
135 | snmp_disk2 |
---|
136 | snmp_tcpopen |
---|
137 | snmp_tcpstats |
---|
138 | snmp_bgpstate |
---|
139 | check_netapp_uptime |
---|
140 | check_netapp_cupuload |
---|
141 | check_netapp_numdisks |
---|
142 | check_compaq_thermalCondition |
---|
143 | |
---|
144 | And, even better, you can create additional service checks quite easily. |
---|
145 | For the case of verifying that snmpd (the SNMP service on Linux) is running we |
---|
146 | need to ask SNMP a question. If we don't get an answer, then Nagios can assume |
---|
147 | that the SNMP service is down on that host. When you use service checks such as |
---|
148 | check_http, check_ssh and check_telnet this is what they are doing as well. |
---|
149 | |
---|
150 | - In our case, let's create a new service check and call it "check_system". This |
---|
151 | service check will connect with the specified host, use the private community |
---|
152 | string we have defined in class and ask a question of snmp on that ask - in this |
---|
153 | case we'll ask about the System Description, or the OID "sysDescr.0" - |
---|
154 | |
---|
155 | - To do this start by editing the file /etc/nagios-plugins/config/snmp.cfg: |
---|
156 | |
---|
157 | # joe /etc/nagios-plugins/config/snmp.cfg |
---|
158 | |
---|
159 | At the top (or the bottom, your choice) add the following entry to the file: |
---|
160 | |
---|
161 | # 'check_system' command definition |
---|
162 | define command{ |
---|
163 | command_name check_system |
---|
164 | command_line /usr/lib/nagios/plugins/check_snmp -H '$HOSTADDRESS$' -C |
---|
165 | '$ARG1$' -o sysDescr.0 |
---|
166 | } |
---|
167 | |
---|
168 | You may wish to copy and paste this vs. trying to type this out. |
---|
169 | |
---|
170 | Note that "command_line" is a single line. If you copy and paste in joe the line |
---|
171 | may not wrap properly and you may have to manually add the part: |
---|
172 | |
---|
173 | '$ARG1$' -o sysDescr.0 |
---|
174 | |
---|
175 | to the end of the line. |
---|
176 | |
---|
177 | - Now you need to edit the file /etc/nagios3/conf.d/services_nagios2.cfg and add |
---|
178 | in this service check. We'll run this check against all our servers in the |
---|
179 | classroom, or the hostgroup "debian-servers" |
---|
180 | |
---|
181 | - Edit the file /etc/nagios3/conf.d/services_nagios2.cfg |
---|
182 | |
---|
183 | # joe /etc/nagios3/conf.d/services_nagios2.cfg |
---|
184 | |
---|
185 | At the bottom of the file add the following definition: |
---|
186 | |
---|
187 | # check that snmp is up on all servers |
---|
188 | define service { |
---|
189 | hostgroup_name snmp-servers |
---|
190 | service_description SNMP |
---|
191 | check_command check_system!xxxxxx |
---|
192 | use generic-service |
---|
193 | notification_interval 0 ; set > 0 if you want to be renotified |
---|
194 | } |
---|
195 | |
---|
196 | The "xxxxxx" is the community string previously (or to be) defined in class. |
---|
197 | |
---|
198 | Note that we have included our private community string here vs. hard-coding |
---|
199 | it in the snmp.cfg file earlier. You must change the "xxxxx" to be the snmp |
---|
200 | community string given in class or this check will not work. |
---|
201 | |
---|
202 | - Now we must create the "snmp-servers" group in our hostgroups_nagios2.cfg file. |
---|
203 | Edit the file /etc/nagios3/conf.d/hostgroups_nagios2.cfg and go to the end of the |
---|
204 | file. Add in the following hostgroup definition: |
---|
205 | |
---|
206 | # A list of snmp-enabled devices on which we wish to run the snmp service check |
---|
207 | define hostgroup { |
---|
208 | hostgroup_name snmp-servers |
---|
209 | alias snmp servers |
---|
210 | members noc |
---|
211 | } |
---|
212 | |
---|
213 | - Note that for "members" you could, also, add in the switches and routers for |
---|
214 | group 1 and 2. But, the particular item (MIB) we are checking for "sysDescr.0" |
---|
215 | may not be available on the switches and/or routers, so the check would then fail. |
---|
216 | |
---|
217 | - Now verify that your changes are correct and restart Nagios. |
---|
218 | |
---|
219 | - If you click on the Service Detail menu choice in web interface you should see |
---|
220 | the SNMP check appear for the noc host. |
---|
221 | |
---|
222 | - After we do the SNMP presentation and exercises in class, then you could come |
---|
223 | back to this exercise and add in all the classroom PCs to the members list in the |
---|
224 | hostgroups_nagios2.cfg file, snmp-servers hostgroup definition. Remember to list |
---|
225 | your PC as "localhost". |
---|
226 | |
---|
227 | |
---|