sub nfgraph { my $hashref=shift; #my $hashrefout=shift; my $title=shift; my $start = timegm(0, 0, 0, 1, $args{month} - 1, $args{year} - 1900); my $end; if( 12 == $args{month} ) { $end = timegm(0, 0, 0, 1, 0, $args{year} - 1900 + 1) - 1; } else { $end = timegm(0, 0, 0, 1, $args{month}, $args{year} - 1900) - 1; } # create an RRD database my(undef, $tempfname) = tempfile( DIR => $tempdir, SUFFIX => '.rrd', UNLINK => 1, ); my $rrd = RRDTool::OO->new( file => $tempfname ) or LOGDIE("can't create RRDTool::OO object"); $rrd->create( start => $start, data_source => { name => $title, type => 'GAUGE', }, data_source => { name => 'out', type => 'GAUGE', }, archive => { rows => 500, cpoints => 12, cfunc => 'MAX', }, archive => { rows => 500, cpoints => 12, cfunc => 'MAX', }, ) or LOGDIE("can't create RRD archive"); #DEBUG("created RRD database $tempfname"); my $totalaccum=0; open (NFIN,">accum$title.csv"); for my $time( sort keys %$hashref ) { $totalaccum+=$hashref->{$time}; print NFIN "$time,$totalaccum\n"; $rrd->update( time => $time, value=$totalaccum ); } close(NFIN); my $totalaccumout=0; open (NFOUT,">accumout.csv"); for my $otime(sort keys %$hashrefout) { $totalaccumout+=$hashrefout->{$otime}; print NFOUT "$otime,$totalaccumout\n"; $rrd->update( time => $otime, values => {out => $totalaccumout} ); } close(NFOUT);