我是Perl的新手,对RRD来说是新手,我有一个运行一些webservice测试的Perl脚本,还可以从垃圾收集日志中检索行.该脚本也执行其他任务,但我只需要有一个与这两个相关的图表.
这段脚本读取结果报告.html,从表中提取一些时间值并将它们存储在变量中.
my $html = "./report/archive/results-$now/web_results.html"; my @headers = qw( Page Initial Resource STB UI ); my $te = HTML::TableExtract->new(headers => \@headers); $te->parse_file($html); my ($table) = $te->tables; for my $row ($te->rows) { my $pageDisplay = "@$row[0]"; $pageDisplay =~ s/\D//g; my $initialLoad = "@$row[1]"; $initialLoad =~ s/\D//g; my $resourceAudit = "@$row[2]"; $resourceAudit =~ s/\D//g; my $uiRefresh = "@$row[3]"; $uiRefresh =~ s/\D//g; my $stbRefresh = "@$row[4]"; $stbRefresh =~ s/\D//g; }
我想使用RRDTool::OO或RRD::Simple将这些变量存储在RRD中,并在脚本的每个循环之后更新它们.
我还想对另一个循环遍历一些垃圾收集日志行的脚本执行相同操作,并为每个日志行返回运行时.
open LOG,"<","./report/archive/logs-$now/garbage.collection.txt" or die "Unable to read file: $!"; while (my $line = <LOG>) { my ($time) = $line =~ m/\breal=([0-9.]+)/; } close LOG;
我相信RRDTool::OO有一个可以使用我的变量调用的更新函数,但我的主要问题是创建RRD,以便可以使用它们进行更新.我不确定我是否需要多个RRD,哪个步骤值最好,数据源等等.
如果我可以成功创建/更新RRD或RRD,我很确定我可以按照Cacti’s Externally Updated RRDs doc将它们加载到仙人掌上进行绘图.虽然有人可能有更好的方法.任何帮助表示赞赏!
编辑
我在剧本的第二部分尝试了以下内容……
#RRDTool::OO my $rrd = RRDTool::OO->new( file => "gcRuntimes.rrd" ); $rrd->create( step => 1,data_source => { name => "GC",type => "GAUGE" },archive => { rows => 50 }); ... open LOG,"./report/archive/logs-$now/garbage.collection.txt" or die "Unable to read file: $!"; while (my $line = <LOG>) { my ($time) = $line =~ m/\breal=([0-9.]+)/; $rrd->update($time); } close LOG;
..但失败并出现错误:
rrdtool创建gcRuntimes.rrd –step 1 DS:GC:GAUGE:2:U:U RRA:MAX:0.5:1:5失败:创建’gcRuntimes.rrd’:/ home / foo / perl5 / lib /中的参数无效perl5 / RRDTool / OO.pm第438行
使用我的脚本运行strace将在mmap2系统调用中显示此(无效参数).
mmap2(NULL,1344,PROT_READ|PROT_WRITE,MAP_SHARED,3,0) = -1 EINVAL (Invalid argument) close(3)
如果我使用RRD :: Simple或RRDTool :: OO对我来说无关紧要,但目前它们都返回相同的错误.