--- trunk/lib/Frey/jQuery/flot.pm 2008/12/26 01:32:09 907 +++ trunk/lib/Frey/jQuery/flot.pm 2009/01/05 20:22:37 920 @@ -21,6 +21,8 @@ default => 'ssh www.rot13.org sar -n 1', ); +with 'Frey::Sponge'; # has sponge + sub as_markup { my ($self) = @_; @@ -31,18 +33,20 @@ |); - my $sponge = Frey::Shell::sar->new( sar_command => $self->sar_command )->as_sponge; - #warn $self->dump( $sponge ); + my $sponge = $self->sponge; my $by_col; my $unit_by_col; foreach my $row ( @{ $sponge->{rows} } ) { - my $x = DateTimeX::Easy->new( $row->[0] )->epoch * 1000; # ms + my $time = eval { + DateTimeX::Easy->new( $row->[0] )->epoch * 1000; # ms + }; + die "FATAL: sponge first column ", $self->dump( $row->[0] ), " isn't valid time because of: $@" if $@; foreach my $col ( 1 .. $#$row ) { my $v = $row->[$col]; $unit_by_col->{$col} = $1 if $v =~ s{([M%])$}{}; - push @{ $by_col->{$col} }, [ $x, $v ]; + push @{ $by_col->{$col} }, [ $time, $v ]; } } @@ -87,7 +91,7 @@ foreach my $line ( split(/\s*\n\s*/, $flags ) ) { my ( $flag, $desc ) = split(/\s+/, $line, 2 ); - warn "# $flag | $desc"; + warn "# $flag | $desc" if $self->debug; my $v = "$c $flag"; my $checked = ''; $checked = " checked" if $self->sar_command =~ m{$flag};