Subject: calculate memory used from `top`
To: NetBSD/current <current-users@NetBSD.org>
From: Joel CARNAT <joel@carnat.net>
List: current-users
Date: 10/25/2006 19:01:35
Hi,

I would like to graph (via script/snmp/rrdtool) my server memory usage.
As the std net-snmp tool has issue on sparc64, I'm looking at getting
the value from shell scripting.

When I look at `dmesg` and `top`, I get the following values:

## from dmesg ##########################################################
total memory = 188 MB
avail memory = 183 MB
########################################################################

## from top ############################################################
Memory: 80M Act, 44M Inact, 3772K Wired, 9516K Exec, 110M File, 8952K Free
########################################################################

What I can't figure out is how to make 183MB with that :)
I mean:
- if I sum everything, I get about 256M.
- if I sum everything, except "File" memory, I get about 148M.
- if I sum "Act" + "Inact", I get 124M.

Is there a way to get the "total used memory" from top ?
Or can "Wired", "Exec" and "File" be counted into "Act" and "Inact"
depending of process states ?

The "CPU states" and "Swap" informations are easialy summable.
On my Mac OS X workstations, the "Memory" part from "top" also is
easiable summable.

So... what did I miss ?

TIA,
	Jo