python3-netsnmp
python3-netsnmp copied to clipboard
RemotePort parameter not used
When the parameter RemotePort is modified (with another value than 161), snmpget/walk still uses 161 as a remote port.
It works if you append the port to the DestHost like this DestHost="<HOST>:<PORT>"
:
sess = netsnmp.Session(Version=2,
DestHost="{}:{}".format(host, port),
Community='public')
Thanks for your answer Alexandre. But it looks like more an undocumented workaround than a bugfix of the RemotePort parameter. Isn't it ?
Agree it's a bit confusing.
I found this test using this syntax in net-snmp-5.9/python/netsnmp/tests/test.py
. Makes me think it might not be a workaround.
def snmp_dest(**kwargs):
"""Return information about how to communicate with snmpd"""
dest = {
'Version': 1,
'DestHost': 'localhost:' + str(os.environ.get("SNMP_SNMPD_PORT", 161)),
# Both the community strings "public" and "private"
# cannot be used to set variables using "snmpset"
# operations. Run the "snmpset" tests after replacing
# the following 'Community' string with any other
# configured community string from the snmpd.conf file.
'Community': 'public',
}
for key, value in kwargs.items():
dest[key] = value
return dest
Not sure what's the purpose of RemotePort
, possibly a bug (?)
The doc in netsnmp source indicates:
RemotePort - default '161', allow remote UDP port to be overridden