snmp: Fix discovery when total memory is missing

In 7348c156a8, we fix some case
where the oid value was not existed.

The post operation for "memory_avail" does not use the generic function
for getting oid value and is impacted by already fixed bug.

This change uses get_oid_value for "memory_avail" like any other place
to fix the issue.

Change-Id: I4b944716af301534a0906dd0ea6117c18c913d50
Closes-bug: #1707859
(cherry picked from commit 61fec88d4e)
This commit is contained in:
Mehdi Abaakouk 2017-08-01 10:51:40 +02:00 committed by Mehdi Abaakouk (sileht)
parent 00d2f6faf2
commit 39196afd03
1 changed files with 6 additions and 2 deletions

View File

@ -274,8 +274,12 @@ class SNMPInspector(base.Inspector):
_memory_total_oid = "1.3.6.1.4.1.2021.4.5.0"
if _memory_total_oid not in cache[self._CACHE_KEY_OID]:
self._query_oids(host, [_memory_total_oid], cache, False)
value = int(cache[self._CACHE_KEY_OID][_memory_total_oid]) - value
return value
total_value = self.get_oid_value(cache[self._CACHE_KEY_OID],
(_memory_total_oid, int))
if total_value is None:
return None
return total_value - value
def _post_op_net(self, host, cache, meter_def,
value, metadata, extra, suffix):