Patch for fixing hardware.memory.used metric

Change SNMP 'hardware.memory.used' metric
to reflect (memTotalReal - memAvailReal) which is the used value
for the memory for a physical machine.

This has to be done as SNMP does not provide a memory metric
for used that can be directly used.

Closes-Bug: #1321537

Change-Id: Ibd8cd38ef15a9e86ccd942412b80e90e3762dd44
This commit is contained in:
vivek.nandavanam 2015-02-18 22:43:35 -08:00
parent 3ad53cc903
commit 22783a4725
1 changed files with 10 additions and 3 deletions

View File

@ -65,7 +65,7 @@ class SNMPInspector(base.Inspector):
_cpu_15_min_load_oid = "1.3.6.1.4.1.2021.10.1.3.3"
# Memory OIDs
_memory_total_oid = "1.3.6.1.4.1.2021.4.5.0"
_memory_used_oid = "1.3.6.1.4.1.2021.4.6.0"
_memory_avail_real_oid = "1.3.6.1.4.1.2021.4.6.0"
_memory_total_swap_oid = "1.3.6.1.4.1.2021.4.3.0"
_memory_avail_swap_oid = "1.3.6.1.4.1.2021.4.4.0"
# Disk OIDs
@ -191,9 +191,9 @@ class SNMPInspector(base.Inspector):
},
'memory.used': {
'matching_type': EXACT,
'metric_oid': (_memory_used_oid, int),
'metric_oid': (_memory_avail_real_oid, int),
'metadata': {},
'post_op': None,
'post_op': "_post_op_memory_avail_to_used",
},
'memory.swap.total': {
'matching_type': EXACT,
@ -392,6 +392,13 @@ class SNMPInspector(base.Inspector):
suffix)
yield (value, metadata, extra_metadata)
def _post_op_memory_avail_to_used(self, host, cache, meter_def,
value, metadata, extra, suffix):
if self._memory_total_oid not in cache[self._CACHE_KEY_OID]:
self._query_oids(host, [self._memory_total_oid], cache, False)
value = int(cache[self._CACHE_KEY_OID][self._memory_total_oid]) - value
return value
def _post_op_net(self, host, cache, meter_def,
value, metadata, extra, suffix):
# add ip address into metadata