Created
January 20, 2012 15:20
-
-
Save xufan6/1647856 to your computer and use it in GitHub Desktop.
通用性较差呢,用于rrd绘图
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
name="gateway" | |
declare -a temp_arr | |
def="DEF:rrd_rtt=$name.rrd:rtt:AVERAGE \ | |
DEF:rrd_pl=$name.rrd:pl:AVERAGE \ | |
VDEF:rtt_max=rrd_rtt,MAXIMUM \ | |
VDEF:pl_max=rrd_pl,MAXIMUM \ | |
-e now -s end-2h \ | |
" | |
NUM="`rrdtool graph xxx \ | |
$def \ | |
PRINT:pl_max:""%3.6lf"" \ | |
PRINT:rtt_max:""%5.6lf"" | |
`" | |
temp_arr=($NUM) | |
bili=`echo "${temp_arr[1]} / ${temp_arr[2]}"|bc -l` | |
[ ${bili:=0} = 0 ] && bili=1 | |
rrdtool graph - \ | |
$def \ | |
--right-axis $bili:0 \ | |
--right-axis-format "%3.3lf%%" \ | |
CDEF:view_pl=rrd_pl,$bili,/ \ | |
AREA:view_pl#baf:"Packet loss (%)" \ | |
COMMENT:"cur/avg/min/max=(\g" \ | |
GPRINT:rrd_pl:LAST:"%3.3lf/\g" \ | |
GPRINT:rrd_pl:AVERAGE:"%3.3lf/\g" \ | |
GPRINT:rrd_pl:MIN:"%3.3lf/\g" \ | |
GPRINT:rrd_pl:MAX:"%3.3lf\g" \ | |
COMMENT:")%\n" \ | |
LINE:rrd_rtt#000:"Rtt (ms)" \ | |
COMMENT:"cur/avg/min/max=(\g" \ | |
GPRINT:rrd_rtt:LAST:"%3.3lf/\g" \ | |
GPRINT:rrd_rtt:AVERAGE:"%3.3lf/\g" \ | |
GPRINT:rrd_rtt:MIN:"%3.3lf/\g" \ | |
GPRINT:rrd_rtt:MAX:"%3.3lf\g" \ | |
COMMENT:")ms\n" \ | |
COMMENT:"test pl_max rtt_max bili" \ | |
COMMENT:"${temp_arr[1]}" \ | |
COMMENT:"${temp_arr[2]}" \ | |
COMMENT:"$bili" \ | |
COMMENT:"\n" \ | |
-t $name \ | |
-v "Round-trip delay time (ms)" \ | |
--right-axis-label "Packet loss (%)" \ | |
-W "`date`" \ | |
-w 576 -h 200 \ | |
-l 0 -r -X b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment