~ubuntu-branches/ubuntu/raring/nagios3/raring

« back to all changes in this revision

Viewing changes to html/docs/monitoring-routers.html

  • Committer: Package Import Robot
  • Author(s): Alexander Wirt
  • Date: 2012-06-16 09:05:19 UTC
  • mfrom: (8.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20120616090519-1okxgkbe21vumokr
Tags: 3.4.1-1
* [28e077b] Imported Upstream version 3.3.1
* [d5314e0] don't call updatepo in clean target
* [45b3eb9] Don't remove config foo
* [54e3dff] Don't fix permissions in cgi postinst
* [d7be9db] Build-depend on libpng-dev (Closes: #662441)
* [4c47006] Add dutch po translation (Closes: #654855)
* [2b6573b] Refresh 10_p1_pl_shebang.dpatch
* [316fd7a] Update 40_fix_spurious_dollar_signs_added_to_command_lines
* [5ff2780] Refresh 55_strip_logarchivepath.dpatch
* [811d269] Refresh 60_fix_p1.pl_patch_mini_epn.dpatch
* [39a1e9c] Remove now unneeded patch 98_fix_XSS_CVE-2011-2179
* [785a4e8] Remove unneded patch 99_fix_XSS_CVE-2011-1523
* [6ce98ef] Remove unneeded patchs from 00list
* [1d18266] Imported Upstream version 3.4.0
* [05584c8] Refresh patches
* [58098cd] Imported Upstream version 3.4.1
* [3e9e07a] Bump standards version
* [fe991e2] wrap-and-sort
* [1ba78f7] Also create /var/run/nagios in cgi package (Closes: #626854)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
 
 
3
 
 
4
 
 
5
 
<html>
6
 
 
7
 
<head>
8
 
 
9
 
<title>Monitoring Routers and Switches</title>
10
 
 
11
 
 
12
 
 
13
 
<STYLE type="text/css">
14
 
 
15
 
<!--
16
 
 
17
 
        .Default { font-family: verdana,arial,serif; font-size: 8pt; }
18
 
 
19
 
        .PageTitle { font-family: verdana,arial,serif; font-size: 16pt; font-weight: bold; }
20
 
 
21
 
-->      
22
 
 
23
 
</STYLE>
24
 
 
25
 
 
26
 
 
27
 
</head>
28
 
 
29
 
 
30
 
 
31
 
<body bgcolor="#FFFFFF" text="black" class="Default">
32
 
 
33
 
 
34
 
 
35
 
<div align="center">
36
 
 
37
 
<img src="images/nagios.jpg" border="0" alt="Nagios" title="Nagios">
38
 
 
39
 
<h1 class="PageTitle">Monitoring Routers and Switches</h1>
40
 
 
41
 
</div>
42
 
 
43
 
 
44
 
 
45
 
<hr>
46
 
 
47
 
 
48
 
 
49
 
<p>
50
 
 
51
 
<img src="images/upto.gif" border="0" align="middle" alt="Up To" title="Up To">Up To: <a href="toc.html">Contents</a><br>
52
 
 
53
 
<img src="images/seealso.gif" border="0" align="middle" alt="See Also" title="See Also"> See Also: <a href="monitoring-publicservices.html">Monitoring Publicly Available Services</a>
54
 
 
55
 
</p>
56
 
 
57
 
 
58
 
 
59
 
<p>
60
 
 
61
 
<strong><u>Introduction</u></strong>
62
 
 
63
 
</p>
64
 
 
65
 
 
66
 
 
67
 
<img src="images/switch.png" border="0" style="float: right" alt="Switch">
68
 
 
69
 
 
70
 
 
71
 
<p>
72
 
 
73
 
This document describes how you can monitor the status of network switches and routers.  Some cheaper "unmanaged" switches and hubs don't have IP addresses and are essentially invisible on your network, so there's not any way to monitor them.  More expensive switches and routers have addresses assigned to them and can be monitored by pinging them or using SNMP to query status information.
74
 
 
75
 
</p>
76
 
 
77
 
 
78
 
 
79
 
<p>
80
 
 
81
 
I'll describe how you can monitor the following things on managed switches, hubs, and routers:
82
 
 
83
 
</p>
84
 
 
85
 
 
86
 
 
87
 
<ul>
88
 
 
89
 
<li>Packet loss, round trip average</li>
90
 
 
91
 
<li>SNMP status information</li>
92
 
 
93
 
<li>Bandwidth / traffic rate</li>
94
 
 
95
 
</ul>
96
 
 
97
 
 
98
 
 
99
 
<p>
100
 
 
101
 
<img src="images/note.gif" border="0" align="bottom" alt="Note" title="Note"> Note: These instructions assume that you've installed Nagios according to the <a href="quickstart.html">quickstart guide</a>.  The sample configuration entries below reference objects that are defined in the sample config files (<i>commands.cfg</i>, <i>templates.cfg</i>, etc.) that are installed when you follow the quickstart.
102
 
 
103
 
</p>
104
 
 
105
 
 
106
 
 
107
 
<p>
108
 
 
109
 
<strong><u>Overview</u></strong>
110
 
 
111
 
</p>
112
 
 
113
 
 
114
 
 
115
 
<img src="images/monitoring-routers.png" border="0" alt="Monitoring a Router or Switch" title="Monitoring a Router or Switch" style="float: right;">
116
 
 
117
 
 
118
 
 
119
 
<p>
120
 
 
121
 
Monitoring switches and routers can either be easy or more involved - depending on what equipment you have and what you want to monitor.  As they are critical infrastructure components, you'll no doubt want to monitor them in at least some basic manner.
122
 
 
123
 
</p>
124
 
 
125
 
 
126
 
 
127
 
<p>
128
 
 
129
 
Switches and routers can be monitored easily by "pinging" them to determine packet loss, RTA, etc.  If your switch supports SNMP, you can monitor port status, etc. with the <i>check_snmp</i> plugin and bandwidth (if you're using MRTG) with the <i>check_mrtgtraf</i> plugin.
130
 
 
131
 
</p>
132
 
 
133
 
 
134
 
 
135
 
<p>
136
 
 
137
 
The <i>check_snmp</i> plugin will only get compiled and installed if you have the net-snmp and net-snmp-utils packages installed on your system.  Make sure the plugin exists in <i>/usr/local/nagios/libexec</i> before you continue.  If it doesn't, install net-snmp and net-snmp-utils and recompile/reinstall the Nagios plugins.
138
 
 
139
 
</p>
140
 
 
141
 
 
142
 
 
143
 
<p>
144
 
 
145
 
<strong><u>Steps</u></strong>
146
 
 
147
 
</p>
148
 
 
149
 
 
150
 
 
151
 
<p>
152
 
 
153
 
There are several steps you'll need to follow in order to monitor a new router or switch.  They are:
154
 
 
155
 
</p>
156
 
 
157
 
 
158
 
 
159
 
<ol>
160
 
 
161
 
<li>Perform first-time prerequisites</li>
162
 
 
163
 
<li>Create new host and service definitions for monitoring the device</li>
164
 
 
165
 
<li>Restart the Nagios daemon</li>
166
 
 
167
 
</ol>
168
 
 
169
 
 
170
 
 
171
 
 
172
 
 
173
 
<p>
174
 
 
175
 
<strong><u>What's Already Done For You</u></strong>
176
 
 
177
 
</p>
178
 
 
179
 
 
180
 
 
181
 
<p>
182
 
 
183
 
To make your life a bit easier, a few configuration tasks have already been done for you:
184
 
 
185
 
</p>
186
 
 
187
 
 
188
 
 
189
 
<ul>
190
 
 
191
 
<li>Two command definitions (<i>check_snmp</i> and <i>check_local_mrtgtraf</i>) have been added to the <i>commands.cfg</i> file.  These allows you to use the <i>check_snmp</i> and <i>check_mrtgtraf</i> plugins to monitor network routers.</li>
192
 
 
193
 
<li>A switch host template (called <i>generic-switch</i>) has already been created in the <i>templates.cfg</i> file.  This allows you to add new router/switch host definitions in a simple manner.</li>
194
 
 
195
 
</ul>
196
 
 
197
 
 
198
 
 
199
 
<p>
200
 
 
201
 
The above-mentioned config files can be found in the <i>/usr/local/nagios/etc/objects/</i> directory.  You can modify the definitions in these and other definitions to suit your needs better if you'd like.  However, I'd recommend waiting until you're more familiar with configuring Nagios before doing so.  For the time being, just follow the directions outlined below and you'll be monitoring your network routers/switches in no time.
202
 
 
203
 
</p>
204
 
 
205
 
 
206
 
 
207
 
<p>
208
 
 
209
 
<strong><u>Prerequisites</u></strong>
210
 
 
211
 
</p>
212
 
 
213
 
 
214
 
 
215
 
<p>
216
 
 
217
 
The first time you configure Nagios to monitor a network switch, you'll need to do a bit of extra work.  Remember, you only need to do this for the *first* switch you monitor.
218
 
 
219
 
</p>
220
 
 
221
 
 
222
 
 
223
 
<p>
224
 
 
225
 
Edit the main Nagios config file.
226
 
 
227
 
</p>
228
 
 
229
 
 
230
 
 
231
 
<pre>
232
 
 
233
 
vi /usr/local/nagios/etc/nagios.cfg
234
 
 
235
 
</pre>
236
 
 
237
 
 
238
 
 
239
 
<p>
240
 
 
241
 
Remove the leading pound (#) sign from the following line in the main configuration file:
242
 
 
243
 
</p>
244
 
 
245
 
 
246
 
 
247
 
<pre>
248
 
 
249
 
#cfg_file=/usr/local/nagios/etc/objects/switch.cfg
250
 
 
251
 
</pre>
252
 
 
253
 
 
254
 
 
255
 
<p>
256
 
 
257
 
Save the file and exit.
258
 
 
259
 
</p>
260
 
 
261
 
 
262
 
 
263
 
<p>
264
 
 
265
 
What did you just do?  You told Nagios to look to the <i>/usr/local/nagios/etc/objects/switch.cfg</i> to find additional object definitions.  That's where you'll be adding host and service definitions for routers and switches.  That configuration file already contains some sample host, hostgroup, and service definitions.  For the *first* router/switch you monitor, you can simply modify the sample host and service definitions in that file, rather than creating new ones.
266
 
 
267
 
</p>
268
 
 
269
 
 
270
 
 
271
 
 
272
 
 
273
 
<p>
274
 
 
275
 
<strong><u>Configuring Nagios</u></strong>
276
 
 
277
 
</p>
278
 
 
279
 
 
280
 
 
281
 
<p>
282
 
 
283
 
You'll need to create some <a href="objectdefinitions.html">object definitions</a> in order to monitor a new router/switch.  </p>
284
 
 
285
 
 
286
 
 
287
 
<p>
288
 
 
289
 
Open the <i>switch.cfg</i> file for editing.
290
 
 
291
 
</p>
292
 
 
293
 
 
294
 
 
295
 
<pre>
296
 
 
297
 
vi /usr/local/nagios/etc/objects/switch.cfg
298
 
 
299
 
</pre>
300
 
 
301
 
 
302
 
 
303
 
<p>
304
 
 
305
 
Add a new <a href="objectdefinitions.html#host">host</a> definition for the switch that you're going to monitor.  If this is the *first* switch you're monitoring, you can simply modify the sample host definition in <i>switch.cfg</i>.  Change the <i>host_name</i>, <i>alias</i>, and <i>address</i> fields to appropriate values for the switch.
306
 
 
307
 
</p>
308
 
 
309
 
 
310
 
 
311
 
<pre>
312
 
 
313
 
define host{
314
 
 
315
 
        use             generic-switch          ; Inherit default values from a template
316
 
 
317
 
        host_name               linksys-srw224p         ; The name we're giving to this switch
318
 
 
319
 
        alias           Linksys SRW224P Switch  ; A longer name associated with the switch
320
 
 
321
 
        address         192.168.1.253           ; IP address of the switch
322
 
 
323
 
        hostgroups      allhosts,switches                       ; Host groups this switch is associated with
324
 
 
325
 
        }
326
 
 
327
 
</pre>
328
 
 
329
 
 
330
 
 
331
 
<p>
332
 
 
333
 
<strong><u>Monitoring Services</u></strong>
334
 
 
335
 
</p>
336
 
 
337
 
 
338
 
 
339
 
<p>
340
 
 
341
 
Now you can add some service definitions (to the same configuration file) to monitor different aspects of the switch.  If this is the *first* switch you're monitoring, you can simply modify the sample service definition in <i>switch.cfg</i>.
342
 
 
343
 
</p>
344
 
 
345
 
 
346
 
 
347
 
<p>
348
 
 
349
 
<img src="images/note.gif" border="0" align="bottom" alt="Note" title="Note"> Note: Replace "<i>linksys-srw224p</i>" in the example definitions below with the name you specified in the <i>host_name</i> directive of the host definition you just added.
350
 
 
351
 
</p>
352
 
 
353
 
 
354
 
 
355
 
 
356
 
 
357
 
<p>
358
 
 
359
 
<strong><u>Monitoring Packet Loss and RTA</u></strong>
360
 
 
361
 
</p>
362
 
 
363
 
 
364
 
 
365
 
<p>
366
 
 
367
 
Add the following service definition in order to monitor packet loss and round trip average between the Nagios host and the switch every 5 minutes under normal conditions.
368
 
 
369
 
</p>
370
 
 
371
 
 
372
 
 
373
 
<pre>
374
 
 
375
 
define service{
376
 
 
377
 
        use                     generic-service ; Inherit values from a template
378
 
 
379
 
        host_name                       linksys-srw224p ; The name of the host the service is associated with
380
 
 
381
 
        service_description     PING            ; The service description
382
 
 
383
 
        check_command           check_ping!200.0,20%!600.0,60%  ; The command used to monitor the service
384
 
 
385
 
        normal_check_interval   5       ; Check the service every 5 minutes under normal conditions
386
 
 
387
 
        retry_check_interval    1       ; Re-check the service every minute until its final/hard state is determined
388
 
 
389
 
        }
390
 
 
391
 
</pre>
392
 
 
393
 
 
394
 
 
395
 
<p>
396
 
 
397
 
This service will be:
398
 
 
399
 
</p>
400
 
 
401
 
 
402
 
 
403
 
<ul>
404
 
 
405
 
<li>CRITICAL if the round trip average (RTA) is greater than 600 milliseconds or the packet loss is 60% or more</li>
406
 
 
407
 
<li>WARNING if the RTA is greater than 200 ms or the packet loss is 20% or more</li>
408
 
 
409
 
<li>OK if the RTA is less than 200 ms and the packet loss is less than 20%</li>
410
 
 
411
 
</ul>
412
 
 
413
 
 
414
 
 
415
 
<p>
416
 
 
417
 
<strong><u>Monitoring SNMP Status Information</u></strong>
418
 
 
419
 
</p>
420
 
 
421
 
 
422
 
 
423
 
<p>
424
 
 
425
 
If your switch or router supports SNMP, you can monitor a lot of information by using the <i>check_snmp</i> plugin.  If it doesn't, skip this section.
426
 
 
427
 
</p>
428
 
 
429
 
 
430
 
 
431
 
<p>
432
 
 
433
 
Add the following service definition to monitor the uptime of the switch.
434
 
 
435
 
</p>
436
 
 
437
 
 
438
 
 
439
 
<pre>
440
 
 
441
 
define service{
442
 
 
443
 
        use                     generic-service ; Inherit values from a template
444
 
 
445
 
        host_name                       linksys-srw224p
446
 
 
447
 
        service_description     Uptime  
448
 
 
449
 
        check_command           check_snmp!-C public -o sysUpTime.0
450
 
 
451
 
        }
452
 
 
453
 
</pre>
454
 
 
455
 
 
456
 
 
457
 
<p>
458
 
 
459
 
In the <i>check_command</i> directive of the service definition above, the "-C public" tells the plugin that the SNMP community name to be used is "public" and the "-o sysUpTime.0" indicates which OID should be checked.
460
 
 
461
 
</p>
462
 
 
463
 
 
464
 
 
465
 
<p>
466
 
 
467
 
If you want to ensure that a specific port/interface on the switch is in an up state, you could add a service definition like this:
468
 
 
469
 
</p>
470
 
 
471
 
 
472
 
 
473
 
<pre>
474
 
 
475
 
define service{
476
 
 
477
 
        use                     generic-service ; Inherit values from a template
478
 
 
479
 
        host_name                       linksys-srw224p
480
 
 
481
 
        service_description     Port 1 Link Status
482
 
 
483
 
        check_command           check_snmp!-C public -o ifOperStatus.1 -r 1 -m RFC1213-MIB
484
 
 
485
 
        }
486
 
 
487
 
</pre>
488
 
 
489
 
 
490
 
 
491
 
<p>
492
 
 
493
 
In the example above, the "-o ifOperStatus.1" refers to the OID for the operational status of port 1 on the switch.  The "-r 1" option tells the <i>check_snmp</i> plugin to return an OK state if "1" is found in the SNMP result (1 indicates an "up" state on the port) and CRITICAL if it isn't found.  The "-m RFC1213-MIB" is optional and tells the <i>check_snmp</i> plugin to only load the "RFC1213-MIB" instead of every single MIB that's installed on your system, which can help speed things up.
494
 
 
495
 
</p>
496
 
 
497
 
 
498
 
 
499
 
<p>
500
 
 
501
 
That's it for the SNMP monitoring example.  There are a million things that can be monitored via SNMP, so its up to you to decide what you need and want to monitor.  Good luck!
502
 
 
503
 
</p>
504
 
 
505
 
 
506
 
 
507
 
<p>
508
 
 
509
 
<img src="images/tip.gif" border="0" align="bottom" alt="Tip" title="Tip"> Tip:  You can usually find the OIDs that can be monitored on a switch by running the following command (replace <i>192.168.1.253</i> with the IP address of the switch):
510
 
 
511
 
<i>snmpwalk -v1 -c public 192.168.1.253 -m ALL .1</i>
512
 
 
513
 
</p>
514
 
 
515
 
 
516
 
 
517
 
<p>
518
 
 
519
 
<strong><u>Monitoring Bandwidth / Traffic Rate</u></strong>
520
 
 
521
 
</p>
522
 
 
523
 
 
524
 
 
525
 
<p>
526
 
 
527
 
If you're monitoring bandwidth usage on your switches or routers using <a href="http://oss.oetiker.ch/mrtg/">MRTG</a>, you can have Nagios alert you when traffic rates exceed thresholds you specify.  The <i>check_mrtgtraf</i> plugin (which is included in the Nagios plugins distribution) allows you to do this.
528
 
 
529
 
</p>
530
 
 
531
 
 
532
 
 
533
 
<p>
534
 
 
535
 
You'll need to let the <i>check_mrtgtraf</i> plugin know what log file the MRTG data is being stored in, along with thresholds, etc.  In my example, I'm monitoring one of the ports on a Linksys switch.  The MRTG log file is stored in <i>/var/lib/mrtg/192.168.1.253_1.log</i>.  Here's the service definition I use to monitor the bandwidth data that's stored in the log file...
536
 
 
537
 
</p>
538
 
 
539
 
 
540
 
 
541
 
<pre>
542
 
 
543
 
define service{
544
 
 
545
 
        use                     generic-service ; Inherit values from a template
546
 
 
547
 
        host_name                       linksys-srw224p
548
 
 
549
 
        service_description     Port 1 Bandwidth Usage
550
 
 
551
 
        check_command           check_local_mrtgtraf!/var/lib/mrtg/192.168.1.253_1.log!AVG!1000000,2000000!5000000,5000000!10
552
 
 
553
 
        }
554
 
 
555
 
</pre>
556
 
 
557
 
 
558
 
 
559
 
<p>
560
 
 
561
 
In the example above, the "/var/lib/mrtg/192.168.1.253_1.log" option that gets passed to the <i>check_local_mrtgtraf</i> command tells the plugin which MRTG log file to read from.  The "AVG" option tells it that it should use average bandwidth statistics.  The "1000000,2000000" options are the warning thresholds (in bytes) for incoming traffic rates.  The "5000000,5000000" are critical thresholds (in bytes) for outgoing traffic rates.  The "10" option causes the plugin to return a CRITICAL state if the MRTG log file is older than 10 minutes (it should be updated every 5 minutes).
562
 
 
563
 
</p>
564
 
 
565
 
 
566
 
 
567
 
 
568
 
 
569
 
<p>
570
 
 
571
 
Save the file.
572
 
 
573
 
</p>
574
 
 
575
 
 
576
 
 
577
 
<p>
578
 
 
579
 
<strong><u>Restarting Nagios</u></strong>
580
 
 
581
 
</p>
582
 
 
583
 
 
584
 
 
585
 
<p>
586
 
 
587
 
Once you've added the new host and service definitions to the <i>switch.cfg</i> file, you're ready to start monitoring the router/switch.  To do this, you'll need to <a href="verifyconfig.html">verify your configuration</a> and <a href="startstop.html">restart Nagios</a>.
588
 
 
589
 
</p>
590
 
 
591
 
 
592
 
 
593
 
<p>
594
 
 
595
 
If the verification process produces any errors messages, fix your configuration file before continuing.  Make sure that you don't (re)start Nagios until the verification process completes without any errors!
596
 
 
597
 
</p>
598
 
 
599
 
 
600
 
 
601
 
 
602
 
 
603
 
 
604
 
 
605
 
<hr>
606
 
 
607
 
 
608
 
 
609
 
</body>
610
 
 
611
 
</html>
612