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

发布于 2024-10-05 23:16:57 字数 2326 浏览 2 评论 0原文

这是一个示例:该脚本将生成数据。


#!/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;
}

标准输出上的结果是:

##################
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. 从 1.5987639427185 中 (https://test.yakabod.net/activityViewer/index.html) 收到的响应

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

谢谢, -卡迈勒。

Here is an example: this script would generate data.


#!/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;
}

The Result on stdout is:

##################
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'); 

Now what i need to do is to take the two variables:
1. EXECUTING AT 0.51596300 1291646308
2. RESPONSE RECEIVED FROM (https://test.yakabod.net/activityViewer/index.html) IN 1.5987639427185

and store them in teo variables:
$exec_at
$receive_at
and update RRDTool with these values.
Any hints on how i can do this ?, what i am trying to plot is :
1. line graphs for EXECUTING AT variable
2. Scatter graph for RESPONSE

Thanks,
-Kamal.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纵性 2024-10-12 23:16:57

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

You can use CPAN's RRD::Simple to plot this very quickly: simply create the rrd, and on each iteration call update with your data points. You should be able to adapt the example on the link to your script.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文