隨筆-124  評論-194  文章-0  trackbacks-0

           

          正常情況:

          設(shè):正常每5秒更新一次,HB10,分別在第15秒時更新值1,第25秒時更新值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

          設(shè):第23次更新沒有到來,4來時,距上一次更新已經(jīng)過去15秒>HB,直接將第234次的PDP置為無效:

          (這時就算在34之間再有值被插入結(jié)果也是一樣,這是因為插入的值都將使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

          設(shè):4值晚一秒到來,即21秒,另,45之間有多個值:24秒的225秒的5(如小圖):

          它是按照權(quán)重計算的: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 我愛佳娃 閱讀(770) 評論(0)  編輯  收藏 所屬分類: 工具使用
          主站蜘蛛池模板: 东莞市| 朔州市| 新安县| 凯里市| 汤原县| 临潭县| 隆德县| 石家庄市| 中山市| 泸西县| 友谊县| 南丰县| 玛多县| 从江县| 闻喜县| 凤冈县| 称多县| 台湾省| 读书| 米林县| 铅山县| 昌邑市| 广元市| 宝兴县| 徐水县| 成都市| 双牌县| 荣成市| 新津县| 河西区| 灯塔市| 安康市| 珲春市| 嵊州市| 华阴市| 平乐县| 青神县| 汾西县| 芷江| 怀来县| 临邑县|