6 |
#with 'Frey::Storage'; |
#with 'Frey::Storage'; |
7 |
with 'Frey::jQuery'; |
with 'Frey::jQuery'; |
8 |
with 'Frey::File'; # FIXME inline on demand? |
with 'Frey::File'; # FIXME inline on demand? |
9 |
|
with 'Frey::Web::IFrame'; |
10 |
|
|
11 |
use DateTimeX::Easy; |
use DateTimeX::Easy; |
12 |
|
|
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 |
|
|
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 |
|
|
68 |
$placeholder = qq| |
$placeholder = qq| |
69 |
<div id="placeholder" style="width:600px;height:300px;"></div> |
<div id="placeholder" style="width:600px;height:300px;"></div> |
70 |
<div id="selection">no selection</div> |
<div id="selection">no selection</div> |
71 |
|; |
| |
72 |
|
. $self->iframe_html |
73 |
|
; |
74 |
} |
} |
75 |
|
|
76 |
warn "# $data_js" if $self->debug; |
warn "# $data_js" if $self->debug; |
77 |
|
|
78 |
my $sar = $self->sar_command; |
my $sar = $self->sar_command; |
79 |
my $c = $sar; |
my $c = $sar; |
80 |
$c =~ s{(-n\s*\d+).*}{$1}; |
$c =~ s{sar\s(-n\s*\d+)?(.*?)$}{sar $1}; |
81 |
|
|
82 |
my $form = qq| |
my $form = qq| |
83 |
<form method="post"> |
<form method="post"> |
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}; |