random tips on coding, ops, ...

RRDTOOL 里 xff 的意思

一直对 rrdtool 在 create 时 RRA 中的 xff 参数的意义不是很清楚,今天 仔细研究了一下,做个总结。下面是 man rrdcreate 里的说明:

*RRA:AVERAGE MIN MAX LAST:xff:steps:rows*

xff The xfiles factor defines what part of a consolidation interval may be made up from *UNKNOWN* data while the consolidated value is still regarded as known. It is given as the ratio of allowed *UNKNOWN* PDPs to the number of PDPs in the interval. Thus, it ranges from 0 to 1 (exclusive).

xff 决定在给定间隔中可以有多大比例的未知 PDP,超过这个比例则该间隔内的值 为 UNKNOWN,其取值范围为前闭后开区间,即: [0, 1) 。举两个极端的例子:

xff = 0 表示不能有未知 PDP

xff = 0.9 表示可以有 90% 的 PDP

下面是测试的程序(备忘)。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

LANG=C

xff=0.5

#t=$(date +%s)
t=1480272727

echo $(date), $t

rrdtool create test.rrd -b $(date +%s) --step 1 DS:temp:GAUGE:1:0:100 RRA:AVERAGE:${xff}:5:10
for i in `seq 1 20`; do
    rrdtool update test.rrd ${t}:${i}
    t=$((t + 1))
done

rrdtool dump test.rrd

comments powered by Disqus