App-ProcTrends
view release on metacpan or search on metacpan
$ref->{ line } = $q->param('line');
$ref->{ stack } = $q->param('stack');
$ref->{ imgformat } = $q->param('imgformat');
$ref->{ title } = $q->param('title');
$ref->{ width } = $q->param('width');
$ref->{ height } = $q->param('height');
my $process = $q->param('process');
my $metric = $q->param('metric');
my $rrd = App::ProcTrends::RRD->new( $ref );
$rrd->gen_image( '/home/satoshi/test.png', 'cpu', 'firefox' );
}
lib/App/ProcTrends/Commandline.pm view on Meta::CPAN
for my $proc ( @procs ) {
print $proc, "\n";
}
print "\n";
}
return 1;
}
=head2 img_handler
Generates png image files using object params, and store them in $self->{ out_dir }
=cut
sub img_handler {
my $self = shift;
my $rrd_dir = $self->{ rrd_dir };
my $out_dir = $self->{ out_dir };
my $rrd = $self->{ rrd };
my $procs = $self->{ procs };
lib/App/ProcTrends/Commandline.pm view on Meta::CPAN
for my $metric ( 'cpu', 'rss' ) {
my $path = $rrd_dir . "/$metric";
my $ref = $rrd->find_rrds( $path );
for my $process ( keys %{ $ref } ) {
if ( @procs ) {
next unless ( grep( /^$process$/, @procs ) );
}
my $rrdfile = $ref->{ $process };
my $filename = $out_dir . "/${metric}_$process.png";
my @params;
push @params, $filename;
push @params, "-s $start";
push @params, "-e $end";
push @params, "DEF:mydata=$rrdfile:$process:AVERAGE";
push @params, "AREA:mydata#0000FF:foo";
RRDs::graph( @params );
}
}
t/02-commandline.t view on Meta::CPAN
my $command = $obj->command();
is( $command, "img", "img method is returned" );
my $handler = "${command}_handler";
can_ok( $obj, $handler );
$obj->$handler();
my $count = 0;
opendir( my $dh, $ref->{ out_dir } );
while( my $file = readdir $dh ) {
$count++ if ( $file =~ /\.png$/ );
}
close $dh;
cmp_ok( $count, ">=", 1, "testing if images are found" );
system( "rm", "-rf", $ref->{ out_dir } );
is( $?, 0, "cleaning up" );
}
( run in 3.027 seconds using v1.01-cache-2.11-cpan-df04353d9ac )