The method of Nagios monitoring LVS connection number in Linux

Source: Internet
Author: User
Tags openssl

About LVS

LVS is a short version of Linux virtual Server, which means the Linux VM, is a virtual server cluster system. This project was established by Dr. Zhangwensong in May 1998 and is one of the earliest free software projects in China.

Several structures of scalable network services that require a front-end load scheduler (or multiple master-slave backups). First, we analyze the main technology of implementing the virtual Network Service, and point out that the IP load balancing technology is the most efficient in the implementation of the load scheduler. In the existing IP load balancing technology, there is a group of servers that make up a high-performance, highly available virtual server via network address translation (network addressing translation), which we call Vs/nat technology (virtual server via Network address translation). On the basis of analyzing the disadvantage of vs/nat and the asymmetry of network service, we propose the method of implementing virtual server via IP tunneling Vs/tun (virtual server via IP tunneling) and the method of implementing virtual server via direct routing vs/ DR (Virtual Server via Direct Routing), which can greatly improve the scalability of the system. Vs/nat, Vs/tun and VS/DR technologies are three IP load balancing technologies implemented in LVS cluster.

Nagios Introduction

Nagios is a monitoring system that monitors system operation status and network information. Nagios can monitor the specified local or remote host and service, as well as provide exception notification capabilities. [1]
Nagios can be run on the Linux/unix platform while providing an optional browser-based Web interface for system administrators to view network status, various system issues, and logs, etc.

Nagios Service-side installation

5.1 Base Support Kit: GCC glibc glibc-common gd gd-devel xinetd openssl-devel

# rpm-q gcc glibc glibc-common gd gd-devel xinetd openssl-devel

If these kits are not available on the system, use the Yum installation
# yum install-y gcc glibc glibc-common gd gd-devel xinetd openssl-devel
5.2 Creating Nagios users and user groups
# useradd-s/sbin/nologin nagios
# mkdir/usr/local/nagios
# chown-r Nagios.nagios/usr/local/nagios
To view permissions for the Nagios directory
# ll-d/usr/local/nagios/
5.3 Compile and install Nagios
# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.3.tar.gz
# tar ZXVF nagios-3.4.3.tar.gz
# CD Nagios
#./configure--prefix=/usr/local/nagios
# make All
# make Install
# Make Install-init
# Make Install-commandmode
# Make Install-config
# chkconfig--add Nagios
# chkconfig--level Nagios on
# chkconfig--list Nagios
5.4 Verify that the program is properly installed
Switch directories to the installation path (here is/usr/local/nagios), see if there are etc, bin, sbin, share, VAR, five directories, if the presence of the program is properly installed to the system. Nagios Each directory uses the following description:

Bin directory where the Nagios executable program resides
etc Nagios Configuration file Directory
Sbin directory where the Nagios CGI files reside, which is the directory where the files needed to execute the external command
Share Nagios the directory where the Web page files are located
Libexec Nagios External Plugin Directory
Var Nagios the directory where the log files, lock, and other files are located
Var/archives Nagios Log Automatic archive directory
Var/rw The directory used to hold external command files

5.5 Installing Nagios Plugin
# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz
# tar ZXVF nagios-plugins-1.4.16.tar.gz
# CD nagios-plugins-1.4.16
#./configure--prefix=/usr/local/nagios
# Make && make install

Nagios Monitoring LVS Connection number

1. Client Configuration
1.1 Let Nagios account have View IPVSADM permission
Vim/etc/sudoers
Join Nagios all= (All) Nopasswd:all

1.2 Add Check Script
Vim/etc/nagios/libexec/check_lvs
#!/bin/bash

Act_count=0

Inactive_count=0

Stat1= ' Sudo/sbin/ipvsadm | grep http |wc-l '

If [$stat 1-ne 0];then

For NUM in ' Sudo/sbin/ipvsadm | grep http | awk ' {print $} '

Todo

act_count=$ (($ACT _count+ $NUM))

Done

For NUM in ' Sudo/sbin/ipvsadm | grep http | awk ' {print $} '

Todo

inactive_count=$ (($Inactive _count+ $NUM))

Done

Else

echo "LVs CRITICAL", "LVs is down"

Exit 2

Fi

if [$ACT _count = 0];then

echo "LVS OK," 0 active connection ""

Exit 1

Else

echo "LVS Ok–lvs is running (conn: $ACT _count active, $Inactive _count Inactive) |active= $ACT _count;80000;99999;0; Inactive= $Inactive _count;800
00;99999;0; "

Fi

Remember to add executive permission chmod +x/etc/nagios/libexec/check_lvs, otherwise may travel.

1.3 Join the Client monitoring configuration file
Vim/etc/nagios/nrpe.cfg
Command[check_conn]=/etc/nagios/libexec/check_lvs

2, service-side configuration
2.1 Before the configuration file is added, test the client for monitoring at the command line.
Su–nagios
/usr/local/nagios/libexec/check_nrpe-h 190.x.x.x-c Check_conn
LVS Ok–lvs is running (conn:9056 active, 22307 inactive) |active=9056;80000;99999;0; inactive=22307;80000;99999;0;

2.2 Confirm the above test can get the normal value, add the configuration file,
Vim/usr/local/nagios/etc/objects/services.cfg
Define Service{
Use Generic-service
HOST_NAME Tw_lvs
Service_description check_connection
Check_command Check_nrpe!check_conn
}

After saving, reload the Nagios,
/etc/init.d/nagios Reload

2.3 Nagios Web page can be found to get the value.
Check_connection OK 06-25-2014 15:35:57 0d 0h 37m 24s 1/3 LVS Ok–lvs is running (conn:9056 active, 22307 inactive)

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.