0

I'm trying to do my first rrd graph through Perl. I have tried RRD::Simple and rrds and just can't get either one to work.

Here's what I have so far:

use strict;
use RRD::Simple ();

# Create an interface object
my $rrd = RRD::Simple->new( file => "server.rrd" );

# Put some arbitary data values in the RRD file for the same
# 3 data sources called bytesIn, bytesOut and faultsPerSec.
 $rrd->create(
            EqSearch => "DERIVE",
            MfSearch => "DERIVE",
            EQCostBasis => "DERIVE",
            MFCostBasis => "DERIVE"
        );

$rrd->update(
            EqSearch => 2,
            MfSearch => 3,
            EQCostBasis => 10,
            MFCostBasis => 15
        );

# Generate graphs:
# /var/tmp/myfile-daily.png, /var/tmp/myfile-weekly.png
# /var/tmp/myfile-monthly.png, /var/tmp/myfile-annual.png
my %rtn = $rrd->graph(
            destination => "/Users/cmuench/Documents/Code/perl",
            title => "Server A",
            vertical_label => "",
            interlaced => "",
            periods => [qw(hour)]
        );

The output is:

graph http://www.mediafire.com/imgbnc.php/a39e2bd662adefa823dca66351db637c5g.jpg

4

1 回答 1

0

从上面的脚本中,主要问题是您没有足够的数据在图表中显示。您可以使用“ rrdtool fetch ”查看 rrd 中的数据。

如果你可以使用 bash 而不是 perl。看看这个“使用 rrdtool 的往返和丢包统计

如果您仍想使用 perl 模块RRD::Simple,请查看该模块提供的示例,即RRD::Simple::Examples或提供有关您面临的问题的更多详细信息。

于 2010-04-22T04:47:16.840 回答