如何使用一个perl脚本来创建/填充和绘制RRDTool图

时间:2010-12-06 16:45:43

标签: perl rrdtool

以下是一个示例:此脚本将生成数据。


#!/opt/local/bin/perl
use Data::Dumper;
use strict;

my $i=0;
my $startTime=time;
$startTime += $ARGV[0] + 5;
my $dTime = localtime( $startTime );
print "\n##################\nLAUNCHING REQUESTS\n COUNT: $ARGV[0]\n DELAY: | 1 \nThe scripts will fire at : $dTime\n##################\n\n";
while ( $ARGV[0] > $i )
{
    $i++;
    system("php avtestTimed.php $ARGV[0] $ARGV[2] $startTime");
    print "RUN system('php avtestTimed.php $ARGV[0] $ARGV[2] $startTime'); \n";
    sleep 1;
}

stdout上的结果是:

##################
LAUNCHING REQUESTS
 COUNT: 5
 DELAY: | 1 
The scripts will fire at : Mon Dec  6 09:38:15 2010
##################


EXECUTING AT 0.00015100 1291646295 --  WITH SID 28a952711439a8f98e5acf807da3455c -- AGAINST test.yakabod.net
RESPONSE RECEIVED FROM (https://test.yakabod.net/activityViewer/index.html) IN 1.5974318981171
RUN system('php avtestTimed.php 5 test.yakabod.net 1291646295'); 

EXECUTING AT 0.35701200 1291646299 --  WITH SID 492cdb3e3893d1fa6ea1a6e8b4961087 -- AGAINST test.yakabod.net
RESPONSE RECEIVED FROM (https://test.yakabod.net/activityViewer/index.html) IN 1.5956890583038
RUN system('php avtestTimed.php 5 test.yakabod.net 1291646295'); 

EXECUTING AT 0.16751000 1291646304 --  WITH SID b97a379d2a73a9bb8df2ab0ee9665417 -- AGAINST test.yakabod.net
RESPONSE RECEIVED FROM (https://test.yakabod.net/activityViewer/index.html) IN 1.5704379081726
RUN system('php avtestTimed.php 5 test.yakabod.net 1291646295'); 

EXECUTING AT 0.51596300 1291646308 --  WITH SID 997b017d830cdd357036a24dd77313e9 -- AGAINST test.yakabod.net
RESPONSE RECEIVED FROM (https://test.yakabod.net/activityViewer/index.html) IN 1.5980801582336
RUN system('php avtestTimed.php 5 test.yakabod.net 1291646295'); 

EXECUTING AT 0.89809900 1291646312 --  WITH SID c512edc3491fb6ebc11ce72d547af201 -- AGAINST test.yakabod.net
RESPONSE RECEIVED FROM (https://test.yakabod.net/activityViewer/index.html) IN 1.5987639427185
RUN system('php avtestTimed.php 5 test.yakabod.net 1291646295'); 

现在我需要做的是采取两个变量: 1.执行0.51596300 1291646308 2.收到回复(https://test.yakabod.net/activityViewer/index.html)1.5987639427185

并将它们存储在teo变量中: $ exec_at $ receive_at 并使用这些值更新RRDTool。 关于我如何做到这一点的任何提示?,我想要绘制的是: 1. EXECUTING AT变量的线图 2. RESPONSE的散点图

谢谢, -Kamal。

1 个答案:

答案 0 :(得分:1)

您可以使用CPAN的RRD::Simple来快速绘制:只需创建rrd,并在每次迭代时使用您的数据点调用更新。您应该能够在脚本链接上调整示例。