Add configuratino varfor SNMP community and port number

This commit is contained in:
Nicolargo 2014-05-10 16:36:01 +02:00
parent dbb2476339
commit 35ad7eb3fb
3 changed files with 10 additions and 2 deletions

View File

@ -122,6 +122,10 @@ class GlancesMain(object):
help=_('define a client/server password from the prompt'))
parser.add_argument('-s', '--server', action='store_true', default=False,
dest='server', help=_('run Glances in server mode'))
parser.add_argument('--snmp-community', default='public', dest='snmp_community',
help=_('SNMP community'))
parser.add_argument('--snmp-port', default=161, type=int,
dest='snmp_port', help=_('SNMP port'))
parser.add_argument('-t', '--time', default=self.refresh_time, type=int,
dest='seconds', help=_('set refresh time in seconds [default: %s sec]') % self.refresh_time)
parser.add_argument('-w', '--webserver', action='store_true', default=False,

View File

@ -243,7 +243,9 @@ class GlancesStatsClientSNMP(GlancesStats):
from glances.core.glances_snmp import GlancesSNMPClient
# Create an instance of the SNMP client
clientsnmp = GlancesSNMPClient(host=self.args.client)
clientsnmp = GlancesSNMPClient(host=self.args.client,
port=self.args.snmp_port,
community=self.args.snmp_community)
return clientsnmp.get_by_oid("1.3.6.1.2.1.1.5.0") != {}

View File

@ -66,7 +66,9 @@ class GlancesPlugin(object):
from glances.core.glances_snmp import GlancesSNMPClient
# Init the SNMP request
clientsnmp = GlancesSNMPClient(host=self.args.client)
clientsnmp = GlancesSNMPClient(host=self.args.client,
port=self.args.snmp_port,
community=self.args.snmp_community)
# Process the SNMP request
snmpresult = clientsnmp.get_by_oid(*snmp_oid.values())