Factorisation of the SNMP set

pull/354/head
Nicolargo 2014-05-02 15:42:04 +02:00
parent d2ba067f18
commit 66525c6efc
2 changed files with 17 additions and 12 deletions

View File

@ -56,6 +56,22 @@ class GlancesPlugin(object):
self.stats = input_stats
return self.stats
def set_stats_snmp(self, snmp_oid={}):
# Update stats using SNMP
from glances.core.glances_snmp import GlancesSNMPClient
# Init the SNMP request
clientsnmp = GlancesSNMPClient()
# Process the SNMP request
snmpresult = clientsnmp.get_by_oid(*snmp_oid.values())
# Build the internal dict with the SNMP result
for key in snmp_oid.iterkeys():
self.stats[key] = snmpresult[snmp_oid[key]]
return self.stats
def get_raw(self):
# Return the stats object
return self.stats

View File

@ -92,18 +92,7 @@ class Plugin(GlancesPlugin):
else:
self.stats['os_version'] = ""
elif input == 'snmp':
# Update stats using SNMP
from glances.core.glances_snmp import GlancesSNMPClient
# Init the SNMP request
clientsnmp = GlancesSNMPClient()
# Process the SNMP request
snmpresult = clientsnmp.get_by_oid(*snmp_oid.values())
# Build the internal dict with the SNMP result
for key in snmp_oid.iterkeys():
self.stats[key] = snmpresult[snmp_oid[key]]
self.stats = self.set_stats_snmp(snmp_oid=snmp_oid)
return self.stats