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

multiget to SNMPv1 device timeout #86

Closed
mig21a opened this issue Sep 26, 2020 · 6 comments
Closed

multiget to SNMPv1 device timeout #86

mig21a opened this issue Sep 26, 2020 · 6 comments

Comments

@mig21a
Copy link

mig21a commented Sep 26, 2020

Issue Description

pursnmp 1.9.1

python3

from puresnmp import multiget
result = multiget('x.x.x.x', 'public', ['1.3.6.1.2.1.1.5.0'], port=161, timeout=3, version=1)
Traceback (most recent call last):
File "", line 1, in
File "/ec/acc/app/dynatrace/OneAgent_SDK/py36a/lib/python3.6/site-packages/puresnmp/api/pythonic.py", line 147, in multiget
raw_output = raw.multiget(ip, community, oids, port, timeout, version=version)
File "/ec/acc/app/dynatrace/OneAgent_SDK/py36a/lib/python3.6/site-packages/puresnmp/api/raw.py", line 97, in multiget
response = transport.send(ip, port, to_bytes(packet))
File "/ec/acc/app/dynatrace/OneAgent_SDK/py36a/lib/python3.6/site-packages/puresnmp/transport.py", line 93, in send
"Max of %d retries reached" % self.retries) # type: ignore
puresnmp.exc.Timeout: Max of 3 retries reached

HexDump

DEBUG:puresnmp.transport:Sending packet to 10.65.100.80:161 (attempt 1/3)
30 29 02 01 01 04 06 70 75 62 6c 69 63 a0 1c 02 0).....public...
04 5f 6f c0 ae 02 01 00 02 01 00 30 0e 30 0c 06 ._o........0.0..
08 2b 06 01 02 01 01 09 01 05 00 .+.........
DEBUG:puresnmp.transport:Timeout during attempt #1
DEBUG:puresnmp.transport:Sending packet to 10.65.100.80:161 (attempt 2/3)
30 29 02 01 01 04 06 70 75 62 6c 69 63 a0 1c 02 0).....public...
04 5f 6f c0 ae 02 01 00 02 01 00 30 0e 30 0c 06 ._o........0.0..
08 2b 06 01 02 01 01 09 01 05 00 .+.........
DEBUG:puresnmp.transport:Timeout during attempt #2
DEBUG:puresnmp.transport:Sending packet to 10.65.100.80:161 (attempt 3/3)
30 29 02 01 01 04 06 70 75 62 6c 69 63 a0 1c 02 0).....public...
04 5f 6f c0 ae 02 01 00 02 01 00 30 0e 30 0c 06 ._o........0.0..
08 2b 06 01 02 01 01 09 01 05 00 .+.........
DEBUG:puresnmp.transport:Timeout during attempt #3
Traceback (most recent call last):
File "9.py", line 5, in
result = multiget('10.65.100.80', 'public', ['1.3.6.1.2.1.1.9.1'], port=161, timeout=3, version=1)
File "/ec/acc/app/dynatrace/OneAgent_SDK/py36a/lib/python3.6/site-packages/puresnmp/api/pythonic.py", line 147, in multiget
raw_output = raw.multiget(ip, community, oids, port, timeout, version=version)
File "/ec/acc/app/dynatrace/OneAgent_SDK/py36a/lib/python3.6/site-packages/puresnmp/api/raw.py", line 97, in multiget
response = transport.send(ip, port, to_bytes(packet))
File "/ec/acc/app/dynatrace/OneAgent_SDK/py36a/lib/python3.6/site-packages/puresnmp/transport.py", line 93, in send
"Max of %d retries reached" % self.retries) # type: ignore
puresnmp.exc.Timeout: Max of 3 retries reached

Kind regards

@exhuma
Copy link
Owner

exhuma commented Sep 27, 2020

This is unlikely an issue with the SNMP library itself. The UDP connection itself gets a timeout.

This happens for example if the community string is incorrect.

If it is correct, then this can have a couple of reasons:

The network device is:

  • ... switched off
  • ... not listening on UDP port 161 (no SNMP enabled)
  • ... sitting behind a firewall now allowing this traffic.

@mig21a
Copy link
Author

mig21a commented Sep 27, 2020

Hello,

It is not firewall, switched off, comunnity string or not listening.
I am able to collect data from same machine with perl net::snmp.
snmpget.pl -v 1 -c public -p 161 10.65.100.80 .1.3.6.1.2.1.1.5.0
.1.3.6.1.2.1.1.5.0 = OCTET STRING: CMC-RJ15-1

Below is example for request with version=1 and without.
I am not able to notice difference in the two request.

CODE

from puresnmp import multiget
import logging
logging.basicConfig(level=logging.DEBUG)
result = multiget('10.218.161.24', 'public', ['.1.3.6.1.2.1.1.5.0'], port=161, timeout=3)
result = multiget('10.65.100.80', 'public', ['.1.3.6.1.2.1.1.5.0'], port=161, timeout=3, version=1)

DEBUG

DEBUG:puresnmp.transport:Sending packet to 10.218.161.24:161 (attempt 1/3)
30 29 02 01 01 04 06 70 75 62 6c 69 63 a0 1c 02 0).....public...
04 5f 70 d7 37 02 01 00 02 01 00 30 0e 30 0c 06 ._p.7......0.0..
08 2b 06 01 02 01 01 05 00 05 00 .+.........
DEBUG:puresnmp.transport:Received packet:
30 34 02 01 01 04 06 70 75 62 6c 69 63 a2 27 02 04.....public.'.
04 5f 70 d7 37 02 01 00 02 01 00 30 19 30 17 06 ._p.7......0.0..
08 2b 06 01 02 01 01 05 00 04 0b 43 4d 43 2d 52 .+.........CMC-R
33 38 31 35 2d 31 3815-1
DEBUG:puresnmp.transport:Sending packet to 10.65.100.80:161 (attempt 1/3)
30 29 02 01 01 04 06 70 75 62 6c 69 63 a0 1c 02 0).....public...
04 5f 70 d7 37 02 01 00 02 01 00 30 0e 30 0c 06 ._p.7......0.0..
08 2b 06 01 02 01 01 05 00 05 00 .+.........
DEBUG:puresnmp.transport:Timeout during attempt #1
DEBUG:puresnmp.transport:Sending packet to 10.65.100.80:161 (attempt 2/3)
30 29 02 01 01 04 06 70 75 62 6c 69 63 a0 1c 02 0).....public...
04 5f 70 d7 37 02 01 00 02 01 00 30 0e 30 0c 06 ._p.7......0.0..
08 2b 06 01 02 01 01 05 00 05 00 .+.........
DEBUG:puresnmp.transport:Timeout during attempt #2
DEBUG:puresnmp.transport:Sending packet to 10.65.100.80:161 (attempt 3/3)
30 29 02 01 01 04 06 70 75 62 6c 69 63 a0 1c 02 0).....public...
04 5f 70 d7 37 02 01 00 02 01 00 30 0e 30 0c 06 ._p.7......0.0..
08 2b 06 01 02 01 01 05 00 05 00 .+.........

@exhuma
Copy link
Owner

exhuma commented Sep 28, 2020

Are you able to fetch the "sysObjectId" (1.3.6.1.2.1.1.2.0) with a simple puresnmp.get(...) instead of a "multiget" call?

SNMPv1 is not thoroughly tested so there might be some issues with it that I have not seen yet.

@mig21a
Copy link
Author

mig21a commented Sep 29, 2020

It is not responding.
There is no version available in get function.

@frogmaster
Copy link

I think version argument type is in actuality puresnmp.const.Version.V2c or V1. Integer values of those don't correspond to snmp version. V2c is 1 and V1 is 0. So when you passed version=1 you actually made a v2c call. The proper call would be:

from puresnmp.const import Version
result = multiget('x.x.x.x', 'public', ['1.3.6.1.2.1.1.5.0'], port=161, timeout=3, version=Version.V1)

I guess this issue could be safely closed.

@exhuma
Copy link
Owner

exhuma commented Apr 22, 2021

Good catch. I'll close this.

I really hope I'll get puresnmp-2.0 out soon. This will clarify this.

Waiting for a minor response from our legal dept which is the only blocker for now 😄

@exhuma exhuma closed this as completed Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants