#!/usr/bin/perl -w ########################################### # mm2rrd # Mike Schilli, 2007 (m@perlmeister.com) ########################################### use strict; use RRDTool::OO; use Sysadm::Install qw(:all); my @points; plough sub { chomp; my($time, $value) = split / /, $_; push @points, [$time, $value]; }, "values.txt"; # Constructor my $rrd = RRDTool::OO->new( file => "mmdata.rrd" ); # Create a round-robin database $rrd->create( step => 30, start => $points[0]->[0] - 1, data_source => { name => "amps", type => "GAUGE" }, archive => { rows => 10_000 }); for(@points) { $rrd->update(time => $_->[0], value => $_->[1]); } $rrd->graph( width => 600, height => 400, image => "mmdata.png", vertical_label => "Amperes", start => $points[0]->[0], end => $points[-1]->[0], draw => { type => "line", color => "0000FF", legend => "Laptop Power", } );