Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SNMPv3 session support to the asynchronous libraries #2736

Closed
Tracked by #1177
lunkwill42 opened this issue Nov 13, 2023 · 0 comments · Fixed by #2743
Closed
Tracked by #1177

Add SNMPv3 session support to the asynchronous libraries #2736

lunkwill42 opened this issue Nov 13, 2023 · 0 comments · Fixed by #2743
Assignees

Comments

@lunkwill42
Copy link
Member

lunkwill42 commented Nov 13, 2023

ipdevpoll's main entrypoint for SNMP sessions is the AgentProxy class, which is just a thin adapter for pynetsnmp's Twisted-compatible AgentProxy class:

class AgentProxy(common.AgentProxyMixIn, twistedsnmp.AgentProxy):
"""pynetsnmp AgentProxy derivative to adjust the silly 1000 value
limit imposed in getTable calls"""

The main method used to create AgentProxy instances for collection jobs is in nav.ipdevpoll.jobs.JobHandler._create_agentproxy():

def _create_agentproxy(self):
if self.agent:
self._destroy_agentproxy()
if not self.netbox.read_only:
self.agent = None
return
port = next(ports)
self.agent = AgentProxy(
self.netbox.ip,
161,
community=self.netbox.read_only,
snmpVersion='v%s' % self.netbox.snmp_version,
protocol=port.protocol,
snmp_parameters=snmp_parameter_factory(self.netbox),
)
try:
self.agent.open()
except SnmpError as error:
self.agent.close()
session_count = self.agent.count_open_sessions()
job_count = self.get_instance_count()
self._logger.error(
"%s (%d currently open SNMP sessions, %d job handlers)",
error,
session_count,
job_count,
)
raise AbortedJobError("Cannot open SNMP session", cause=error)
else:
self._logger.debug(
"AgentProxy created for %s: %s", self.netbox.sysname, self.agent
)

Command line programs like navoidverify and naventity seem to have their own versions of this method - perhaps this could benefit from some consolidation now that SNMP session parameters are becoming more complex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant