Skip to content

Commit

Permalink
max repetitions can be set in device config
Browse files Browse the repository at this point in the history
  • Loading branch information
frogmaster committed May 11, 2015
1 parent 5f886d9 commit 04c6599
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -57,6 +57,9 @@ Example configuration file:
hostname: "bar"
community: "foo"
snmp_version: 2
#snmp_timeout: 2000000
#snmp_retries: 0
#snmp_max_repetitions: 49
metrics:
- "ifInUcastPkts"
- ""ifOutOctets"
Expand Down
7 changes: 6 additions & 1 deletion src/opentsdb/snmp/device.py
Expand Up @@ -28,6 +28,10 @@ def __init__(self, data, resolvers, mods, metrics):
self.snmp_retries = data["snmp_retries"]
else:
self.snmp_retries = 0
if "snmp_max_repetitions" in data:
self.snmp_max_repetitions = data["snmp_max_repetitions"]
else:
self.snmp_max_repetitions = 49
self.metrics = []
self.resolvers = resolvers
self.value_modifiers = mods
Expand All @@ -50,7 +54,8 @@ def init_snmp(self):
community=self.community,
version=self.snmp_version,
timeout=self.snmp_timeout,
retries=self.snmp_retries
retries=self.snmp_retries,
max_repetitions=self.snmp_max_repetitions
)
self.snmp.connect()
return self.snmp
Expand Down
7 changes: 5 additions & 2 deletions src/opentsdb/snmp/snmp_session.py
Expand Up @@ -15,13 +15,16 @@


class SNMPSession:
def __init__(self, host, community, version=2, timeout=2000000, retries=0):
def __init__(self, host, community,
version=2, timeout=2000000,
retries=0, max_repetitions=49):
self.session = None
self.host = host
self.community = community
self.version = version
self.timeout = timeout
self.retries = retries
self.max_rep = max_repetitions

def connect(self):
#resolve hostname
Expand Down Expand Up @@ -66,7 +69,7 @@ def bulkwalk(self, oid,

while (runningtreename.startswith(oid) and stop is False):
vrs = VarList(Varbind(runningtreename, startindexpos))
result = self.session.getbulk(0, 50, vrs)
result = self.session.getbulk(0, self.max_rep, vrs)
if self.session.ErrorInd:
logging.warn(
"walk failed on: {0} ({1})".format(
Expand Down

0 comments on commit 04c6599

Please sign in to comment.