From: Bruce Caldwell (caldwell@kenetinc.com)
Date: Mon Oct 27 2003 - 17:16:19 EST
Hi folks,
I want to find out where my swap is going to. Top reports 8
gig in use on its summary. But when I total the lines I get
Less than 2 gig. Where is it all?? Top correlates with memps -p.
./totalswap.pl
150 processes: 138 sleeping, 11 zombie, 1 on cpu
Memory: 2048M real, 818M free, 8054M swap in use, 3579M swap free
TOP: Total swap used is 1175 Meg
memps output 1191.104M
Machine is a Sun 280 running solaris 2.8.
The zombies aren't supposed to take any resources
(http://rsusu1.rnd.runnet.ru/solaris2.7/Solaris_System_Administration_Gu
ide-stripped/ch01/025-027.html)
caldwell@cruncher: /netapp/home/caldwell/bin/ > swap -s
total: 8160984k bytes allocated + 85952k reserved = 8246936k used,
3665192k available
Perl script to grock top and memps:
#!/usr/bin/perl -w
# run top then add up total swap needed
open (TOP, "top -b 10000|") || die "cannot run top $!\n" ;
while (<TOP>) {
print ;
last if (/PID USERNAME/) ;
}
while (<TOP>) {
@fields = split (/\s+/, $_) ;
$size = $fields[6] ; # first char is a space
$size =~ /(\d+)([KMG])/ ;
$units = $2 ; $size = $1 ;
if ($units =~ /M/) {
$total += ($size * 1e6) ;
} else {
if ($units =~ /K/) {
$total += ($size * 1e3) ;
}
}
# print "$total $_" ;
}
printf "TOP: Total swap used is %d Meg\n", $total/1e6 ;
open (MEMPS, "memps -p |") || die "cannot open memps : $!\n" ;
while (<MEMPS>) {
next if (/PID /) ;
@fields = split (/\s+/, $_ ) ;
$size = $fields[2] ;
$size =~ s/k// ;
$mempstotal += $size * 1000 ;
# print "$mempstotal $_" ;
}
$mempstotal = $mempstotal/1e6 ;
print "memps outpout $mempstotal\M \n";
Thanks,
Bruce Caldwell
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:27:21 EDT