Figure out memory usage using SNMP on Windows
Asked Answered
F

2

7

Currently i use the following to figure it out:

For total memory:

.1.3.6.1.2.1.25.2.2.0 

For used memory i walk the following oid (gives me usage of each process):

.1.3.6.1.2.1.25.5.1.1.2

and sum them all.

However, this is very inaccurate, because it shows much less usage than if i use WMI or the performance monitor.

Am i missing something? I do not want to use third party SNMP agents (like SNMP informant, which works correctly btw). I wanna figure it out using what's standard in windows.

Floatstone answered 25/2, 2011 at 17:0 Comment(0)
L
11

Try 1.3.6.1.2.1.25.2.3.1. I received the following results with Net-SNMP's snmpwalk utility from one of our Windows Server 2003 servers:

$ snmpwalk -v1 -cpublic 10.200.80.221 1.3.6.1.2.1.25.2.3.1.3
HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: C:\ Label:  Serial Number 38728140
HOST-RESOURCES-MIB::hrStorageDescr.2 = STRING: D:\
HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: O:\ Label:Data  Serial Number b618c4bc
HOST-RESOURCES-MIB::hrStorageDescr.4 = STRING: Q:\ Label:Quorum  Serial Number 4cbbcc74
HOST-RESOURCES-MIB::hrStorageDescr.5 = STRING: Virtual Memory
HOST-RESOURCES-MIB::hrStorageDescr.6 = STRING: Physical Memory

$ snmpwalk -v1 -cpublic 10.200.80.221 1.3.6.1.2.1.25.2.3.1.4
HOST-RESOURCES-MIB::hrStorageAllocationUnits.1 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.2 = INTEGER: 0 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.3 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.4 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.5 = INTEGER: 65536 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.6 = INTEGER: 65536 Bytes

$ snmpwalk -v1 -cpublic 10.200.80.221 1.3.6.1.2.1.25.2.3.1.5
HOST-RESOURCES-MIB::hrStorageSize.1 = INTEGER: 17911195
HOST-RESOURCES-MIB::hrStorageSize.2 = INTEGER: 0
HOST-RESOURCES-MIB::hrStorageSize.3 = INTEGER: 66794245
HOST-RESOURCES-MIB::hrStorageSize.4 = INTEGER: 35836990
HOST-RESOURCES-MIB::hrStorageSize.5 = INTEGER: 128101
HOST-RESOURCES-MIB::hrStorageSize.6 = INTEGER: 98266

$ snmpwalk -v1 -cpublic 10.200.80.221 1.3.6.1.2.1.25.2.3.1.6
HOST-RESOURCES-MIB::hrStorageUsed.1 = INTEGER: 1365706
HOST-RESOURCES-MIB::hrStorageUsed.2 = INTEGER: 0
HOST-RESOURCES-MIB::hrStorageUsed.3 = INTEGER: 38290
HOST-RESOURCES-MIB::hrStorageUsed.4 = INTEGER: 17637
HOST-RESOURCES-MIB::hrStorageUsed.5 = INTEGER: 4819
HOST-RESOURCES-MIB::hrStorageUsed.6 = INTEGER: 6952

What is important here are the 5th and 6th rows of the tables. If you have fewer hard disks then you can find the values of virtual and physical memory in other rows.

Lipsey answered 28/2, 2011 at 10:25 Comment(2)
Hmmm, hrStoragesize.6 and hrStorageUsed.6 doesn't really give a correct number? Could you explain what to sum/subtract on how to get total memory used? (Eg. what in the memory graph in task manager in Performance Tab)Floatstone
@Floatstone Total memory used: hrStorageUsed.6 * hrStorageAllocationUnits.6 = 6952 * 65536 = 455606272 bytes = 434,5 MB Total memory: hrStorageSize.6 * hrStorageAllocationUnits.6 = 98266 * 65536 = 6439960576 bytes = 5.99 GBLipsey
C
0

You may either report this as a bug to Microsoft and wait for a fix, or simply switch to another agent.

Microsoft prefers WMI to SNMP, so you should know the agent is only a second class citizen on Windows.

Crude answered 26/2, 2011 at 9:33 Comment(1)
So basically you're saying there's no way of getting that information without resorting to third party? WMI isn't always an option since it requires you have a valid user account on that server.Floatstone

© 2022 - 2024 — McMap. All rights reserved.