1.create
vip="55.269.163.168"
/usr/bin/rrdtool create /home/sysadmin/tanzhijun/test_"$vip"_.rrd -s 30 \
DS:ee:GAUGE:60:0:U \
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
RRA:AVERAGE:0.5:24:775 \
RRA:AVERAGE:0.5:288:797 \
RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 \
RRA:MAX:0.5:24:775 \
RRA:MAX:0.5:288:797
2.update&graph
#!/bin/bash
IP="117.15.171.143 211.142.189.231 55.269.163.153 55.269.163.138 55.269.163.168"
rrd_path="/home/sysadmin/tanzhijun"
image_path="/home/sysadmin/tanzhijun/images"
while :
do
for vip in $IP
do
now=`date +%s`
N=`netstat -ant|awk '/$vip/{print $5}'|wc -l`
/usr/bin/rrdtool update "$rrd_path"/test_"$vip"_.rrd $now:$N
done
/usr/bin/rrdtool graph "$image_path"/apache_visits.png \
-t "$vip apache visits" -s -86400 -e -0 -l 0 -M -h 180 -w 500 -v "test per sec"\
DEF:a1="$rrd_path"/test_117.15.171.143_.rrd:aa:AVERAGE \
DEF:a2="$rrd_path"/test_117.15.171.143_.rrd:aa:MAX \
DEF:b1="$rrd_path"/test_211.142.189.231_.rrd:bb:AVERAGE \
DEF:b2="$rrd_path"/test_211.142.189.231_.rrd:bb:MAX \
DEF:c1="$rrd_path"/test_55.269.163.153_.rrd:cc:AVERAGE \
DEF:c2="$rrd_path"/test_55.269.163.153_.rrd:cc:MAX \
DEF:d1="$rrd_path"/test_55.269.163.138_.rrd:dd:AVERAGE \
DEF:d2="$rrd_path"/test_55.269.163.138_.rrd:dd:MAX \
DEF:e1="$rrd_path"/test_55.269.163.168_.rrd:ee:AVERAGE \
DEF:e2="$rrd_path"/test_55.269.163.168_.rrd:ee:MAX \
LINE1:a1#00FF00FF:"117.15.171.143" \
GPRINT:a1:LAST:"current\:%8.0lf %s" \
GPRINT:a1:AVERAGE:"average\:%8.0lf %s" \
GPRINT:a2:MAX:"maximum\:%8.0lf \n" \
LINE1:b1#EACC00FF:"211.142.189.231" \
GPRINT:b1:LAST:"current\:%8.0lf %s" \
GPRINT:b1:AVERAGE:"average\:%8.0lf %s" \
GPRINT:b2:MAX:"maximum\:%8.0lf \n" \
LINE1:c1#FF0000FF:"55.269.163.153" \
GPRINT:c1:LAST:"current\:%8.0lf %s" \
GPRINT:c1:AVERAGE:"average\:%8.0lf %s" \
GPRINT:c2:MAX:"maximum\:%8.0lf \n" \
LINE1:d1#0000FFFF:"55.269.163.138" \
GPRINT:d1:LAST:"current\:%8.0lf %s" \
GPRINT:d1:AVERAGE:"average\:%8.0lf %s" \
GPRINT:d2:MAX:"maximum\:%8.0lf \n" \
LINE1:e1#F51D30FF:"55.269.163.168" \
GPRINT:e1:LAST:"current\:%8.0lf %s" \
GPRINT:e1:AVERAGE:"average\:%8.0lf %s" \
GPRINT:e2:MAX:"maximum\:%8.0lf \n"
sleep 30
done