Subject: snmpd and top don't agree
To: NetBSD/sparc64 <port-sparc64@NetBSD.org>
From: Joel CARNAT <joel@carnat.net>
List: port-sparc64
Date: 05/22/2006 23:44:35
Hi,

I'm trying to get memory usage stats (from net-snmp) on my Ultra 5, 
running netbsd-3.
The result from snmpwalk show swap usage similar to memory usage.
But the "top" command claim no swap is used.

# snmpwalk -v 2c -c mypasswd kala hrStorageTable
HOST-RESOURCES-MIB::hrStorageIndex.1 = INTEGER: 1
HOST-RESOURCES-MIB::hrStorageIndex.2 = INTEGER: 2
HOST-RESOURCES-MIB::hrStorageIndex.3 = INTEGER: 3
HOST-RESOURCES-MIB::hrStorageType.1 = OID: 
HOST-RESOURCES-TYPES::hrStorageOther
HOST-RESOURCES-MIB::hrStorageType.2 = OID: 
HOST-RESOURCES-TYPES::hrStorageRam
HOST-RESOURCES-MIB::hrStorageType.3 = OID: 
HOST-RESOURCES-TYPES::hrStorageVirtualMemory
HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: Memory Buffers
HOST-RESOURCES-MIB::hrStorageDescr.2 = STRING: Real Memory
HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: Swap Space
HOST-RESOURCES-MIB::hrStorageAllocationUnits.1 = INTEGER: 256 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.2 = INTEGER: 8192 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.3 = INTEGER: 8192 Bytes
HOST-RESOURCES-MIB::hrStorageSize.1 = INTEGER: 1024
HOST-RESOURCES-MIB::hrStorageSize.2 = INTEGER: 68191
HOST-RESOURCES-MIB::hrStorageSize.3 = INTEGER: 68191
HOST-RESOURCES-MIB::hrStorageUsed.1 = INTEGER: 57600
HOST-RESOURCES-MIB::hrStorageUsed.2 = INTEGER: 33566
HOST-RESOURCES-MIB::hrStorageUsed.3 = INTEGER: 33566
HOST-RESOURCES-MIB::hrStorageAllocationFailures.1 = Counter32: 0
HOST-RESOURCES-MIB::hrStorageAllocationFailures.2 = Counter32: 0
HOST-RESOURCES-MIB::hrStorageAllocationFailures.3 = Counter32: 0

# top
load averages:  0.70,  0.52,  
0.44                                               23:40:43
52 processes:  51 sleeping, 1 on processor
CPU states:  0.0% user,  0.0% nice,  0.0% system,  0.0% interrupt,  100% 
idle
Memory: 93M Act, 51M Inact, 4196K Wired, 18M Exec, 95M File, 8724K Free
Swap: 513M Total, 513M Free

net-snmp version is "net-snmp-5.2.1.2nb1" (from pkgsrc-2005Q4) because 
5.3* doesn't work at all.

This method gives decent results on netbsd/xen (netbsd-3 and netbsd-HEAD).
Any idea to get the right memory stats from snmp (except scripting from 
top ;-) ?

TIA,
    Jo