/[Frey]/trunk/lib/Frey/jQuery/flot.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/jQuery/flot.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 919 by dpavlin, Fri Dec 26 01:32:09 2008 UTC revision 920 by dpavlin, Mon Jan 5 20:22:37 2009 UTC
# Line 21  has sar_command => ( Line 21  has sar_command => (
21          default => 'ssh www.rot13.org sar -n 1',          default => 'ssh www.rot13.org sar -n 1',
22  );  );
23    
24    with 'Frey::Sponge'; # has sponge
25    
26  sub as_markup {  sub as_markup {
27          my ($self) = @_;          my ($self) = @_;
28    
# Line 31  sub as_markup { Line 33  sub as_markup {
33                  <script language="javascript" type="text/javascript" src="/$path/jquery.flot.js"></script>                  <script language="javascript" type="text/javascript" src="/$path/jquery.flot.js"></script>
34          |);          |);
35    
36          my $sponge = Frey::Shell::sar->new( sar_command => $self->sar_command )->as_sponge;          my $sponge = $self->sponge;
         #warn $self->dump( $sponge );  
37    
38          my $by_col;          my $by_col;
39          my $unit_by_col;          my $unit_by_col;
40    
41          foreach my $row ( @{ $sponge->{rows} } ) {          foreach my $row ( @{ $sponge->{rows} } ) {
42                  my $x = DateTimeX::Easy->new( $row->[0] )->epoch * 1000; # ms                  my $time = eval {
43                            DateTimeX::Easy->new( $row->[0] )->epoch * 1000; # ms
44                    };
45                    die "FATAL: sponge first column ", $self->dump( $row->[0] ), " isn't valid time because of: $@" if $@;
46                  foreach my $col ( 1 .. $#$row ) {                  foreach my $col ( 1 .. $#$row ) {
47                          my $v = $row->[$col];                          my $v = $row->[$col];
48                          $unit_by_col->{$col} = $1 if $v =~ s{([M%])$}{};                          $unit_by_col->{$col} = $1 if $v =~ s{([M%])$}{};
49                          push @{ $by_col->{$col} }, [ $x, $v ];                          push @{ $by_col->{$col} }, [ $time, $v ];
50                  }                  }
51          }          }
52    
# Line 87  sub as_markup { Line 91  sub as_markup {
91    
92          foreach my $line ( split(/\s*\n\s*/, $flags ) ) {          foreach my $line ( split(/\s*\n\s*/, $flags ) ) {
93                  my ( $flag, $desc ) = split(/\s+/, $line, 2 );                  my ( $flag, $desc ) = split(/\s+/, $line, 2 );
94                  warn "# $flag | $desc";                  warn "# $flag | $desc" if $self->debug;
95                  my $v = "$c $flag";                  my $v = "$c $flag";
96                  my $checked = '';                  my $checked = '';
97                  $checked = " checked" if $self->sar_command =~ m{$flag};                  $checked = " checked" if $self->sar_command =~ m{$flag};

Legend:
Removed from v.919  
changed lines
  Added in v.920

  ViewVC Help
Powered by ViewVC 1.1.26