centos7.4 Installation monitoring Software series 2:nagios

Source: Internet
Author: User

Similar to the series 1 cacti, Nagios is also a monitoring software, involving more plug-ins, flexible monitoring of server resources, the use of more extensive;
Nagios itself is not a monitoring function, all of its functions are done by invoking plug-ins, it has two modes of operation: active monitoring, passive monitoring.
"Passive monitoring" nagios is passively monitored by NSCA. is to actively upload data to the Nagios monitoring system by the detected end server and then Nagios to read the data. This monitoring method improves the real-time data, reduces the monitoring delay, and the amount of the monitored data is greatly increased. Only NSCA plugins are currently known to support passive monitoring.
Active monitoring nagios is actively monitored via the Nrpe plug-in and the SNMP protocol. Nagios periodically calls the plugin to fetch data from the remote host, which makes real-time worse. Active mode can be used in cases where the number of monitoring hosts is low.

The configuration for active monitoring is described here:

Nagios invokes its plug-in library, which returns the monitoring results to Nagios,nagios to analyze the results and show it to us in the web, while also invoking the plugin to provide alarm functionality.
For remote monitoring, the Check_nrpe plugin is required, Nagios executes the plug-in, and tells Check_nrpe to detect which services. Check_nrpe connect the Nrpe daemon on the remote machine via SSL, then Nrpe can run various local plug-ins to detect the local service and status, and finally Nrpe the result of the test to the Check_nrpe,nagios end of the Nagios side Check_ The Nrpe then sends the results to the status queue so that Nagios reads the information and ultimately renders the Web page results to the administrator.
Four monitoring statuses for Nagios:
0 (OK) normal, Green
1 (warning) warning, xxx
2 (Critical) fatal error, red
3 (unknown) position error, deep xxx

This example: monitoring the client's MySQL

Nagios Server (monitor side): 192.168.80.80 need to install the following software:
Lamp architecture provides Web monitoring view
NAGIOS-4.3.4.TAR.GZ Server server Nagios main program
nagios-plugins-2.2.1.tar.gz Nagios Plugin
Nrpe-3.2.1.tar.gz plug-in, responsible for remote connection
PNP4NAGIOS-0.6.26.TAR.GZ Chart Tools

Ngios client (Monitored): 192.168.80.81 need to install the following software:
nagios-plugins-2.2.1.tar.gz Nagios Plugin
Nrpe-3.2.1.tar.gz plug-in, responsible for remote connection
MySQL compiled and installed for testing only

Case implementation: I. Service side (monitoring side) configuration 1. Install lamp, can be installed Yum, save time, commissioning can provide Web services; 2. Install Nagios:

Groupadd Nagcmd
Useradd-g Nagcmd Nagios
Usermod-a-G Nagcmd Apache
Id-n-G Apache

Tar XF nagios-4.3.4.tar.gz
CD nagios-4.3.4
./configure--with-command-group=nagcmd

Make all

Make install
Make Install-init//Generate Management scripts
Make Install-commandmode//Automatically set permissions on the relevant directory for Nagios users
Make Install-config//install configuration file

Cp-r contrib/eventhandlers//usr/local/nagios/libexec/
Chown-r nagios:nagios/usr/local/nagios/libexec/eventhandlers
/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg//Check configuration file
/etc/init.d/nagios checkconfig//Check configuration issues
Make install-webconf//Generate Nagios/apache configuration file

Htpasswd-c/usr/local/nagios/etc/htpasswd.users Nagios

Service Nagios Start
Service httpd Restart

WIN10 Access http://192.168.80.80/nagios///will enter Nagios's main console and will have a login prompt

3. Installing Nagios-plugins

Tar XF nagios-plugins-2.2.1.tar.gz
CD nagios-plugins-2.2.1
./configure \
--with-nagios-user=nagios \
--with-nagios-group=nagcmd \
--enable-perl-modules

Make && make install

4. Installing Nrpe

Tar XF nrpe-3.2.1.tar.gz
CD nrpe-3.2.1
./configure
Make all
Make Install-plugin
Make Install-daemon

CP Sample-config/nrpe.cfg/usr/local/nagios/etc/nrpe.cfg

ls/usr/local/nagios/libexec///Check plug-in installation situation

/usr/local/nagios/bin/nrpe-d-c/usr/local/nagios/etc/nrpe.cfg//Start Nrpe

echo "/usr/local/nagios/bin/nrpe-d-c/usr/local/nagios/etc/nrpe.cfg" >>/etc/rc.local//Configurable boot-up

chmod +x/etc/rc.d/rc.local
Netstat-lnput|grep 5666

/usr/local/nagios/libexec/check_nrpe-h localhost//test local connection
NRPE v3.2.1

Two: client (monitored) settings 1. Manually compile and install MySQL, test to provide MySQL service 2. Install Nagios-plugins

Yum install-y perl-devel Perl-cpan openssl-devel

Tar XF nagios-plugins-2.2.1.tar.gz

Useradd-m Nagios

CD nagios-plugins-2.2.1
./configure \
--with-nagios-user=nagios \
--with-nagios-group=nagios \
--enable-perl-modules

Make && make install

3. Installing Nrpe

Tar XF nrpe-3.2.1.tar.gz
CD nrpe-3.2.1

./configure

Make all
Make Install-plugin
Make Install-daemon

mkdir/usr/local/nagios/etc/
CP sample-config/nrpe.cfg/usr/local/nagios/etc/nrpe.cfg//Copy template, the following need to configure the use

ls/usr/local/nagios/libexec///View Nrpe Plugin

/usr/local/nagios/bin/nrpe-d-c/usr/local/nagios/etc/nrpe.cfg//Start Nrpe

echo "/usr/local/nagios/bin/nrpe-d-c/usr/local/nagios/etc/nrpe.cfg" >>/etc/rc.local//Can be added to boot boot

chmod +x/etc/rc.d/rc.local
Netstat-lnput|grep 5666

/usr/local/nagios/libexec/check_nrpe-h localhost//test local connection
NRPE v3.2.1

4. Configure Nrpe.cfg

cd/usr/local/nagios/etc/

VI nrpe.cfg

allowed_hosts=127.0.0.1,::1,192.168.80.80//Back Add monitor end 80 address, allow server side address connection
Command[check_users]=/usr/local/nagios/libexec/check_users-w 5-c 10
Defines the command to check the user, more than 5 user w-warning. 10 + users C-critical
Command[check_load]=/usr/local/nagios/libexec/check_load-r-W. 15,.10,.05-c. 30,.25,.20
Command[check_sda1]=/usr/local/nagios/libexec/check_disk-w 20%-C 10%-p/dev/sda1
Command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs-w 5-c 10-s Z
Command[check_total_procs]=/usr/local/nagios/libexec/check_procs-w 150-C 200
All of these are client-defined Nrpe commands that can be called by the monitoring side Nrpe to enable monitoring

/usr/local/nagios/libexec/check_nrpe-h localhost-c Check_total_procs
You can test the execution of local commands first to ensure that there are no problems

Three: Service side (monitoring side) configuration Test 1. Test whether the two machines Nrpe can be connected remotely

Pkill Nrpe
/usr/local/nagios/bin/nrpe-d-c/usr/local/nagios/etc/nrpe.cfg//Restart Nrpe

/usr/local/nagios/libexec/check_nrpe-h 192.168.80.81//test Connection condition
/usr/local/nagios/libexec/check_nrpe-h 192.168.80.81-c check_sda1//test command is executable

2. Configuration

VI/ETC/USR/LOCAL/NAGIOS/ETC/NAGIOS.CFG//Configuring the master configuration file
cfg_dir=/usr/local/nagios/etc/conf//Last or suitable location new subdirectory, easy to configure
Mkdir/usr/local/nagios/etc/conf

VI/ETC/USR/LOCAL/NAGIOS/ETC/OBJECTS/COMMANDS.CFG//configuration command configuration file, where defined commands can be called by other configuration files
Define Command{
Command_name Check_nrpe
Command_line $USER 1$/check_nrpe-h $HOSTADDRESS $-C $ARG 1$
}//Last insert adds a definition for Check_nrpe

VI/ETC/USR/LOCAL/NAGIOS/ETC/OBJECTS/CONTACTS.CFG//Configure contacts or groups to notify when problems occur
emial [email protected]//admin Email address

cd/usr/local/nagios/etc/conf//Start defining hosts and host groups, services
VI host81.cfg//define hosts and host groups
Define Host{
Use Linux-server//monitor used templates
HOST_NAME the name displayed on the MySQL//monitor platform
Alias www.bb.com//name displayed on the monitoring platform
Address 192.168.80.81//managed End addresses
}
Define hostgroup{//define host Group
Hostgroup_name Testgroup
Alias MySQL
Members MySQL
}

VI server81.cfg//define the Check_command that the service uses to be defined in Commands.cfg

Define Service{
HOST_NAME MySQL//monitoring service Name
Service_description check-host-alive//Monitoring description
Check_command check-host-alive//monitoring command name (host is alive)
Max_check_attempts 3//Check the number of retries after failure
Check_interval 2//Check interval time
Retry_interval 2//Retry interval time
Check_period 24x7//monitor time period defined in Timeperiods.cfg
Notification_interval 300//Reminder interval time, every 300 seconds reminder
Notification_period 24x7//reminder cycle, which is defined in Timeperiods.cfg
Notification_options w,u,c,r//When the host appears w-warning, u-unknown,c-critical,r-alert the administrator when recovering from an abnormal state (D-down)
#contact_groups Admins
Process_perf_data 1
}
Define Service{
HOST_NAME MySQL
Service_description Check-procs
Check_command Check_nrpe!check_total_procs
Max_check_attempts 3
Check_interval 2
Retry_interval 2
Check_period 24x7
Notification_interval 300
Notification_period 24x7
Notification_options W,u,c,r
#contact_groups Admins
Process_perf_data 1
}
Define Service{
HOST_NAME MySQL
Service_description Check-load
Check_command Check_nrpe!check_load
Max_check_attempts 3
Check_interval 2
Retry_interval 2
Check_period 24x7
Notification_interval 300
Notification_period 24x7
Notification_options W,u,c,r
#contact_groups Admins
Process_perf_data 1
}
Define Service{
HOST_NAME MySQL
Service_description Check-ssh
Check_command Check_ssh
Max_check_attempts 3
Check_interval 2
Retry_interval 2
Check_period 24x7
Notification_interval 300
Notification_period 24x7
Notification_options W,u,c,r
#contact_groups Admins
Process_perf_data 1
}

CD/USR/LOCAL/NAGIOS/ETC//Increase Nagios Group authorization
grep nagiosadmin cgi.cfg//The user group that checks the relevant authorization in the configuration file defaults to only Nagiosadmin
Sed-i ' s/nagiosadmin/nagiosadmin,nagios/g ' cgi.cfg//Add Nagios Group authorization

Service Nagios Restart

3. Test:

WIN10 Access Http://192.168.80.80/nagios can see the monitoring host 80.81

At this point, nagios monitoring Basic configuration is complete, how to graphically more intuitive to view on the Web? Need to add the use of graphical modules, to be continued ...

centos7.4 Installation monitoring Software series 2:nagios

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.