NAME
RRD::Simple - Simple interface to create and store data in RRD files
SYNOPSIS
use strict;
use RRD::Simple ();
# Create an interface object
my $rrd = RRD::Simple->new();
# Create a new RRD file with 3 data sources called
# bytesIn, bytesOut and faultsPerSec. Data retention
# of a year is specified. (The data retention parameter
# is optional and not required).
$rrd->create("myfile.rrd", "year",
bytesIn => "GAUGE",
bytesOut => "GAUGE",
faultsPerSec => "COUNTER"
);
# Put some arbitary data values in the RRD file for same
# 3 data sources called bytesIn, bytesOut and faultsPerSec.
$rrd->update("myfile.rrd",
bytesIn => 10039,
bytesOut => 389,
faultsPerSec => 0.4
);
my @rtn = $rrd->graph("myfile.rrd",
destination => "/var/tmp",
title => "Network Interface eth0",
"vertical-label" => "Bytes/Faults"
);
# Get unixtime of when RRD file was last updated
my $lastUpdated = $rrd->last("myfile.rrd");
print "myfile.rrd was last updated at " .
scalar(localtime($lastUpdated)) . "\n";
# Get list of data source names from an RRD file
my @dsnames = $rrd->sources("myfile.rrd");
print "Available data sources: " . join(", ", @dsnames) . "\n";
# And for the ultimately lazy, you could create and update
# an RRD in one go using a one-liner like this:
perl -MRRD::Simple -e'RRD::Simple->update(@ARGV)' myfile.rrd bytesIn 99999
DESCRIPTION
RRD::Simple provides a simple interface to RRDTool's RRDs module. This module does not currently offer fetch
or info
methods that are available in the RRDs module.
It does howeve create RRD files with a sensible set of default RRA (Round Robin Archive) definitions, and can dynamically add new data source names to an existing RRD file.
This module is ideal for quick and simple storage of data within an RRD file if you do not need to, nor want to bother defining custom RRA definitions.
METHODS
new
create
$rrd->create($rrdfile, $period,
source_name => 'TYPE',
source_name => 'TYPE',
source_name => 'TYPE'
);
$rrdfile
is optional and will default to $0.rrd
. (Script basename with the file extension of .rrd).
$period
is optional and will default to year
. Valid options are day
, week
, month
, year
and 3years
. Specifying a retention period value will change how long data will be retained for within the RRD file.
update
$rrd->update($rrdfile, $unixtime,
source_name => 'VALUE',
source_name => 'VALUE',
source_name => 'VALUE'
);
last
my $unixtime = $rrd->last($rrdfile);
sources
my @sources = $rrd->sources($rrdfile);
add_source
$rrd->add_source($rrdfile,
source_name => 'TYPE'
);
graph
$rrd->graph($rrdfile,
destination => '/path/to/write/graph/images',
rrd_graph_option => 'value',
rrd_graph_option => 'value',
rrd_graph_option => 'value'
);
TODO
Finish POD.
Write the retention duration scheme handling code. (Currently defaults to one year retention only).
Write info() and fetch() methods.
SEE ALSO
RRDTool::Managed, RRDTool::OO, RRD::Query, RRDs, http://www.rrdtool.org
VERSION
$Id: Simple.pm,v 1.11 2005/12/09 23:52:43 nicolaw Exp $
AUTHOR
Nicola Worthington <nicolaw@cpan.org>
http://perlgirl.org.uk
COPYRIGHT
(c) Nicola Worthington 2005. This program is free software; you can redistribute it and/or modify it under the GNU GPL.
See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt