#!/usr/bin/perl
use strict;
use Data::Dumper;
use constant PROG_NAME => 10;
my $what_im_looking_for = 'JVM';
my %ps_hash;
my @ps = `ps aux`;
foreach (@ps) {
my @tmp = split;
next if ($tmp[PROG_NAME] ne $what_im_looking_for);
$ps_hash{$tmp[PROG_NAME]}{cpu} += $tmp[3];
$ps_hash{$tmp[PROG_NAME]}{mem} += $tmp[4];
$ps_hash{$tmp[PROG_NAME]}{time} += $tmp[9];
}
print Dumper(\%ps_hash);
####
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 1324 76 ? S 2001 4:22 init [3]
root 2 0.0 0.0 0 0 ? SW 2001 0:07 [kflushd]
root 3 0.0 0.0 0 0 ? SW 2001 0:12 [kupdate]
root 4 0.0 0.0 0 0 ? SW 2001 0:00 [kpiod]
root 5 0.0 0.0 0 0 ? SW 2001 0:25 [kswapd]
root 6 0.0 0.0 0 0 ? SW< 2001 0:00 [mdrecoveryd]
root 45 0.0 0.0 0 0 ? SW 2001 0:00 [khubd]
root 353 0.0 0.5 1384 340 ? S 2001 0:26 syslogd -m 0
root 363 0.0 0.2 1680 184 ? S 2001 0:01 klogd
^^^^^^^^^^^^^^
This is where the name is
####
grep> cd pub
grep> more beer