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

           

          正常情況:

          設:正常每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

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

          (這時就算在34之間再有值被插入結果也是一樣,這是因為插入的值都將使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秒,另,45之間有多個值:24秒的225秒的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 我愛佳娃 閱讀(774) 評論(0)  編輯  收藏 所屬分類: 工具使用
          主站蜘蛛池模板: 灵宝市| 襄汾县| 怀集县| 仲巴县| 奈曼旗| 玛纳斯县| 六枝特区| 泸州市| 宜阳县| 藁城市| 吉安县| 会泽县| 卢湾区| 沙洋县| 黎平县| 武威市| 舟曲县| 石泉县| 宣威市| 宁阳县| 新泰市| 治县。| 凤台县| 定襄县| 香港 | 惠水县| 阿坝县| 塔城市| 疏勒县| 潞西市| 筠连县| 涟源市| 莱西市| 乌拉特中旗| 纳雍县| 广州市| 贵南县| 佳木斯市| 武隆县| 阳城县| 遂川县|