You should look at '
ps -aux' (the '-' is deprecated on some *nix then use '
ps aux') and its output, else if '
ps' does not give all the info you need read up on the proc filesystem.
Here is some code:
#!/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);
Look at the output of '
ps aux' and find what your JVM is listed as in the proc table. Then just stick the name in
$what_im_looking_for
Sample ps output:
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 [kflush
+d]
root 3 0.0 0.0 0 0 ? SW 2001 0:12 [kupdat
+e]
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 [mdreco
+veryd]
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
grep> cd pub
grep> more beer
|