RRDTools RRDs::xport 模块的工作示例

问题描述

我正在尝试利用 Perl 中 RRDs 模块的 xport 函数从 rrd 文件提取数据。但是,我没有任何运气找到正确的语法来使用相同的语法。官网仅提供以下说明。 如果有人用过这个模块来做同样的事情,请帮忙。

RRDs::xport exposes the rrdxport functionality and returns data with the following structure:

  my ($start,$end,$step,$cols,$names,$data) = RRDs::xport ...
  
  # $start : timestamp
  # $end   : timestamp
  # $step  : seconds
  # $cols  : number of returned columns
  # $names : arrayref with the names of the columns
  # $data  : arrayref of arrayrefs with the data (first index is time,second is column)

解决方法

RRDs 模块中的各种 Perl 函数采用与命令行函数完全相同的参数数组。

例如,

@args = qw/--start now-1h --end now DEF:x=file.rrd:ds0:AVERAGE XPORT:x:out_bytes/;
($start,$end,$step,$cols,$names,$data) = RRDs::xport(@args);

请记住,您不需要引用包含空格的参数 - 毕竟,它们已经在数组中标记了。