【发布时间】:2016-05-06 09:32:00
【问题描述】:
是的,我知道,
"DEF:in=$rrd_file:traffic_in:AVERAGE:step=1",
"DEF:out=$rrd_file:traffic_out:AVERAGE:step=1",
'CDEF:bitin=in,8,*',
'CDEF:bitout=out,8,*',
'CDEF:total=bitin,bitout,+',
'VDEF:pct_total=total,95,PERCENT',
'VDEF:pct_in=bitin,95,PERCENT',
'VDEF:pct_out=bitout,95,PERCENT',
进、出和 95(进+出)。
但是 95th(In+Out) 虽然它是正确的,但它不是我所需要的total 95th。
我需要将传统的 In 值和 Out 值一起“展平”并以此计算出第 95 个值。 因此,如果 1 个链接主要是在大 In 峰值的 Inbound 上运行,那么这个更好的第 95 个百分位将是一个更接近于平均 Inbound 流量的数字,因为大多数/所有顶部峰值将是 Inbound 流量在总使用量中的影响不大。 同样,链接 2 主要是出站,这第 95 个百分位将是一个更接近出站平均流量的数字。
有没有办法单独使用 RRDtools 来做到这一点,类似于上面的命令参数?
在 perl 中我做了类似的事情(脏),但我没有对齐时间窗口(@987654322@ 不被rrdtool fetch 识别为参数)和更长的时间段(比如一个月)我得到的样本很少,所以对我隐藏了一些和解;
my ($start, $end, $rrd_file) = @_;
my @series = `rrdtool fetch -s $start -e $end $rrd_file MAX`;
my @all;
foreach my $line (@series) {
if ($line !~ m/nan/ig && $line =~ m/(\d+): (\S+) (\S+)/) {
my ($time, $in, $out) = ($1, $2, $3);
push(@all, $in * 8, $out * 8);
}
}
@all = sort {$b <=> $a} @all;
my $index_all = int(scalar(@all) * 0.05) + 1;
return sprintf("%.2f", $all[$index_all] / 1000 / 1000);
在哪里
my $end = DateTime->now(time_zone => 'local')->truncate(to => 'minute');
my $start = $end->clone->subtract(hours => 168)->epoch();
$end = $end->epoch();
【问题讨论】:
标签: perl rrdtool percentile rrd