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

TypeError & Library mismatch #52

Closed
HyperDevil opened this issue Aug 24, 2016 · 4 comments
Closed

TypeError & Library mismatch #52

HyperDevil opened this issue Aug 24, 2016 · 4 comments

Comments

@HyperDevil
Copy link

HyperDevil commented Aug 24, 2016

Hi,

I am trying to run snmp_exporter on Ubuntu 16.04 LTS and running into several issues.

First issue:

Exception happened during processing of request from ('****_', 55329)
Traceback (most recent call last):
File "/usr/lib/python3.5/socketserver.py", line 600, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python3.5/socketserver.py", line 354, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/lib/python3.5/dist-packages/snmp_exporter/http.py", line 70, in
handler = lambda *args, *_kwargs: SnmpExporterHandler(config_path, _args, *_kwargs)
File "/usr/local/lib/python3.5/dist-packages/snmp_exporter/http.py", line 25, in init
BaseHTTPRequestHandler.init(self, _args, *_kwargs)
File "/usr/lib/python3.5/socketserver.py", line 681, in init
self.handle()
File "/usr/lib/python3.5/http/server.py", line 422, in handle
self.handle_one_request()
File "/usr/lib/python3.5/http/server.py", line 410, in handle_one_request
method()
File "/usr/local/lib/python3.5/dist-packages/snmp_exporter/http.py", line 64, in do_GET
""")
File "/usr/lib/python3.5/socket.py", line 593, in write
return self._sock.send(b)
TypeError: a bytes-like object is required, not 'str'

Which means that in file http.py the self.wfile.write() functions need to be rewritten so that the variables will be byte encoded using for example: self.wfile.write(traceback.format_exc().encode(encoding='utf_8')) on line 54.

Second issue

sudo pip3 install netsnmp-py

Error:

Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/snmp_exporter/http.py", line 46, in do_GET
output = collect_snmp(config[module], params['address'][0])
File "/usr/local/lib/python3.5/dist-packages/snmp_exporter/collector.py", line 120, in collect_snmp
for oid, value in values:
File "/usr/local/lib/python3.5/dist-packages/snmp_exporter/collector.py", line 23, in walk_oids
session = netsnmp.Session(Version=2, DestHost=host, RemotePort=port,
AttributeError: module 'netsnmp' has no attribute 'Session'

And the error is correct, netsnmp-py does not have a function called session.
It could be the wrong library, there is no other library i can find in PIP that has netsnmp in the name.
The netsnmp-python package in ubuntu 16.04 LTS is only for python 2.7.

At the moment i cannot use snmp_exporter.

@brian-brazil
Copy link
Contributor

The snmp exporter is not known to work with Python3, though someone has been submitting patches.

Per the README the netsnmp you need isn't on pip, it's an OS-level package.

It is expected that this will all be ported to Go in the near future so all this will go away.

@HyperDevil
Copy link
Author

Aha i did not know that.
I also tried running SNMP_exporter on Python 2.7 which also failed. (on ubuntu 16.04 LTS)
Which version of python is this written for?

@brian-brazil
Copy link
Contributor

It should work on 2.7, and it's known to work on 14.04.

@brian-brazil
Copy link
Contributor

The snmp exporter is now in Go.

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

2 participants