Upload
khadxa
View
222
Download
0
Embed Size (px)
Citation preview
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
1/32
Telecommunications Management Network : TMN
Classe Level : Ingnieur des Travaux de
Tlcommunications (IGTT2-T 2012)
Works:Management and Oversee systems
Through Open Source Tools
Teacher:Dr A. D. KORA
Assistant works: Moindze S
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
2/32
Nagios Quickstart Installation Guides on Ubuntu 10.04 LTS
1. Installation Introduction
1.1.About Nagios
Visit www.nagios.org/about/ for more information on Nagios - including features, capabilities, and
technical specifications.
These quickstart guides are intended to provide you with simple instructions on how to install Nagios
from source (code) and have it monitoring your local machine and your network LAN inside of 20
minutes.
You can also find additional quickstart guides on the Nagios Community Wiki. Cant find a quickstart
for your particular OS? Write one and post it to the wiki for others. If you are installing Nagios on anoperating system or Linux distribution that isnt listed above, read the Fedora quickstart for an
overview of what youll need to do. Command names, paths, etc. vary widely across different OSes /
distributions, so youll likely need to tweak the installation docs a bit to work for your particular case.
These instructions were written based on an Ubuntu 10.04 LTS (desktop) installation. They should
work for an Ubuntu 10.04 or higher install as well.
1.2.What Youll End Up With
If you follow these instructions, heres what youll end up with:
Nagios and the plugins will be installed underneath/usr/local/nagios
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
3/32
Nagios will be configured to monitor a few aspects of your local system (CPU load, disk usage,
etc.)
The Nagios web interface will be accessible at http://localhost/nagios/or http://ip-address-
server/nagios/ if that ip-addrerss-serveris the IP address for your Nagios server.
2. Required Packages
2.1.installation of dependencies packets for system linux
Make sure youve installed the following packages on your Ubuntu installation before continuing.
You can useapt-get or aptitude command to install these packages by running the following
commands:
Withapt-get install nom-paquet oraptitude install nom-paquetwith nom-paquet is the name that you
want to install. But its necessary to have internet connexion on you your linux server.
Its necessary login with user root for privileges of installation.
# apt-get install vim ; for installing editor file vim
# apt-get install gcc g++; for installing compilator
# apt-get install apache2 ; for installing wb interafce
# apt-get install php5 ; for php scripts
# apt-get install build-essential autoconf automake libxmu-dev gcc-4.3; for installing packets
system
Notes: the symbol; here mean comment for explain.
2.2.Required packets for installation Nagios
Make sure youve installed the following packages on your Ubuntu installation before continuing.
Apache 2
PHP 5 or higher
GCC compiler and development libraries
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
4/32
GD development libraries
You can use apt-get to install these packages by running the following commands:
# apt-get install apache2 ; for apache2
# apt-get install libapache2-mod-php5; for install php5
# apt-get install build-essential ; for system
# aptitude install build-essential ; for compiles sources of softwares
# aptitude install apache2 wget ; for the web interface
# apt-get install bind9-host dnsutils libbind9-60 libdns66
# aptitude install libisc60 libisccc60 libisccfg60 liblwres60 libradius1
# aptitude install radiusclient1 snmp snmpd ; for a good functional of nagios and installing SNMP
parquets
# aptitude install libgd2-noxpm-dev libpng12-dev libjpeg62 libjpeg62-dev ; for a goob graph
from nagios
# apt-get install gcc, g++,
# apt-get install libgd2-xpm-dev
# apt-get install libgd2-dev ; for install install the gd2 library
# apt-get install libgd2-xpm-dev ; for install install the gd2 library
3. Installation of nagios-3.2.3
3.1.Creating Account and group Information
Notes:In this TP through all pictures:
rootis the user current connected
VAIO-SOIDRIDINEis the name of the server (Computer)
/home/moindze/ is the directory for connected user
Become the root user with command su. On linux you can use the su r name-userto change a user
and give the correspondence password.
Notes:the symbol #in the beginning of line means that the user root(administrator) is connected
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
5/32
And the symbol $in the beginning of line means that an invite (not administrator user) user is connect.
$ sudo su root
Create a new nagios user account and give it a password.
# /usr/sbin/useradd -m -s /bin/bash nagios
# passwd nagios
for this TP the passwd is nagios
Figure 1: create a user nagios and password nagios
You will need to also add a nagios group (its not created by default on Ubuntu 10.o4 and higher). You
should be able to skip this step on desktop or newer server editions of Ubuntu.
# /usr/sbin/groupadd nagios
# /usr/sbin/usermod -G nagios nagios
Figure 2: create a group nagios
Create a new nagcmd group for allowing external commands to be submitted through the web
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
6/32
interface. Add both the nagios user and the apache user to the group.
# /usr/sbin/groupadd nagcmd
# /usr/sbin/usermod -a -G nagcmd nagios
# /usr/sbin/usermod -a -G nagcmd www-data
Figure 3: crate a group for external command nagcmd
3.2. Download Nagios and the Plugins
Create a directory for storing the download or use the default directory Download in Document. For
this TP I used the Document directory for saving nagios package.
Download directly with internet connexion on the linux host, the source code tarballs of both Nagios
and the Nagios plugins (visit http://www.nagios.org/download/ for links to the latest versions).
These directions were tested with Nagios 3.1.1 and Nagios Plugins 1.4.11.
# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz
# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
You can also download separately and copy file on the directory of your choice. For this installation, I
had downloaded nagios and nagios-plugins and saved these files on Documents.
I used cd command to enter in Document
#cd /Document
And I used the ls command to list content of Docuent
#ls
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
7/32
Figure 4: packages nagios-3.2.3.tar.gz and nagios-plugings-.4.15.tar.gz saved in Document
directory
3.3. Compile and Install Nagios
Extract the Nagios source code tarball from Documents and save the desarchive file on/usr/local/
I have used option -Cfor specify the destination directory .
# cd Documents
# tar xzvf nagios-3.2.3.tar.gz -C /usr/local
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
8/32
Figure 5: desarchivage nagios file and save that on /usr/local
Enter on the nagios file for installation
# cd /usr/local/nagios-3.2.3
Run the Nagios configure script, passing the name of the group you created earlier like so:
# ./configure --with-command-group=nagcmd
The outputs of ./configurecommand are shown bellow :
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
9/32
Figure 6a: first output of ./configure command
The end of the output of ./configure command is
Figure 6 b: the end of output of command ./configure
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
10/32
Compile the Nagios source code.
You can compile nagios with this command:
# make all
Figure 7a: the beginning of output of make all
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
11/32
The end of the output of make allis given bellow
Figure 7b: the second output of make all command
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
12/32
Figure 7c: the third output of make all commandAnd for the end of make all I had that you have:
Figure 7d: the end of make all
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
13/32
3.4.installation of binaries
You can use the commands bellow to install binaries, init script, sample config files and set permissions
on the external command directory.
# make install
# make install-init
# make install-config
# make install-commandmode
The output of make install is :
Figure 8 : output of make install
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
14/32
The outputs of make install-init is:
Figure 9 : the output of make install-init
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
15/32
The outputs of make install-commandmode and make install-configis
Figure 10: output of make install-commadmode and make install-config
Dont start Nagios yet - theres still more that needs to be done...
3.5.Customize Configuration
This step is not mandatory but recommended.
Sample configuration files have now been installed in the /usr/local/nagios/etc directory. These sample
files should work fine for getting started with Nagios. Youll need to make just one change before you
proceed. Edit the/usr/local/nagios/etc/objects/contacts.cfgconfig file with your favorite editor suh as
vim or gedit or another and change the email address associated with the nagiosadmin contact
definition to the address youd like to use for receiving alerts.
# vim /usr/local/nagios/etc/objects/contacts.cfg
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
16/32
Figure 11a: content the file /usr/local/nagios/etc/objects/contacts.cfg
In this TP was not change the mail but keep the default mail.
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
17/32
Figure 11b: content the file /usr/local/nagios/etc/objects/contacts.cfg
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
18/32
3.6.Configure the Web Interface
Install the Nagios web config file in the Apache conf.d directory:
# make install-webconf
Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you
assign to this account - youll need it later.
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Restart Apache to make the new settings take effect.
# /etc/init.d/apache2 reload
Figure 12: create a nagiosadmin user and his password for connexion web interface and start
apache2
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
19/32
4.
Compile and Install the Nagios Plugins
Extract the Nagios-plugins source code tarball from Documents to /usr/local also.
Note: I had already download nagios-plugins above.
# cd /Documents
# tar xzf nagios-plugins-1.4.11.tar.gz -C /usr/local
Figure 13: decompress nagios-plugins and save the result on /usr/local
Figure 14: decompress procedure
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
20/32
After this step, entering of directory of nagios-plugins
# cd /usr/local/ nagios-plugins-1.4.11
Compile and install the plugins.
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
Figure 15: enter in /usr/local/nagios-plugins directory and configure
The output of configure command
Figure 16: output of configure command
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
21/32
Install nagios-plugins
#make
# make install
The output of makeis bellow
figure 17: output of make
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
22/32
The output ofmake installis
Figure 18 : output of make install
5. Start Nagios
Configure Nagios to automatically start when the system boots.
# ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
Figure 20: configure nagios to automatically start with system
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
23/32
Verify the sample Nagios configuration files. If everything is ok.
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Figure 21: beginning of output of verification
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
24/32
The end of the verification command is:
Figure 22: the end of verification command
Note: If you have Total warning is 0 and Total error is o that means everything is Ok. If you have
another number in total warning there is not problem but ensure that you have total Errors is 0
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
25/32
We had not any errors, and i started Nagios with the bellow command:
# /etc/init.d/nagios start
Figure 25: started of server nagios and web interface apache2
6. Login to the Web Interface
You should now be able to access the Nagios web interface at the URL below. Youll be prompted for
the username (nagiosadmin) and password you specified earlier. You can open a web browser and tape:
http://localhost/nagios/or http://127.0.0.1/nagios/or http://192.168.1.2/nagios/
Here 192.168.1.2 is the address of nagios server.
Note: don't forget the symbol / in the end of link.
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
26/32
Figure 26: login on the nagios server
After identification with login nagiosadminand password nagios, the home page of nagios is bellow:
Figure 27: Home page for nagios
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
27/32
Click on the "Service Detail" navbar link to see details of whats being monitored on your local
machine. You can click on the MAP button to see the MAP of your network.
7. Verifying Your Configuration
Every time you modify your configuration files, you should run a sanity check on them. It is important
to do this before you (re)start Nagios, as Nagios will shut down if your configuration contains errors.
In order to verify your configuration, run Nagios with the -v command line option like so:
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If youve forgotten to enter some critical data or misconfigured things, Nagios will spit out a warning
or error message that should point you to the location of the problem. Error messages generally print
out the line in the configuration file that seems to be the source of the problem. On errors, Nagios will
often exit the pre-flight check and return to the command prompt after printing only the first error that
it has encountered. This is done so that one error does not cascade into multiple errors as the remainder
of the configuration data is verified. If you get any error messages youll need to go and edit your
configuration files to remedy the problem. Warning messages can generally be safely ignored, since
they are only recommendations and not requirements.
Once youve verified your configuration files and fixed any errors you can go ahead and (re)start
Nagios.
8. Starting and Stopping Nagios
Theres more than one way to start, stop, and restart Nagios. Here are some of the more common ones.
Tip:Always make sure you verify your configuration before you (re)start Nagios.
8.1. Starting Nagios
a) Init Script: The easiest way to start the Nagios daemon is by using the init script like so:
# /etc/rc.d/init.d/nagios start
b) Manually: You can start the Nagios daemon manually with the -d command line option like so:
#/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
28/32
8.2. Restarting Nagios
Restarting/reloading is necessary when you modify your configuration files and want those changes to
take effect.
a) Init Script: The easiest way to restart the Nagios daemon is by using the init script like so:
# /etc/rc.d/init.d/nagios reload
b) Web Interface: You can restart the Nagios through the web interface by clicking the "Process
Info" navigation link and selecting "Restart the Nagios process":
c) Manually: You can restart the Nagios process by sending it a SIGHUP signal like so:# kill -HUP
8.3. Stopping Nagios
a) Init Script: The easiest way to stop the Nagios daemon is by using the init script like so:# /etc/rc.d/init.d/nagios stop
b) Web Interface: You can stop the Nagios through the web interface by clicking the "ProcessInfo" navigation link and selecting "Shutdown the Nagios process":
c) Manually: You can stop the Nagios process by sending it a SIGTERM signal like so:# kill
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
29/32
9. Object Configuration Overview
9.1. What Are Objects?
Objects are all the elements that are involved in the monitoring and notification logic. Types of objectsinclude:
Services Service Groups Hosts (pc, routers, switchs, prints, gateway, all equipments)
Host Groups Contacts Contact Groups Commands
Time Periods
Notification Escalations Notification and Execution Dependencies
More information on what objects are and how they relate to each other can be found below.
9.2. Where Are Objects Defined?
Objects can be defined in one or more configuration files and/or directories that you specify using the
cfg_file and/or cfg_dir directives in the main configuration file.
Tip: When you follow quickstart installation guide above, several sample object configuration files are
placed in/usr/local/nagios/etc/objects/. You can use these sample files to see how object inheritance
works and learn how to define your own object definitions.
9.3. Objects Explained
Some of the main object types are explained in greater detail below:
a) Hosts are one of the central objects in the monitoring logic. Important attributes of hosts are asfollows: Hosts are usually physical devices on your network (servers, workstations, routers,
switches, printers, etc). Hosts have an address of some kind (e.g. an IP or MAC address). Hosts have one or more more services associated with them.
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
30/32
Hosts can have parent/child relationships with other hosts, often representing real-worldnetwork connections, which is used in the network reachability logic.
b) Host Groups are groups of one or more hosts. Host groups can make it easier to (1) view the
status of related hosts in the Nagios web interface and (2) simplify your configuration through
the use of object tricks.
c) Services are one of the central objects in the monitoring logic. Services are associated with
hosts and can be:
Attributes of a host (CPU load, disk usage, uptime, etc.)
Services provided by the host (HTTP, POP3, FTP, SSH,etc.)
Other things associated with the host (DNS records, etc.)
d) Service Groups are groups of one or more services. Service groups can make it easier to (1)
view the status of related services in the Nagios web interface and (2) simplify your
configuration through the use of object tricks.
e) Contacts are people involved in the notification process:
Contacts have one or more notification methods (cellphone, pager, email, instant messaging,
etc.)
Contacts receive notifications for hosts and service they are responsible for
f) Contact Groups are groups of one or more contacts. Contact groups can make it easier to
define all the people who get notified when certain host or service problems occur.
g) Timeperiods are are used to control:
When hosts and services can be monitored
When contacts can receive notifications
h) Commands are used to tell Nagios what programs, scripts, etc. it should execute to perform:
Host and service checks
Notifications
Event handlers
and more...
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
31/32
9.4. Object Definitions
When creating and/or editing configuration files, keep the following in mind:1. Lines that start with a # character are taken to be comments and are not processed2. Directive names are case-sensitive3. Characters that appear after a semicolon (;) in configuration lines are treated as comments and arenot processed
Host Definition
Description:
A host definition is used to define a physical server, workstation, device, etc. that resides on your network.
Definition Format:Note:Directives in red are required, while those in black are optional
define host{host_name host_namealias aliasaddress addressparents host_names
for example
#declaring a server ; comment
define host {
host_name SRVLEMANS ;device namealias Server Le Mans ; aliasaddress 10.166.200.100 ; IP addressuse generic-host ;device typeparents server-backbone
}
Directive Descriptions:
host_name: This directive is used to define a short name used to identify the host. It is used in host
group and service definitions to reference this particular host. Hosts can have multiple services (which
are monitored) associated with them. When used properly, the $HOSTNAME$ macro will contain this
short name.
8/10/2019 Works 1 Installation and Configure Nagios for ESMT-IGTT2-T2012!13!16 December2011
32/32
alias: This directive is used to define a longer name or description used to identify the host. It is
provided in order to allow you to more easily identify a particular host. When used properly, the
$HOSTALIAS$ macro will contain this alias/description.
address: This directive is used to define the address of the host. Normally, this is an IP address,
although it could really be anything you want (so long as it can be used to check the status of the host).
You can use a FQDN to identify the host instead of an IP address, but if DNS services are not 3333ccle
this could cause problems. When used properly, the $HOSTADDRESS$ macro will contain this
address. Note: If you do not specify an address directive in a host definition, the name of the host will
be used as its address. A word of caution about doing this, however - if DNS fails, most of your
service checks will fail because the plugins will be unable to resolve the host name.
parents: This directive is used to define a comma-delimited list of short names of the "parent" hosts for
this particular host. Parent hosts are typically routers, switches, firewalls, etc. that lie between the
monitoring host and a remote hosts. A router, switch, etc. which is closest to the remote host is
considered to be that hosts "parent". Read the "Determining Status and Reachability of Network
Hosts" document located here for more information. If this host is on the same network segment as the
host doing the monitoring (without any intermediate routers, etc.) the host is considered to be on the
local network and will not have a parent host. Leave this value blank if the host does not have a parent
host (i.e. it is on the same segment as the Nagios host). The order in which you specify parent hosts has
no effect on how things are monitored.