Network Monitoring - Pdf 67

131
CHAPTER 6
Network Monitoring
Knowing When It Goes Wrong
Without Watching It
A
s an administrator, it is your responsibility to know when things are about to go
wrong. You can, of course, go sit by your server all day and figure out if everything is going
all right, but you probably have better things to do. Nagios offers services to monitor the
network for you. In this chapter you’ll learn how to install and use Nagios.
Starting with Nagios
Nagios is a network- wide monitoring tool. In this chapter you’ll learn how to set it up
on your servers. Once it is set up, you can watch the status of servers in your network via
a web browser. Don’t want to watch a web browser all time? That’s fine, because you can
configure Nagios to send relevant security alerts to some specified users on the network if
something goes wrong. Nagios allows you to monitor local server events, such as running
out of disk space, as network events.
Before you install Nagios, make sure that you have a web server configured (you can
read more about configuring Apache Web Server in Chapter 11 of my book Beginning
Ubuntu Server Administration, from Apress) and running. Nagios uses a web interface to
show its information, so you can’t do without that. Once you have confirmed it is up and
running, install the
j]ceko
packages:
]lp)capejop]hhj]ceko.j]ceko)lhqcejoj]ceko)ei]cao
This command installs about 40 MB of data on your server. Once that is done, you
have to complete the installation by setting up authentication. Nagios uses the file
CHAPTER 6
N
NETWORK MONITORING
132

]l]_da.*_kjb
file contains the authentication settings and some
basic paths that Nagios has to use. The other relevant configuration file is
+ap_+j]ceko.+
_ce*_bc
, which contains the name of the admin user that is used for different purposes, as
well as other settings that are related to the CGI scripts that Nagios uses. The interesting
part of this script is that you can change admin names in it. By default,
j]ceko]`iej
is the
only user who has administrative permissions to perform different tasks. If, for instance,
you want to use another user account for hosts and services- related commands, change it
in the
_ce*_bc
file. Listing 6-2 shows its contents.
CHAPTER 6
N
NETWORK MONITORING
133
N
Note
For better readability, I have removed all comment lines. Consult the configuration file on disk to
see the comment lines as well.
Listing 6-2. cgi.cfg Contains the Authorizations of the admin User
j]ceko[_da_g[_kii]j`9+qon+he^+j]ceko+lhqcejo+_da_g[j]cekoX
+r]n+_]_da+j]ceko.+op]pqo*`]p1#+qon+o^ej+j]ceko.#
qoa[]qpdajpe_]pekj9-
]qpdkneva`[bkn[ouopai[ejbkni]pekj9j]ceko]`iej
]qpdkneva`[bkn[_kjbecqn]pekj[ejbkni]pekj9j]ceko]`iej
]qpdkneva`[bkn[ouopai[_kii]j`o9j]ceko]`iej

135
Configuring Nagios
Nagios uses lots of configuration files. The most difficult part of managing Nagios is to
find the right configuration file for a specific purpose. To make it even more difficult,
Nagios distinguishes between core configuration files and plug- in configuration files,
add- on files that can be used as an extension to the default functionality of Nagios.
Location of the Configuration Files
When you first start working with Nagios, it looks like configuration files are located just
about everywhere! To help you pinpoint the locations of these files, the following list
identifies the most common directories in which Nagios stores information:
s
+ap_+j]ceko.
: This is the master configuration directory. It contains the most
important configuration files, among which you will find the
j]ceko*_bc
config-
uration file.
s
+qon+he^+j]ceko+lhqcejo
: As mentioned, Nagios works with plug- ins. Every plug- in
allows you to monitor an additional service. For example, Nagios by itself doesn’t
know how to monitor Oracle. If, however, the Oracle plug- in has been installed in
this directory (which is the case after a default installation), the plug- in can man-
age Oracle.
s
+ap_+j]ceko.+_kjb*`
: This directory contains some of the most important Nag-
ios configuration files. If the file you are looking for is not in here, also check
+ap_+j]ceko)lhqcejo+_kjb
ig.

`abeja_kii]j`w
_kii]j`[j]ialnk_aoo)dkop)lanb`]p]
_kii]j`[heja+qon+^ej+lnejpb!^ H=OPDKOP?DA?G Xp DKOPJ=IA
±
Xp DKOPOP=PA Xp
DKOP=PPAILP Xp DKOPOP=PAPULA Xp
±
DKOPATA?QPEKJPEIA Xp DKOPKQPLQP Xp DKOPLANB@=P= Xj::
±
+r]n+he^+j]ceko.+dkop)lanb`]p]*kqp
y
#lnk_aoo)oanre_a)lanb`]p]#_kii]j``abejepekj
`abeja_kii]j`w
_kii]j`[j]ialnk_aoo)oanre_a)lanb`]p]
_kii]j`[heja+qon+^ej+lnejpb!^ H=OPOANRE?A?DA?G Xp DKOPJ=IA
±
Xp OANRE?A@AO? Xp
OANRE?AOP=PA Xp OANRE?A=PPAILP Xp
±
OANRE?AOP=PAPULA Xp OANRE?AATA?QPEKJPEIA Xp OANRE?AH=PAJ?U
±
Xp OANRE?AKQPLQP Xp OANRE?ALANB@=P= Xj::+r]n+he^+j]ceko.+oanre_a)lanb`]p]*kqp
y
Nagios commands are well structured. If you feel you are missing any functionality in
the default Nagios command set, you can create your own Nagios commands as well. The
_kii]j`o*_bc
file contains some hints on how to do that.
The Master Configuration File: nagios.cfg
The master configuration file that Nagios uses is
+ap_+j]ceko.+j]ceko*_bc

_bc[beha9+ap_+j]ceko.+dkopcnkqlo*_bc
_bc[beha9+ap_+j]ceko.+dkopo*_bc
_bc[beha9+ap_+j]ceko.+oanre_ao*_bc
_bc[beha9+ap_+j]ceko.+peialanek`o*_bc
Atpaj`a`dkop+oanre_aejbk`abejepekjo]najksopkna`]hkjcsepd
kpdank^fa_p`abejepekjo6
_bc[beha9+ap_+j]ceko.+dkopatpejbk*_bc
_bc[beha9+ap_+j]ceko.+oanre_aatpejbk*_bc
Ukq_]j]hokpahhJ]cekopklnk_aoo]hh_kjbecbehao$sepd]*_bc
atpajoekj%ej]l]npe_qh]n`ena_pknu^uqoejcpda_bc[`en
`ena_pera]oodksj^ahks6
_bc[`en9+ap_+j]ceko.+oanrano
_bc[`en9+ap_+j]ceko.+lnejpano
_bc[`en9+ap_+j]ceko.+osep_dao
_bc[`en9+ap_+j]ceko.+nkqpano
As a Nagios administrator, it is also useful if you know about the other important
lines in the
j]ceko*_bc
file. The following list provides an overview of the most important
definitions it contains:
CHAPTER 6
N
NETWORK MONITORING
138
s
hkc[beha9+r]n+hkc+j]ceko.+j]ceko*hkc
: This parameter tells Nagios where to log its
information.
s
_bc[`en9+ap_+j]ceko.+_kjb*`

: Rotate hourly
s
`
: Rotate daily
s
s
: Rotate weekly
s
i
: Rotate monthly
s
hkc[]n_dera[l]pd9+r]n+hkc+j]ceko.+]n_derao
: If log rotation is enabled, this param-
eter describes where the archive of log files should be written to.
Creating Essential Nagios Configuration Files
Nagios needs some minimal configuration files, and they should reside in one of the
directories defined in the
j]ceko*_bc
file using the
_bc[`en
directive. The default location
to put them would be
+ap_+j]ceko.+_kjb*`
. Make sure that you create at least the follow-
ing configuration files:
s
_kjp]_po*_bc
: This file defines which people should get a message in case of
trouble.
s

Internet. Nagios can monitor other operating systems as well, but let’s try to set up
Linux- based host monitoring first. The following servers are monitored:
s
-5.*-24*-*55
: DHCP, NFS, web, Nagios, SSH
s
-5.*-24*-*-,,
: Samba, SSH
s
-5.*-24*-*-,-
: Web, FTP, SSH
s
4,*25*5/*.-2
: Web, SSH
Creating a Contacts File
Start with the creation of the
_kjp]_po*_bc
file. As specified in
+ap_+j]ceko.+j]ceko*_bc
,
this file should reside in
+ap_+j]ceko.
, so make sure to create it there. Listing 6-5 gives an
example of what this file may look like.
Listing 6-5. Example contacts.cfg File
_kjp]_p`abejepekjbknhej`]
`abeja_kjp]_pw
_kjp]_p[j]iahej`]
]he]ohej`]pdkioaj
oanre_a[jkpebe_]pekj[lanek`skngdkqno

oanre_a[jkpebe_]pekj[klpekjo
parameters can be used:
s
j
: Do not notify at all
s
s
: Notify on WARNING states
s
q
: Notify on UNKNOWN states
s
_
: Notify on CRITICAL states
s
n
: Notify when the service recovers and returns to OK state
Likewise, the following
dkop[jkpebe_]pekj[klpekjo
parameters can be used:
s
j
: Do not notify at all
s
`
: Notify on DOWN host states
s
q
: Notify if host is unreachable
s

]he]oQ^qjpqOanran
]``naoo-5.*-24*-*55
qoacajane_)dkop
_da_g[_kii]j`_da_g)dkop)]hera
i]t[_da_g[]ppailpo-,
jkpebe_]pekj[ejpanr]h-.,
jkpebe_]pekj[lanek`.0t3
jkpebe_]pekj[klpekjo`(q(n
y
@abejepekjkbcajane_O]i^]oanran
`abejadkopw
dkop[j]iaouh
]he]oO]i^]Oanran
]``naoo-5.*-24*-*-,,
qoacajane_)dkop


Nhờ tải bản gốc
Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status