MeetMe/newrelic-plugin-agent — pull request #153 by but3k4 (2013-09-23 15:01:18+00:00)
Title: Fix proxy connections

The agent.py had problems with proxy connections. The requests module could not send data to the newrelic api. So I removed this module and added the urllib2.

I'm using the tinyproxy, but I replaced it for a squid proxy and a got the same error. The complete error is:

root@mongodb0003:~# newrelic_plugin_agent -c /etc/newrelic/newrelic_plugin_agent.cfg -f
INFO 2013-09-23 11:55:07 4107 MainProcess MainThread clihelper run L382 : newrelic_plugin_agent 1.1.0 started
INFO 2013-09-23 11:55:07 4107 MainProcess MainThread newrelic_plugin_agent.plugins.base finish L141 : MongoDB poll successful, completed in 0.02 seconds
INFO 2013-09-23 11:55:07 4107 MainProcess MainThread newrelic_plugin_agent.agent send_components L209 : Sending 56 metrics to NewRelic
Exception: error(104, 'Connection reset by peer')

Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/clihelper/__init__.py", line 744, in run
process.run()
File "/usr/lib/pymodules/python2.6/clihelper/__init__.py", line 384, in run
self.process()
File "/usr/lib/python2.6/dist-packages/newrelic_plugin_agent/agent.py", line 114, in process
self.send_data_to_newrelic()
File "/usr/lib/python2.6/dist-packages/newrelic_plugin_agent/agent.py", line 198, in send_data_to_newrelic
self.send_components(components, metrics)
File "/usr/lib/python2.6/dist-packages/newrelic_plugin_agent/agent.py", line 218, in send_components
True))
File "/usr/lib/python2.6/dist-packages/requests/api.py", line 88, in post
return request('post', url, data=data, **kwargs)
File "/usr/lib/python2.6/dist-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python2.6/dist-packages/requests/sessions.py", line 335, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.6/dist-packages/requests/sessions.py", line 438, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.6/dist-packages/requests/adapters.py", line 340, in send
r.content
File "/usr/lib/python2.6/dist-packages/requests/models.py", line 594, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
File "/usr/lib/python2.6/dist-packages/requests/models.py", line 541, in generate
chunk = self.raw.read(chunk_size, decode_content=True)
File "/usr/lib/python2.6/dist-packages/urllib3/response.py", line 171, in read
data = self._fp.read(amt)
File "/usr/lib/python2.6/httplib.py", line 542, in read
s = self.fp.read(amt)
File "/usr/lib/python2.6/socket.py", line 377, in read
data = self._sock.recv(left)
error: [Errno 104] Connection reset by peer