1、安装rrdtool
tar xvzf rrdtool-1.4..tar.gz
cd rrdtool-1.4.
./configure -prefix=/usr/local/rrdtool
make
make instal
安装完毕后将rrdtool库文件添加至系统库文件搜索路径
echo '/usr/local/rrdtool/lib’ >>/etc/ld.so.conf
ldconfig –v
/usr/local/rrdtool/bin/rrdtool –v #查看rrdtool版本信息
2、安装配置lvs-rrd
tar xvzf lvs-rrd-v0..tar.gz
mv lvs-rrd-v0. /var/www/html/lvs-rrd
mkdir /var/www/html/lvs-rrd/rrd
修改配置
vim lvs.rrd.update
RRDTOOL=”/usr/local/rrdtool/bin/rrdtool”#rrdtool可执行程序路径
IPVSADM=”/sbin/ipvsadm”#ipvsadm命令路径
WORKDIR=”/var/www/html/lvs-rrd/rrd”#rrdtool收集的数据的存放路径 vim graph-lvs.sh
# WORKDIR must match the directory used in the update script.
WORKDIR=”/var/www/html/lvs-rrd/rrd” #rrdtool收集的数据存放的路径
RRDTOOL=”/usr/local/rrdtool/bin/rrdtool”#rrdtool可执行程序路径
# Where to put the graphs.
GRAPHS=“/var/www/html/lvs-rrd/graphs”#生成的图片保存路径
WEBPATH=”/lvs-rrd/graphs”#图片路径 vim lvs-rrd.php
<?php
header(“Cache-Control: max-age=, must-revalidate”);
system(“/var/www/html/lvs-rrd/graph-lvs.sh -H”);#修改路径为部署服务的路径
?>
sudo chown -R apache.apache /var/www/html/lvs-rrd
3、配置周期性收集数据
/var/www/html/lvs-rrd/lvs.rrd.update &>/dev/null
4、apache配置:
Alias /lvs /var/www/html/lvs-rrd
<Directory "/var/www/html/lvs-rrd">
#Options None
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
AuthName "LVS Status"
AuthType Basic
AuthUserFile /etc/httpd/conf/.htpasswd
Require valid-user
</Directory>
生成密码文件
htpasswd -cm /etc/httpd/conf/.htpasswd admin
上一张生产环境的监控图: