by:ysuncn(欢迎转载,请注明原创信息)
看了一些讲RRDtool绘图命令graph用法的文章,有些版本过时,命令不同了,还有些就像我前边写的“Hello World”里边的作图一样,泛泛带过,针对性不强。这里献给大家两个自认为经典的例子,希望对大家有帮助:)ps:如果自己操练,改与数据库相关的就ok了。
--end now --start end-120000s --width 400 /
-t "VDEF、CDEF应用举例" /
--font TITLE:14:FZZHYJW.ttf /
--x-grid MINUTE:30:HOUR:4:HOUR:4:0:%H:%M /
# 每30分钟一条线,每4小时一条主线,4小时一个标签标于主线下方,标签格式“小时:分钟”
-Y /
DEF:ds0=/home/ rrdtool/data/router2.rrd : Inbound :AVERAGE /
DEF:ds1= /home/ rrdtool/data/router2.rrd : Outbound :AVERAGE /
VDEF:ds0max=ds0,MAXIMUM /
VDEF:ds0avg=ds0,AVERAGE /
VDEF:ds0min=ds0,MINIMUM /
VDEF:ds0pct=ds0,95,PERCENT /
VDEF:ds1max=ds1,MAXIMUM /
VDEF:ds1avg=ds1,AVERAGE /
VDEF:ds1min=ds1,MINIMUM /
VDEF:ds1pct=ds1,95,PERCENT /
CDEF:ds0bits=ds0,8,* /
CDEF:ds1bits=ds1,8,* /
COMMENT:" " /
COMMENT:"Maximum " /
COMMENT:"Average " /
COMMENT:"Minimum " /
COMMENT:"95th percentile/l" /
AREA:ds0bits#00FF00:"Inbound " /
GPRINT:ds0max:"%6.2lf %Sbps" /
GPRINT:ds0avg:"%6.2lf %Sbps" /
GPRINT:ds0min:"%6.2lf %Sbps" /
GPRINT:ds0pct:"%6.2lf %Sbps/l" /
LINE1:ds1bits#FF0000:"Outbound" /
GPRINT:ds1max:"%6.2lf %Sbps" /
GPRINT:ds1avg:"%6.2lf %Sbps" /
GPRINT:ds1min:"%6.2lf %Sbps" /
GPRINT:ds1pct:"%6.2lf %Sbps/l" /
COMMENT:"/s" /
VRULE:1186562026#000000:x-mark /
HRULE:1700000000#0000FF:y-mark /
COMMENT:" update time/: `date /"+%Y/%m/%d %H/:%M/:%S/"`" COMMENT:"/l"
出图:
Copyright ©2007 ysuncn
看了一些讲RRDtool绘图命令graph用法的文章,有些版本过时,命令不同了,还有些就像我前边写的“Hello World”里边的作图一样,泛泛带过,针对性不强。这里献给大家两个自认为经典的例子,希望对大家有帮助:)ps:如果自己操练,改与数据库相关的就ok了。
实例1:DEF提取数据+理解时间粒度(间隔)对作图的影响。rrdtool graph graph.png /
rrdtool graph def.png /
--end now --start end-120000s --width 400 /
-t "DEF应用举例+不同时间粒度作图对比" /
--font TITLE:14:FZZHYJW.ttf /
DEF:dsa=/home/rrdtool/data/router1.rrd:dsa:AVERAGE /
DEF:dsb=/home/rrdtool/data/router1.rrd:dsb:AVERAGE:step=1800 /
DEF:dsc=/home/rrdtool/data/router1.rrd:dsc:AVERAGE:step=7200 /
LINE1:ds0a#0000FF:"default resolution 300 seconds/l" /
LINE1:ds0b#00CCFF:"resolution 1800 seconds per interval/l" /
LINE1:ds0c#FF00FF:"resolution 7200 seconds per interval/l"
出图:
实例2:VDEF、CDEF用法+坐标轴标签+横纵线条+报告生成+更新时间
--end now --start end-120000s --width 400 /
-t "VDEF、CDEF应用举例" /
--font TITLE:14:FZZHYJW.ttf /
--x-grid MINUTE:30:HOUR:4:HOUR:4:0:%H:%M /
# 每30分钟一条线,每4小时一条主线,4小时一个标签标于主线下方,标签格式“小时:分钟”
-Y /
DEF:ds0=/home/ rrdtool/data/router2.rrd : Inbound :AVERAGE /
DEF:ds1= /home/ rrdtool/data/router2.rrd : Outbound :AVERAGE /
VDEF:ds0max=ds0,MAXIMUM /
VDEF:ds0avg=ds0,AVERAGE /
VDEF:ds0min=ds0,MINIMUM /
VDEF:ds0pct=ds0,95,PERCENT /
VDEF:ds1max=ds1,MAXIMUM /
VDEF:ds1avg=ds1,AVERAGE /
VDEF:ds1min=ds1,MINIMUM /
VDEF:ds1pct=ds1,95,PERCENT /
CDEF:ds0bits=ds0,8,* /
CDEF:ds1bits=ds1,8,* /
COMMENT:" " /
COMMENT:"Maximum " /
COMMENT:"Average " /
COMMENT:"Minimum " /
COMMENT:"95th percentile/l" /
AREA:ds0bits#00FF00:"Inbound " /
GPRINT:ds0max:"%6.2lf %Sbps" /
GPRINT:ds0avg:"%6.2lf %Sbps" /
GPRINT:ds0min:"%6.2lf %Sbps" /
GPRINT:ds0pct:"%6.2lf %Sbps/l" /
LINE1:ds1bits#FF0000:"Outbound" /
GPRINT:ds1max:"%6.2lf %Sbps" /
GPRINT:ds1avg:"%6.2lf %Sbps" /
GPRINT:ds1min:"%6.2lf %Sbps" /
GPRINT:ds1pct:"%6.2lf %Sbps/l" /
COMMENT:"/s" /
VRULE:1186562026#000000:x-mark /
HRULE:1700000000#0000FF:y-mark /
COMMENT:" update time/: `date /"+%Y/%m/%d %H/:%M/:%S/"`" COMMENT:"/l"
出图:
Copyright ©2007 ysuncn