G'Day Brian, On Wed, Jul 11, 2007 at 03:05:14PM -0400, Brian Gupta wrote: > How have I have gone all this time without knowing about the kstat command?! > :(
There have been a number of really awsome tools that sadly haven't been marketed or taught to customers very well; they would include, kstat microstate accounting lockstat cpustat/cputrack SE Toolkit RMCmem mdb When I first saw DTrace, I was hoping it wouldn't join that list! (and wondering what I could do to help prevent that :) Fortunately DTrace has been marketed very well (along with ZFS and Zones). The "Solaris Performance and Tools" book does demo a lot of these, and mentions kstat frequently (including sample Sun::Solaris::Kstat scripts in the appendix). Hopefully it will promote some of these lesser known tools. > I have tried poking around, and am trying to understand some of the fields, > and have a couple of scriptlets that I wrote that should report identical > output. (As I understand) > > What am I missing? > > 1) prtconf -v|grep ^Mem > 2) echo `pagesize` `kstat |grep physmem|nawk '{print $2}'`|nawk '{print > "Memory size: "$1 * $2 / 1024 / 1024 " Megabytes"}' Getting the kstat memory numbers to add up isn't easy. Once upon a time I wrote the following tool, which uses mostly Sun::Solaris::Kstat, $ ./swapinfo RAM _____Total 10238.6 Mb RAM Unusable 8.0 Mb RAM Kernel 8357.5 Mb RAM Locked 3.9 Mb RAM Used 1612.6 Mb RAM Avail 256.4 Mb Disk _____Total 2560.0 Mb Disk Alloc 29.0 Mb Disk Free 2531.0 Mb Swap _____Total 3150.2 Mb Swap Alloc 1341.9 Mb Swap Unalloc 633.6 Mb Swap Avail 1174.7 Mb Swap (MinFree) 1278.8 Mb Source is here: http://www.brendangregg.com/K9Toolkit/swapinfo. While it looks like it could be a spectacular tool, I never really advertised it as it never (and still doesn't) work on all platforms. It is unfinished business. It was hard to write because, 1) I didn't have access to the Solaris source (this was before OpenSolaris); but that has now changed 2) The kstat statistics are barely documented 3) AFAIK, many of the kstat statistics are not a "stable" interface (one of the great features of DTrace is the stability taxonomy that is built into the command set) 4) The Solaris VM is ancient, old and new, at the same time. The kstats made sense, at some point, and need updating just as badly as CPU kstats. If you are interested in memory stats, check out the following (this is the "SEE ALSO" section from the header of swapinfo), # SEE ALSO: vmstat 1 2; swap -s; echo ::memstat | mdb -k # RMCmem - The MemTool Package # RICHPse - The SE Toolkit # "Clearing up swap space confusion" Unix Insider, Adrian Cockcroft # "Solaris Internals", Jim Mauro, Richard McDougall # /usr/include/vm/anon.h, /usr/include/sys/systm.h no worries, Brendan -- Brendan [CA, USA] _______________________________________________ perf-discuss mailing list perf-discuss@opensolaris.org