Build Nagios Monitoring steps

Source: Internet
Author: User

1. Experimental environment:

Host Name: The software environment required by IP

Nagios-server 192.168.124.143 Apache, Php, Nagios, Nagios-plugins, Nrpe

Nagios-linux 192.168.124.203 Nagios-plugins, Nrpe

Nagios software is required on the monitor nagios-server to handle the monitored data and to provide a web interface for viewing and management. Of course, the information of the machine itself is monitored;

Monitoring machine Nagios-linux need to install Nrpe and Nagios plugins, according to the monitoring machine's request to perform monitoring, and then return the results to the monitoring machine;

I. Environmental readiness on the Nagios Surveillance Machine (192.168.124.143)

1. Install the compilation environment

Installing with Yum

[email protected] ~]# Yum install-y gcc glibc glibc-common gd xinetd openssl-devel mysql-devel

2. Create Nagios users and user groups

[[Email protected] ~] #useradd-S/sbin/nologin nagios

[[Email protected] ~] #mkdir/usr/local/nagios

[[Email protected] ~] #chown-R Nagios:nagios/usr/local/nagios

3. Yum installs httpd and PHP, and configures httpd to support PHP

As long as the browser can achieve normal access to HTTP//native ip/index.php can be

4. Compiling and installing Nagios

Upload the Nagios source package to the/root directory

[[Email protected] ~] #tar zxvf nagios-4.0.3.tar.gz

[[Email protected] ~] #cd nagios-4.0.3

[Email protected] ~]#./configure--prefix=/usr/local/nagios--with-nagiosuser=nagios--with-nagios-group=nagios

[[Email protected] ~] #make All

[[Email protected] ~] #make Install

[[Email protected] ~] #make install-init

[[Email protected] ~] #make Install-commandmode

[[Email protected] ~] #make install-config

[[Email protected] ~] #make install-webconf

[[Email protected] ~] #chkconfig--add Nagios # Add Nagios to System services

[[Email protected] ~] #chkconfig Nagios on

5. Verify that Nagios is properly installed

Switch directories to the installation path (here is/usr/local/nagios) to see if there are other directories such as etc, Bin, libexec, Sbin, Share, Var, if present, it can indicate that the program is properly installed to the system.

Nagios Various directory uses are described below:

Directory name Usage

directory where the bin Nagios executable program resides

The directory where the ETC Nagios configuration files are located

The directory where the sbin nagios CGI file is located, which is the directory where the files needed to execute the external command reside share the Nagios Web page file

Libexec Nagios External plug-in directory

The directory where the Var Nagios log files, lock, and other files reside

Var/archives Nagios Log Auto Archive directory

VAR/RW the directory used to store external command files

6. Install Nagios Plugin

Upload nagios-plugins-1.5.tar.gz to/root directory

[[Email protected] ~] #tar zxvf nagios-plugins-1.5.tar.gz

[[Email protected] ~] #cd nagios-plugins-1.5

[Email protected] ~]#./configure--prefix=/usr/local/nagios--with-mysql--with-nagios-user=nagios-- With-nagiosgroup=nagios

[[Email protected] ~] #make && make install

Note:

--with-mysql enables Nagios plug-ins to monitor MySQL (the system needs yum to install the Mysql-devel package first) and Check_mysql and Check_mysql_query commands in the Libexec directory

7. Install Check_nrpe plug-in

Upload nrpe-2.12.tar.gz to/root directory

[[Email protected] ~] #tar zxvf nrpe-2.12.tar.gz

[[Email protected] ~] #cd nrpe-2.12

[Email protected] ~]#./configure--with-nrpe-user=nagios--with-nrpe-group=nagios--with-nagiosuser=nagios --with-nagios-group=nagios--enable-command-args--enable-ssl

[[Email protected] ~] #make All

[[Email protected] ~] #make install-plugin

The monitor only runs to this step, because only the Check_nrpe plugin in Nrpe is required

8, modify the Apache configuration file/etc/httpd/conf/httpd.conf

[[Email protected] ~] #vim/etc/httpd/conf/httpd.conf

User Apache modified to user Nagios

Group Apache modified to group Nagios

DirectoryIndex index.html modified to DirectoryIndex index.php

Save

9, for the sake of security, in general, to let Nagios Web monitoring page must be authorized to access the compiled installation Nagios 4.0. After the 3 version is complete, the httpd is automatically configured and the default htpasswd validation file is set /usr/local/nagios/etc/htpasswd.users

[[Email protected] ~] #htpasswd-C/usr/local/nagios/etc/htpasswd.users nagiosadmin #指定用户 nagiosadmin can access

10. Start httpd Service

[[Email protected] ~] #service httpd restart

[[Email protected] ~] #service nagios Start

11. Browser Access to Nagios site

Http://192.168.124.143/nagios

Second, the Monitoring Machine (192.168.124.203) installed Nrpe and Nagios-plugins

1. Install the compilation environment

Installing with Yum

[email protected] ~]# Yum install-y gcc glibc glibc-common gd xinetd openssl-devel mysql-devel

2. Compile and install Nagios plugin

Upload nagios-plugins-1.5.tar.gz to/root directory

[[Email protected] ~] #tar-ZXVF nagios-plugins-1.5.tar.gz

[[Email protected] ~] #cd nagios-plugins-1.5

[Email protected] ~]#./configure--with-mysql--with-nagios-user=nagios--with-nagios-group=nagios

[[Email protected] ~] #make && make install

After this step is completed, two directories libexec and share are generated under/usr/local/nagios/, and directory permissions are modified [[email protected] ~] #useradd-S/sbin/nologin nagios

[[Email protected] ~] #chown-R Nagios:nagios/usr/local/nagios

3. Compile and install Nrpe

Upload nrpe-2.12.tar.gz to/root directory

[[Email protected] ~] #tar-ZXVF nrpe-2.12.tar.gz

[[Email protected] ~] #cd nrpe-2.12

[Email protected] ~]#./configure--with-nrpe-user=nagios--with-nrpe-group=nagios--with-nagiosuser=nagios --with-nagios-group=nagios--enable-command-args--enable-ssl

[[Email protected] ~] #make All

[[Email protected] ~] #make install-plugin

[[Email protected] ~] #make Install-daemon

[[Email protected] ~] #make install-daemon-config

#现在再查看/usr/local/nagios Directory will find 4 subdirectories

[[Email protected] ~] #make install-xinetd

[[Email protected] ~] #vim/etc/xinetd.d/nrpe

Modify at the end of the entry Only_from = 192.168.124.0/24

This setting allows access to the network segment where the monitor is located

[[Email protected] ~] #vim/etc/services

#编辑/etc/services file, add Nrpe service content at the end

At the end add Nrpe 5666/tcp #nrpe

[[Email protected] ~] #service xinetd Restart

[[Email protected] ~] #netstat-ntulp|grep 5666

#查看nrpe是否已启动并监听5666端口

4. Test whether the Nrpe is working properly

Perform Check_nrpe This plugin on the monitor (192.168.124.143) to test communication with the monitored machine (192.168.124.203)

[[email protected] ~]#/usr/local/nagios/libexec/check_nrpe-h 192.168.124.203 if Nrpe V2.12 is displayed, Nrpe communication is normal

Third, the Monitoring Machine (192.168.124.143) on the configuration

1. Add Check_nrpe definition at the end of the Commands.cfg file

[[Email protected] ~] #vim/usr/local/nagios/etc/objects/commands.cfg

#添加如下 Code

Define Command{

Command_name Check_nrpe

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

2, define the monitoring of the Nagios-linux host, create the Nagios_linux.cfg file and add the following code content


[[Email protected] ~] #vim/usr/local/nagios/etc/objects/nagios_linux.cfg

Define Host{

Use Linux-server

HOST_NAME Nagios-linux

Alias Nagios-linux

Address 192.168.124.67 #此处设置被监控机的IP地址}

Define service{#添加监控CPU负载的服务

Use Local-service

HOST_NAME Nagios-linux

Service_description CPU Load

Check_command Check_nrpe!check_load

}

Define service{#添加监控总进程数的服务

Use Local-service

HOST_NAME Nagios-linux

Service_description Total Processes

Check_command Check_nrpe!check_total_procs

}

The code above defines the monitoring services for CPU load (CPU loads) and total Processes (number of processes), and additional monitoring services can be added to this file

3. Add the following code to the end of Nagios's main configuration file nagios.cfg

[[Email protected] ~] #vim/usr/local/nagios/etc/nagios.cfg

Cfg_file=/usr/local/nagios/etc/objects/nagios_linux.cfg

#在nagios的主配置文件中增 the configuration file of the monitored machine

4. Restart the Services

[[Email protected] ~] #service httpd restart

[[Email protected] ~] #service nagios Restart

5. Verify that Nagios can monitor the native (localhost) and the monitored machine nagios-linux

Http://ip/nagios

6, [[email protected] ~] #service httpd restart

[[Email protected] ~] #service nagios Restart

#重启验证新增的监控信息

Ok! This is the end! I hope I have some help with you.


This article is from the "12178027" blog, please be sure to keep this source http://12188027.blog.51cto.com/12178027/1863548

Build Nagios Monitoring steps

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.