Install and configure Nagios in Linux

Source: Internet
Author: User
Tags php cli sapi fully qualified domain name mrtg

Install and configure Nagios in Linux

1. Nagios Overview

1. Introduction

Nagios is a plug-in structure, and it does not have any monitoring function. All monitoring is performed through the plug-in, so it is highly modular and flexible. Nagios monitoring objects can be divided into two types: Host and service. A host usually refers to a physical host, such as a server, router, workstation, or printer. The host can also be a virtual device, such as a Linux system virtualized by xen; A service usually refers to a specific function, such as an httpd process that provides http Services. For management convenience, the host and service can also be planned as the master unit and service group respectively.

Nagios does not monitor any specific numerical indicators (such as the number of processes on the operating system). It only uses four abstract attributes to describe the status of the Monitored object: OK, WARNING, CRITICAL and UNKNOWN. Therefore, the Administrator only needs to pay attention to and define the threshold values of the WARNING and CRITICAL states of a monitored object. Nagios transmits the thresholds of WARTING and CRTICAL to the plug-in, and the plug-in monitors and analyzes the results of a specific object. The output information is status information (OK, WARNING, CRITICAL or UNKOWN) and some additional details.

2. Features

According to the preceding instructions, Nagios is very elastic and its monitoring function can be fully performed as expected by the Administrator. In addition, it provides automatic response to problems and a powerful notification system. All these functions are implemented based on a well-structured object definition system and a few object types.

1) Command (Commands)

The "command" defines how Nagios executes a specific monitoring task. It is an abstraction layer defined based on a specific Nagios plug-in. It usually contains a group of operations to be executed.

2) Time period (Time periods)

"Time Period" is used to define the date and time span on which an "operation" can be executed or cannot be executed, such as-every day within the working day;

3) contact and contact Group (Contacts and contact Group)

"Contacts" are used to define the notification objects for a monitoring event, the information to be notified, and the time and how these notification recipients receive notifications. One or more contacts can be defined as contact groups, one contact can also belong to multiple groups;

4) Host and Host group)

A "host" usually refers to a physical host, which includes the recipient (contact) of the notification information related to the host, and the definition of how and when to monitor the host. Hosts can also be grouped, that is, host groups. A host can belong to multiple groups at the same time;

5) Services)

A "service" usually refers to a specific function or resource that can be monitored on a host, including the recipient of the notification information related to this service, how and when to monitor it. Services can also be grouped, that is, Service groups. A Service can belong to multiple Service groups at the same time;

3. Dependency

Nagios's powerful functions are also manifested in its mature dependency system. For example, if a router device fails, other hosts associated with the device cannot be normally accessed. If the dependency between these devices cannot be defined, therefore, a large amount of device fault information is inevitable in the monitoring system. Nagios uses dependencies to describe the topological structure of network devices, and can no longer detect other devices dependent on this device when a device fails, this avoids unnecessary fault information and allows administrators to locate and troubleshoot faults in a timely manner. In addition, the dependency of Nagios can also be implemented at the service level. If a service depends on other services, it can also implement functions similar to host dependency.

4. macros

Nagios can also use macros, and macro definitions are consistent throughout the Nagios system. A macro is a variable that can be used in an object definition. Its value usually depends on the context. The macro defined in "command" has different values than the host, service, or many other parameters. For example, a command can monitor different hosts Based on the IP addresses it passes.

5. scheduled downtime

Nagios also provides the downtime mechanism in the scheduling plan. administrators can periodically set a host or service as unavailable in the plan. This feature prevents Nagios from notifying any information during scheduling downtime. Of course, this also allows Nagios to automatically notify the Administrator to perform host or service maintenance.

6. Soft and Hard States)

As mentioned above, the main task of Nagios is to check the status of the host or service and store it. A host or service status can only be one of the four available statuses at a specific time. Therefore, it is critical that the status correctly reflects the actual status of the host or service. To avoid occasional temporary or random problems, Nagios introduces soft and hard states. In actual detection, once Nagios finds that the status of a host or service is UNKOWN or different from that of the last detection, it will perform multiple tests on the host or service to ensure that the changes to this status are not unexpected. It can be configured to perform several tests. During the specified test period, Nagios assumes that the status after the change is the software status. Once the test is complete, the status becomes hard.

Ii. install and configure Nagios

1. About Nagios

Nagios generally consists of a main program (Nagios), a plug-in program (Nagios-plugins), and four optional ADDON (NRPE, NSCA, NSClient ++, and NDOUtils. Nagios monitoring is implemented through plug-ins. Therefore, Nagios and Nagios-plugins are necessary components for server work. Among the four ADDON instances, NRPE is used to execute script INS on the monitored remote Linux/Unix hosts to monitor these host resources; NSCA is used to allow the monitored remote Linux/Unix host to send monitoring information to the Nagios server (this is especially used in redundant monitoring mode ); NSClient ++ is a component used to monitor Windows hosts installed on Windows hosts, while NDOUtils is used to store Nagios configuration information and data generated by various events into the database, to quickly retrieve and process the data. In the four ADDON (attachments), NRPE and NSClient ++ work on the client, NDOUtils work on the server, and NSCA must be installed on both the server and the client.

Currently, Nagios can only be installed on a Linux host, and gcc is required for compiling. At the same time, if you want to use the web interface management tool, you also need support for the apache server and GD graphics library.

Configure Mrtg in Ubuntu to monitor Nginx and server system resources

Use snmp + Mrtg to monitor Linux systems

Mrtg server construction (Network Traffic Monitoring)

Network Monitor Nagios Overview

Nagios construction and Configuration

Build a Nagios monitoring platform in the Nginx Environment

Configure the basic Nagios System on RHEL5.3 (using Nagios-3.1.2)

CentOS 5.5 + Nginx + Nagios monitoring and control terminal installation and Configuration Guide

Install Nagios Core for Ubuntu 13.10 Server

2. Preparations before installation

(1) solve the dependency between Nagios installation:

The running of basic Nagios components depends on httpd, gcc, and gd. Run the following command to check whether the rpm package on which nagios depends has been fully installed:

[Root @ DB2 ~] # Yum-y install httpd gcc glibc-common gd-devel php-mysql-devel mysql-server

Note: You can also install the software package by compiling the source code, but the path of many related files to be used must be modified one by one according to the configuration during installation of your source code. In addition, you must start necessary services, such as httpd, as needed.

(2) Add the users and groups required for running nagios:

[Root @ DB2 ~] # Groupadd nagcmd

[Root @ DB2 ~] # Useradd-G nagcmd nagios

[Root @ DB2 ~] # Passwd nagios

Add apache to the nagcmd group so that you can have sufficient permissions when using the web Interface to operate nagios:

[Root @ DB2 ~] # Usermod-a-G nagcmd apache

3. Compile and install nagios:

[Root @ DB2 ~] # Tar-zxf nagios-3.3.1.tar.gz

[Root @ DB2 ~] # Cd nagios

[Root @ DB2 nagios] #./configure -- with-command-group = nagcmd -- enable-event-broker


* ** Configuration summary for nagios 3.3.1 07-25-2011 ***:

General Options:

-------------------------

Nagios executable: nagios

Nagios user/group: nagios, nagios

Command user/group: nagios, nagcmd

Embedded Perl: no

Event Broker: yes

Install $ {prefix}:/usr/local/nagios

Lock file: $ {prefix}/var/nagios. lock

Check result directory: $ {prefix}/var/spool/checkresults

Init directory:/etc/rc. d/init. d

Apache conf. d directory:/etc/httpd/conf. d

Mail program:/bin/mail

Host OS: linux-gnu

 


Web Interface Options:

------------------------

Html url: http: // localhost/nagios/

Cgi url: http: // localhost/nagios/cgi-bin/

Traceroute (used by WAP ):

Review the options abve for accuracy. If they look okay,

Type 'make all' to compile the main program and CGIs.
 

[Root @ DB2 nagios] # make all


* ** Compile finished ***

 


If the main program and CGIs compiled without any errors, you

Can continue with installing Nagios as follows (type 'make'

Without any arguments for a list of all possible options ):

 


Make install

-This INSTALLThe main program, CGIs, and HTML files

 


Make install-init

-This INSTALLThe init script in/etc/rc. d/init. d

 


Make install-commandmode

-This installand configures permissions on

Directory for holding the external command file

 


Make install-config

-This install* SAMPLE * config files in/usr/local/nagios/etc

You'll have to modify these sample files before you can

Use Nagios. Read the HTML documentation for more info

On doing this. Pay maid to the docs on

Object configuration files, as they determine what/how

Things get monitored!

 


Make install-webconf

-This INSTALLThe Apache config file for the Nagios

Web interface

 


Make install-exfoliation

-This INSTALLThe Exfoliation theme for the Nagios

Web interface

 


Make install-classicui

-This INSTALLThe classic theme for the Nagios

Web interface

 

 

 

* ** Support Notes *********************************** ********

 


If you have questions about running ing or running Nagios,

Please make sure that you:

 


-Look at the sample config files

-Read the documentation on the Nagios Library:

Http://library.nagios.com

 


Before you post a question to one of the mailing lists.

Also make sure to include pertinent information that cocould

Help others help you. This might include:

 


-What version of Nagios you are using

-What version of the plugins you are using

-Relevant snippets from your config files

-Relevant error messages from the Nagios log file

 


For more information on obtaining support for Nagios, visit:

 


Http://support.nagios.com

 


**************************************** *********************

 


Enjoy.
 

[Root @ DB2 nagios] # make install


* ** Main program, CGIs and HTML files installed ***

 


You can continue with installing Nagios as follows (type 'make'

Without any arguments for a list of all possible options ):

 


Make install-init

-This INSTALLThe init script in/etc/rc. d/init. d

 


Make install-commandmode

-This installand configures permissions on

Directory for holding the external command file

 


Make install-config

-This installsample config files in/usr/local/nagios/etc

 


Make [1]: Leaving directory '/root/nagios'
 

[Root @ DB2 nagios] # make install-init

 


/Usr/bin/install-c-m 755-d-o root-g root/etc/rc. d/init. d

/Usr/bin/install-c-m 755-o root-g root daemon-init/etc/rc. d/init. d/nagios

 


* ** Init script installed ***
 

[Root @ DB2 nagios] # make install-commandmode

 


/Usr/bin/install-c-m 775-o nagios-g nagcmd-d/usr/local/nagios/var/rw

Chmod g + s/usr/local/nagios/var/rw

 


* ** External command directory configured ***
 

[Root @ DB2 nagios] # make install-config


/Usr/bin/install-c-m 775-o nagios-g nagios-d/usr/local/nagios/etc

/Usr/bin/install-c-m 775-o nagios-g nagios-d/usr/local/nagios/etc/objects

/Usr/bin/install-c-B-m 664-o nagios-g nagios sample-config/nagios. cfg/usr/local/nagios/etc/nagios. cfg

/Usr/bin/install-c-B-m 664-o nagios-g nagios sample-config/cgi. cfg/usr/local/nagios/etc/cgi. cfg

/Usr/bin/install-c-B-m 660-o nagios-g nagios sample-config/resource. cfg/usr/local/nagios/etc/resource. cfg

/Usr/bin/install-c-B-m 664-o nagios-g nagios sample-config/template-object/templates. cfg/usr/local/nagios/etc/objects/templates. cfg

/Usr/bin/install-c-B-m 664-o nagios-g nagios sample-config/template-object/commands. cfg/usr/local/nagios/etc/objects/commands. cfg

/Usr/bin/install-c-B-m 664-o nagios-g nagios sample-config/template-object/contacts. cfg/usr/local/nagios/etc/objects/contacts. cfg

/Usr/bin/install-c-B-m 664-o nagios-g nagios sample-config/template-object/timeperiods. cfg/usr/local/nagios/etc/objects/timeperiods. cfg

/Usr/bin/install-c-B-m 664-o nagios-g nagios sample-config/template-object/localhost. cfg/usr/local/nagios/etc/objects/localhost. cfg

/Usr/bin/install-c-B-m 664-o nagios-g nagios sample-config/template-object/windows. cfg/usr/local/nagios/etc/objects/windows. cfg

/Usr/bin/install-c-B-m 664-o nagios-g nagios sample-config/template-object/printer. cfg/usr/local/nagios/etc/objects/printer. cfg

/Usr/bin/install-c-B-m 664-o nagios-g nagios sample-config/template-object/switch. cfg/usr/local/nagios/etc/objects/switch. cfg

 


* ** Config files installed ***

 


Remember, these are * SAMPLE * config files. You'll need to read

The documentation for more information on how to actually define

Services, hosts, etc. to fit your particle needs.
 

 


Specify the email address you want to use to receive nagios warning information for email. The default address is the native nagios User:

[Root @ DB2 nagios] # vi/usr/local/nagios/etc/objects/contacts. cfg

Email nagios @ localhost # This is the default setting

 


Create a Web program configuration file for Nagios In the httpd configuration file directory (conf. d:

[Root @ DB2 nagios] # cd/etc/httpd/conf. d/

[Root @ DB2 nagios] # make install-webconf


/Usr/bin/install-c-m 644 sample-config/httpd. conf/etc/httpd/conf. d/nagios. conf

 


* ** Nagios/Apache conf file installed ***
 

 


Create a user logging on to the nagios web program. This User Account will be used to log on to nagios for authentication in the future:

 


[Root @ DB2 nagios] # htpasswd-c/usr/local/nagios/etc/htpasswd. users nagiosadmin


New password:

Re-type new password:

Adding password for user nagiosadmin
 

 


After the above process is configured, You need to restart httpd:

[Root @ DB2 nagios] # service httpd restart


Stopping httpd: [OK]

Starting httpd: apr_sockaddr_info_get () failed for DB2

Httpd: cocould not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

[OK]
 

 


Apache installation:

[Root @ DB2 ~] # Wget http://archive.apache.org/dist/httpd/httpd-2.2.23.tar.gz

[Root @ DB2 ~] # Tar-zxf httpd-2.2.23.tar.gz

[Root @ DB2 ~] # Cd httpd-2.2.23

[Root @ DB2 httpd-2.2.23] #./configure -- prefix =/usr/local/apache2

[Root @ DB2 httpd-2.2.23] # make & make install

 


[Root @ DB2 php-5.6.2] # yum-y install libxml2

[Root @ DB2 php-5.6.2] # yum install libxml2-devel-y

 


PHP installation:

[Root @ DB2 ~] # Wget http://cn2.php.net/distributions/php-5.6.2.tar.gz

[Root @ DB2 ~] # Tar zxf php-5.6.2.tar.gz

[Root @ DB2 ~] # Cd php-5.6.2

[Root @ DB2 php-5.6.2] #./configure -- prefix =/usr/local/php -- with-apxs2 =/usr/local/apache2/bin/apxs

 


Generating files

Configure: creating./config. status

Creating main/internal_functions.c

Creating main/internal_functions_cli.c

+ -------------------------------------------------------------------- +

| License: |

| This software is subject to the PHP License, available in this |

| Distribution in the file LICENSE. By continuing this installation |

| Process, you are bound by the terms of this license agreement. |

| If you do not agree with the terms of this license, you must abort |

| The installation process at this point. |

+ -------------------------------------------------------------------- +

 


Thank you for using PHP.

 


Config. status: creating php5.spec

Config. status: creating main/build-defs.h

Config. status: creating scripts/phpize

Config. status: creating scripts/man1/phpize.1

Config. status: creating scripts/php-config

Config. status: creating scripts/man1/php-config.1

Config. status: creating sapi/cli/php.1

Config. status: creating sapi/cgi/php-cgi.1

Config. status: creating ext/phar/phar.1

Config. status: creating ext/phar. phar.1

Config. status: creating main/php_config.h

Config. status: executing default commands
 

[Root @ DB2 php-5.6.2] # make & make install


Build complete.

Don't forget to run 'make test '.

 


Installing php sapi module: apache2handler

/Usr/local/apache2/build/instdso. sh SH_LIBTOOL = '/usr/local/apache2/build/libtool' libphp5.la/usr/local/apache2/modules

/Usr/local/apache2/build/libtool -- mode = install cp libphp5.la/usr/local/apache2/modules/

Cp. libs/libphp5.so/usr/local/apache2/modules/libphp5.so

Cp. libs/libphp5.lai/usr/local/apache2/modules/libphp5.la

Libtool: install: warning: remember to run 'libtool -- finish/root/php-5.6.2/libs'

Chmod 755/usr/local/apache2/modules/libphp5.so

[Activating module 'php5 'in/usr/local/apache2/conf/httpd. conf]

Installing shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/

Installing php cli binary:/usr/local/php/bin/

Installing php cli man page:/usr/local/php/man/man1/

Installing php cgi binary:/usr/local/php/bin/

Installing php cgi man page:/usr/local/php/man/man1/

Installing build environment:/usr/local/php/lib/php/build/

Installing header files:/usr/local/php/include/php/

Installing helper programs:/usr/local/php/bin/

Program: phpize

Program: php-config

Installing man pages:/usr/local/php/man/man1/

Page: phpize.1

Page: php-config.1

Installing PEAR environment:/usr/local/php/lib/php/

[PEAR] Archive_Tar-installed: 1.3.12

[PEAR] lele_getopt-installed: 1.3.1

[PEAR] Structures_Graph-installed: 1.0.4

[PEAR] XML_Util-installed: 1.2.3

[PEAR] PEAR-installed: 1.9.5

Wrote PEAR system config file at:/usr/local/php/etc/pear. conf

You may want to add:/usr/local/php/lib/php to your php. ini include_path

/Root/php-5.6.2/build/shtool install-c ext/phar. phar/usr/local/php/bin

Ln-s-f/usr/local/php/bin/phar. phar/usr/local/php/bin/phar

Installing PDO headers:/usr/local/php/include/php/ext/pdo/

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.