use strict; use warnings; use DateTime::Event::Recurrence; use DateTime::SpanSet; use RRDs; # # Set up paths, config data etc... # foreach $file ( @array_of_RRD_filenames ) { my ( $metric, $interval, $begin, $end ) = ( 'AVERAGE', '1800', '-800h', 'now' ); my $start_span = DateTime::Event::Recurrence->weekly( days => [ 1 .. 5 ], hours => 8 ); my $end_span = DateTime::Event::Recurrence->weekly( days => [ 1 .. 5 ], hours => 18 ); my $span_set = DateTime::SpanSet->from_sets( start_set => $start_span, end_set => $end_span ); push @opts, $file; push @opts, $metric; push @opts, "-r $interval"; push @opts, "-s $begin"; push @opts, "-e $end"; my ( $start, $step, $names, $data ) = RRDs::fetch @opts; #### my ( $intotal, $outtotal, $i ); foreach my $value ( @{ $data } ) { $start += $step; my ( $minute, $hour, $day, $month, $year ) = ( localtime( $start ) )[ 1, 2, 3, 4, 5 ]; $month += 1; # Why does localtime give month -1? my $dt = DateTime->new( year => $year, month => $month, day => $day, hour => $hour, minute => $minute ); next unless $span_set->contains( $dt ); $i++; $in_total += $value->[ 0 ]; $out_total += $value->[ 1 ]; } # Now go off and work out averages / percentages etc... # Build a HoH and exit the for loop. } # Output some purty HTML.