in reply to Re^2: How best to tell when my hash is "full" (all values defined)?
in thread How best to tell when my hash is "full" (all values defined)?
outputsmy @raw=`top -b -n 1`; my (%stats,%stats2); my $expected_keys = 5; @stats{'users','load','tmem','fmem','runproc'} = (); my $its=0; foreach my $line (@raw){ if ($line =~ /up\s.+\s(\d+)\suser.+\s+load\saverage:\s+(\d+\.\d{2}), +/){ $stats{users}=$1; $stats{load}=$2; $stats2{users}=$1; $stats2{load}=$2; } elsif ($line =~ /(?:Tasks|processes):.+\s+(\d+) running/i){ $stats{runproc}=$1; $stats2{runproc}=$1; } elsif ($line =~ /^Mem:\s+(\d+)k\s+(?:total|av),.+used,\s+(\d+)k\s+fr +ee/){ $stats{tmem}=$1; $stats{fmem}=$2; $stats2{tmem}=$1; $stats2{fmem}=$2; } $its++; print scalar(%stats2); print scalar(%stats); (scalar(keys(%stats2)) == $expected_keys) && last; } ## end foreach my $line (@raw)
2/8 4/8 2/8 4/8 2/8 4/8 4/8 4/8So the memory usage is no different (correct me if I am wrong--my understanding is that the number we are worried about (if we're worried about memory consumption) is the divisor).
I'll go ahead and make the call to `top` a piped open and have done with it. Thanks for your help (everyone who posted).
T.
|
|---|