正常情况:
设:正常每5秒更新一次,HB=10,分别在第1个5秒时更新值1,第2个5秒时更新值2……
这样每次PDP都有值:
887457305: 1.0000000000e+00
887457310: 2.0000000000e+00
887457315: 3.0000000000e+00
887457320: 4.0000000000e+00
887457325: 5.0000000000e+00
887457330: 6.0000000000e+00
887457335: 7.0000000000e+00
887457340: 8.0000000000e+00
设:第2、3次更新没有到来,4来时,距上一次更新已经过去15秒>HB,直接将第2、3、4次的PDP置为无效:
(这时就算在3和4之间再有值被插入结果也是一样,这是因为插入的值都将使HB超时,3值都将无效,同时此值也会被抛弃,不会影响4值的计算)
887457305: 1.0000000000e+00
887457310: nan
887457315: nan
887457320: nan
887457325: 5.0000000000e+00
887457330: 6.0000000000e+00
887457335: 7.0000000000e+00
887457340: 8.0000000000e+00
设:4值晚一秒到来,即21秒,另,4和5之间有多个值:24秒的2,25秒的5(如小图):
它是按照权重计算的:4*1/5 + 2*3/5 + 5*1/5 = 3
887457305: 1.0000000000e+00
887457310: nan
887457315: nan
887457320: nan
887457325: 3.0000000000e+00
887457330: 6.0000000000e+00
887457335: 7.0000000000e+00
887457340: 8.0000000000e+00
程序如下:
#!/bin/bash
rm -f ./1.rrd
ep="Jan 1, 1970 UTC"
start=`date -d "$ep+887457300 seconds" +%s`
echo $start
# create
rrdtool create ./1.rrd "
--start `expr $start` --step 5 "
DS:t1:GAUGE:10:U:U "
RRA:AVERAGE:0.5:1:43200
# add data
rrdtool update ./1.rrd `expr $start + 5`:1
#rrdtool update ./1.rrd `expr $start + 10`:2
rrdtool update ./1.rrd `expr $start + 18`:3
rrdtool update ./1.rrd `expr $start + 21`:4
rrdtool update ./1.rrd `expr $start + 2`:2
rrdtool update ./1.rrd `expr $start + 25`:5
rrdtool update ./1.rrd `expr $start + 30`:6
rrdtool update ./1.rrd `expr $start + 35`:7
rrdtool update ./1.rrd `expr $start + 40`:8
echo "***begin fetch***"
s2=0
rrdtool fetch ./1.rrd AVERAGE "
-r 5 --start `expr $start + $s2` --end `expr $start + $s2 + 60`
posted on 2008-09-17 21:15
我爱佳娃 阅读(751)
评论(0) 编辑 收藏 所属分类:
工具使用