mirror of
https://github.com/nicolargo/glances.git
synced 2024-11-11 17:26:37 +03:00
Factorisation of the SNMP set
This commit is contained in:
parent
d2ba067f18
commit
66525c6efc
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user