1 Install the Nrpe client on the LVS server:
1.1,rpm Way to install Nrpe client
: http://download.csdn.net/detail/mchdba/7493875
[[email protected] nagios]# ll total 768-rw-r--r--1 root root 713389 12-16 12:08 nagios-plugins-1.4.11-1.x86_64.rpm-rw-r--r- -1 root root 32706 12-16 12:09 nrpe-2.12-1.x86_64.rpm-rw-r--r--1 root root 18997 12-16 12:08 nrpe-plugin-2.12-1 . X86_64.rpm[[email protected] nagios]# rpm-ivh *.rpm--nodeps --force
1.2 At the end of the configuration file, add configuration information and monitor the host server IP address
[email protected] localhost nagios]# vim/etc/nagios/nrpe.cfg# add by Tim on 2014-06-11command[check_users]=/usr/local/ Nagios/libexec/check_users-w 8-c 15command[check_load]=/usr/local/nagios/libexec/check_load-w 15,10,5-c 30,25,20command[check_sda1]=/usr/local/nagios/libexec/check_disk-w 20%-C 10%-p/dev/sdacommand[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 50-c 80command[check_total_procs]=/usr/local/nagios/libexec/check_procs-w 750-c 800command[ Check-host-alive]=/usr/local/nagios/libexec/check_ping-h localhost-w 3000.0,80%-C 5000.0,100%-P 5allowed_hosts = 127.0.0.1, 10.2xx.3.xx
Check if the command is in effect:
[Email protected] nrpe-2.15]#/usr/local/nagios/libexec/check_users-w 8-c 15USERS OK-2 users currently logged in |use Rs=2;8;15;0[[email protected] nrpe-2.15]#
See that the Users OK-.... command has been in effect.
1.3 Start Nrpe error as follows:
[[Email protected] ~]# service Nrpe restartshutting down Nrpe: [Failed]starting Nrpe:/usr/sbin/nrpe:error while loading Shared Libraries:libssl.so.6:cannot open Shared object file:no such file or directory [failure][[email protected] ~]#[[e Mail protected] nagios_client]# service Nrpe startstarting Nrpe:/usr/sbin/nrpe:error while loading shared libraries:lib Ssl.so.6:cannot open Shared object file:no such file or directory [failed][[email protected] nagios_client]#
Establish a connection
[Email protected] nagios_client]# ln-s/usr/lib64/libssl.so/usr/lib64/libssl.so.6 ( If there is no libssl.so, use other libssl.so.10 to do soft connection, ln-s/usr/lib64/libssl.so.10/usr/lib64/libssl.so.6) [[email protected] Nagios _client]#
Restart the following:
[Email protected] nagios_client]# service Nrpe startstarting Nrpe:/usr/sbin/nrpe:error while loading shared libraries: Libcrypto.so.6:cannot open Shared object file:no such file or directory [failure][[email protected] ~]# ll/usr/lib64/lib Crypto.solrwxrwxrwx. 1 root root 18 October 2013/usr/lib64/libcrypto.so-Libcrypto.so.1.0.0[[email protected] Nagios_ client]#
Re-build Links:
[Email protected] nagios_client]# ln-s/usr/lib64/libcrypto.so/usr/lib64/libcrypto.so.6 ( Or if there is no libcrypto.so, use libcrypto.so.10 to do soft connection, ln-s/usr/lib64/libcrypto.so.10/usr/lib64/libcrypto.so.6) [[Email Protected] nagios_client]# service Nrpe startstarting Nrpe: [OK][[email protected] nagios_client]#
1.4 Check if the Nrpe is running properly:
Go to Nagios server-side check
[Email protected] ~]# /usr/local/nagios/libexec/check_nrpe-h xx.xx3.xxNRPE v2.12[[email protected] ~]#
[Email protected] ~]#/usr/local/nagios/libexec/check_nrpe-h xx.xx3.xx
NRPE v2.12
[Email protected] ~]#
See return Nrpe v2.15 indicates that the connection has been successful.
2 Writing shell scripts for LVS monitoring
2.1 Monitoring Scripts
Nagios does not have a ready-to-use monitoring LVs status script, so you need to go online to find a simple monitoring script check_lvs.sh,copy to the/usr/lib/nagios/plugins/directory, give Nagios permissions, the script content is as follows:
#!/bin/bash # http://www.ohlinux.com/archives/632/# Add by Tim on 20140613usage_method=\ "$ (basename $) [-h|--hostname] <free IP or hostname> [-w|--warning] <free integer> [-c|--critical] <free integer>\ "USAGE_Value=\" Warning value must be small than critical value: ' BaseName $ ' $*\ ' State_ok=0state_warning=1state_critical=2state_ unknown=3if [$#-lt 4];then echo echo \ "Usage: $USAGE _method\" Echo Exit 0fiwhile [$#-gt 0];d o case \ " $1\ "in-w|--warning") shift warning=$1; -c|--critical) shift critical=$1;; Esac Shiftdoneif [[$warning = = $critical | | $warning-gt $critical]]then #echo $warning #echo $critical Echo \ "$USAGE _value\" echo \ "USAGE: $USAGE _method\" Exit 0fiact_count=0inactive_count=0stat1= ' sudo ipvsadm | grep http | grep route|wc-l ' If [$stat 1-ne 0];then for NUM in ' sudo ipvsadm | grep http | grep Route | awk \ ' {print $5}\ ' do act_count=$ (($ACT _count+ $NUM)) did for NUM in ' sudo ipvsadm | grep http | grep Route | awk \ ' {print $6}\ ' do inactive_count=$ (($Inactive _count+ $NUM) doneelse echo \ "STAT1: $stat 1, LVS Critic Al,lvs is down now.\ "Exit 3fiif [[\] $ACT _count\"-gt \ "$critical \"]]then echo \ "Critical-lvs connetion is: $AC T_count active\ "Exit 2fiif [[\" $ACT _count\ "-gt \" $warning \ "&& \" $ACT _count\ "-lt \" $critical \ "]]then EC HO \ "Warning-lvs connetions is: $ACT _count active\" Exit 1fiif [[\ "$ACT _count\"-lt \ "$warning \" | | $ACT _count = 0 ]]then echo \ "LVS Ok-lvs is running (conn: $ACT _count active, $Inactive _count Inactive) |active= $ACT _count;69999;9999 9;0; inactive= $Inactive _count;69999;99999;0;\ "Exit 0fi
2.2 nrpe.cfg The inside is configured as follows
Vim/etc/nagios/nrpe.cfg, add a line Check_lvs command inside:
Restart Nrpe after
[Email Protected]/root/nagios/check_lvs ~]# service Nrpe restart; Shutting down Nrpe: [OK]starting Nrpe: [OK][[email Protected]/root/nagios/check_lvs ~] #service Nrpe restart;
2.3 go to Nagios Service Side Check A bit
[Email protected] ~]# /usr/local/nagios/libexec/check_nrpe-h 1x.xx4.x.x5-c Check_lvs LVs Critical,lvs are down now. [Email protected] ~]#
See Check out the LVS service is already in the down mode.
Note: Since the CHECK_LVS is to invoke the IPVSADM command to obtain the LVS state, and the Ipvsadm command is only run as root, the Nagios user needs to be set up so that it can not be directly su to root without a password. This makes it possible to run command Sudo/usr/lib/nagios/plugins/check_lvs with Nagios users. In the CentOS system, you cannot call the sudo command directly, you need to modify the/etc/sudoers, find the #Defaults Requiretty and uncomment, add another line. Indicates that Nagios users do not need to log on to the terminal to invoke the command, as follows:
Defaults requirettydefaults:nagios !requiretty# add Nagios to request sudo, allowing for specific instructions (which can be followed by parameters) without requiring a password (such as). Nagios all= (All) Nopasswd:all
Then go to the Naigos server above check, which has been in effect as follows:
[Email protected] etc]#/usr/local/nagios/libexec/check_nrpe-h 10.xx.xx.xx-c Check_lvslvs Ok-lvs is running (conn:16 Active, inactive) |active=16;69999;99999;0; inactive=77;69999;99999;0; [Email protected] etc]#
2.4 in the Nagios add configuration on the server
Vim services.cfgdefine service{ host_name lvs-lan service_description Check LVs Check_command Check_nrpe!check_lvs max_check_attempts 5 normal_check_interval 3 retry_check_ Interval 2 check_period 24x7 notification_interval notification_period 24x7 notification_options w,c,r contact_groups opsweb }vim objects/commands.cfgdefine command{ command_name check_lvs command_line $USER 1$/check_lvs-h $HOSTADDRESS $-W $ARG 1$-C $ arg2$ }
After reloading Nagios, the monitoring service for LVS was completed.
[Email protected] etc]# service nagios reloadrunning Configuration check ... Reloading Nagios Configuration...done[[email protected] etc]#
At this point, Nagios's monitoring of the LVS service has been completed.
Reference: http://c20031776.blog.163.com/blog/static/684716252013627506890/