Nagios's surveillance

Source: Internet
Author: User

Monitoring systems need to be monitored:

1. Local Resources: Load (uptime), CPU (top, SAR), Disk (DF), memory (free), IO (Iostat), RAID, temperature, passwd file changes, all local file fingerprint identification

2, network services: port, URL, packet loss, number of processes, network traffic

3. Other Devices: Routers, switch port traffic, printers, windows

4, Business data: The number of user logon failures, the number of users logged in the site, enter the number of failed verification code

One API interface traffic concurrency, e-commerce site orders, payment of the number of transactions

5, monitoring software itself is only a platform, want to monitor the content, theoretically as long as the server command line can be obtained

Data can be monitored by monitoring software

Nagios monitoring is typically performed by a main program Nagios, a plug-in program Nagios-plugins, and optional additional programs (NRPE, nsclient++, NSCA, and ndoutils), etc.

Nagios itself is a monitoring platform, and its specific monitoring work is implemented by plugins (nagios-plugins), so the Nagios main program and the Nagios-plugins plugin are

Nagios server side must be installed on the program components, Nagios-plugins generally also installed on the monitored side. Several additional programs are described below:

1. NRPE: Semi-passive mode

Presence Location: Nrpe software works on monitored side, operating system is Linux,unix system

Nrpe function: Used to execute script plugin on monitored remote Linux,unix host to get data back to server side for monitoring of these host resources

Presence form: Daemon agent mode, open port 5666


2. nsclient++: Semi-passive mode

Presence location: For servers that are monitored for Windows systems

Function: Functions equivalent to Nrpe under Linux

Components that are installed on a Windows host when you use it to monitor Windows hosts


3, NSCA: pure passive mode of monitoring

Location: NSCA needs to be installed on both the server side and the client

Role: Used to enable monitored remote Linux, UNIX host actively to monitor the information sent to the Nagios server (in the Distributed monitoring cluster mode to use, within 300 servers, can not be used)

Introduction to Distributed Monitoring NSCA external components: In order to commit the mandatory detection result from the remote host, the NSCA external component is developed. The external component consists of two parts, the first part

is the client program (SEND_NSCA) that runs on the remote host and is responsible for sending the force detection results to the specified Nagios server side, and the other part is the NSCA daemon (NSCA)

It can be run independently of the daemon service or can be registered to inetd as a inetd client program to provide a listening connection. After receiving the service detection result information from the client, the daemon

Submit the results to Nagios on the hub server by inserting a process_svc_check_result command in the external command file, followed by the test results. In Nagios

The next time the server processes the external command, it will find the mandatory detection result sent by the distributed server and process it


First install the Nagios server side:

1. Some package components required for installation

Yum install httpd php php-cli gcc glibc glibc-common gd gd-devel net-snmp-y


2. Modify the httpd.conf file

Vim/etc/httpd/conf/httpd.conf

-"ServerName localhost"

Service httpd Start


3. Add Users

#useradd Nagios

Useradd Nagios

passwd nagios----> Set Password to Redhat


4. Add a gagcmd Group

#groupadd Gagcmd

Groupadd Nagcmd

Usermod-a-G Nagcmd Nagios

Usermod-a-G Nagcmd Apache


5. Compiling and installing Nagios software

Mkdir/home/huang/tools-p

cd/home/huang/tools/

wget https://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.1.1/nagios-4.1.1.tar.gz

Tar xzf nagios-4.1.1.tar.gz

CD nagios-4.1.1

./configure--with-command-group=nagcmd

Make all

Make install

Make Install-init

Make Install-config

Make Install-commandmode

Make install-webconf

--"Because Nagios's web interface requires authorization authentication:

-"htpasswd-c/usr/local/nagios/etc/htpasswd.users nagiosadmin----> Set password for Redhat

Service httpd Restart


6. Compile and install the plugin Nagios-plugins

cd/home/huang/tools/

wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz

Tar Xfz nagios-plugins-2.1.1.tar.gz

CD nagios-plugins-2.1.1

./configure--with-nagios-user=nagios--with-nagios-group=nagios

Make

Make install

/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg Detect if there is an error

Service Nagios Start

Chkconfig--add Nagios

Chkconfig Nagios on


7, install the plug-in Nrpe:

wget https://github.com/NagiosEnterprises/nrpe/archive/3.0.tar.gz

Tar XF 3.0.tar.gz

CD nrpe-3.0/

./configure

Make all

Make install

Make Install-plugin

Make Install-daemon

Make Install-config

Here are some of the compilation parameter choices:

###

[[email protected] nrpe-3.0]# make

Please enter make [option] where [option] is one of:

All builds Nrpe and Check_nrpe

Nrpe builds Nrpe only

Check_nrpe builds Check_nrpe only

Install-groups-users Add the users and groups if they do not exist

Install install Nrpe and Check_nrpe

Install-plugin Install the Check_nrpe plugin

Install-daemon Install the Nrpe daemon

Install-config Install the Nrpe configuration file

INSTALL-INETD Install the startup files for inetd, launchd, etc.

Install-init Install the startup files for Init, systemd, etc.


Turn on the Nagios server:

Service Nagios Start

Browser access:

Http://192.168.1.155/nagios


Install the client software that needs to be monitored:

#监控Linux, UNIX hosts, installing clients

Add Nagios Users

Useradd-m nagios-s/sbin/nologin


#安装插件nagios-plugins

cd/home/huang/tools/

wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz

Tar Xfz nagios-plugins-2.1.1.tar.gz

CD nagios-plugins-2.1.1

./configure--with-nagios-user=nagios--with-nagios-group=nagios--prefix=/usr/local/nagios

Make

Make install


Chown-r nagios.nagios/usr/local/nagios/


#安装NRPE

wget https://github.com/NagiosEnterprises/nrpe/archive/3.0.tar.gz

Tar XF 3.0.tar.gz

CD nrpe-3.0/

./configure

Make all

Make install

Make Install-plugin

Make Install-daemon

Make Install-config


###### #测试监控

Use Nagios to monitor this machine for testing:

[Email protected] objects]# pwd

/usr/local/nagios/etc/objects

[Email protected] objects]# tree

.

├──COMMANDS.CFG---Storing the Nagios command-related configuration (optionally specifying the commands directory), where the command is not a system command, but instead implements the commands defined in Nagios and

A file associated with a plugin in a Linux system

├──contacts.cfg--"store the relevant configuration files of the alarm contact person

├──localhost.cfg

├──printer.cfg

├──switch.cfg

├──templates.cfg-template configuration file, template exists for convenient configuration of the server configuration.

├──timeperiods.cfg--"storage alarm cycle time and other related configuration

└──windows.cfg

Service.cfg-----------"store specific monitored host-related configuration, default does not exist

Hosts.cfg-----------"store specific monitored host-related configuration, default does not exist

The name of Localhost.cfg is hosts.cfg.


Active mode: Not related to Nrpe, is to use the server-side local plug-in direct access to information

General monitoring services: httpd, sshd, mysqld, etc.

Passive mode: The data is obtained through the client Nrpe

The main program communicates with the client Nrpe process through the Check_nrpe plugin, calling the local plug-in to get the data


#配置check_nrpe命令

Configure Check_nrpe to the Commands.cfg configuration file to successfully invoke the plug-in

Define Command {

Command_nameCheck_nrpe

Command_line $USER 1$/check_nrpe-h $HOSTADDRESS-C $ARG 1$

}

Example:

/usr/local/nagios/libexec/check_nrpe-h 192.168.1.11 (client IP)-C check_disk


#配置hosts. cfg file

Rename the localhost.cfg to hosts.cfg and modify it to the following

[email protected] etc]# cat objects/hosts.cfg

###############################################################################

# LOCALHOST. Cfg-sample OBJECT CONFIG FILE for monitoring

#

#

# note:this config file is intended to serve as a *extremely* simple

# Example of how can I create configuration entries to monitor

# The local (Linux) machine.

#

# HOST DEFINITION

# Define A host for the Local machine

#define A host for Nagios server

Define Host{

Use Linux-server; The Name of the host template to the use----"is the default

; This host definition would inherit all variables that is defined

; In (or inherited by) the Linux-server host template definition.

HOST_NAME nagios_server----"The name can be taken anywhere

Alias Nagios_server

Address 192.168.1.155----"Here I'm monitoring the Nagios native server side

}

# HOST GROUP DEFINITION

# Define An optional HostGroup for Linux machines

Define Hostgroup{

Hostgroup_name linux-servers; The name of the HostGroup

Alias Linux Servers; Long Name of the group

Members Nagios_server; Comma separated list of hosts that belong to this group-----the hosts to be monitored are added to the HostGroup group and put into members

}


#配置services. cfg file

Cd/usr/local/nagios/etc/objects

Touch services.cfg

Chown-r Nagios.nagios services.cfg

Edit the file to add services that need to be monitored

Define Service{

Use generic-service

HOST_NAME nagios_server-----"Here I use Nagios server to do the monitoring sample, because I Nrpe plugin does not start all non-monitoring service information

Service_description CPU Load

Check_command Check_nrpe!check_load

}


Manually collect the data by using the command first:

[Email protected] etc]#/usr/local/nagios/libexec/check_nrpe-h 192.168.1.155-c check_load

Connect to address 192.168.1.155 Port 5666:connection refused

Connect to host 192.168.1.155 Port 5666:connection refused

Discovery failed to collect data and found that the Nrpe service was not started, so

#nrpe start listening on port 5666

Modify configuration file: Nrpe.cfg

allowed_hosts=127.0.0.1,192.168.1.155


[Email protected] objects]#/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d

[Email protected] objects]# NETSTAT-TUNLP

Active Internet connections (only servers)

Proto recv-q send-q Local address Foreign address State Pid/program Name

TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2597/sshd

TCP 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1216/master

TCP 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 55737/nrpe

TCP 0 0::: +:::* LISTEN 33699/httpd

TCP 0 0::: $:::* LISTEN 2597/sshd

TCP 0 0:: 1:25:::* LISTEN 1216/master

TCP 0 0::: 5666:::* LISTEN 55737/nrpe


Manually test again to see if the data can be collected

[Email protected] objects]#/usr/local/nagios/libexec/check_nrpe-h 192.168.1.155-c check_load

Ok-load average:0.00, 0.00, 0.00|load1=0.000;15.000;30.000;0; load5=0.000;10.000;25.000;0; load15=0.000;5.000;20.000;0;

Data collection, Observation web monitoring page

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/86/4A/wKiom1e6-0-h8CbvAACYS9ClTrY085.jpg "title=" Nagios.jpg "alt=" Wkiom1e6-0-h8cbvaacys9cltry085.jpg "/>

So simple monitoring is done

Reference article: http://tecadmin.net/install-nagios-core-service-on-centos-rhel/

And the PDF of the attachment



Nagios's surveillance

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.