Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit 2b5ceb0

Browse files
author
Gavin M. Roy
committed
Add auth support for CouchDB (MeetMe#58)
1 parent 5b19112 commit 2b5ceb0

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,14 @@ Configuration Example
231231
host: localhost
232232
port: 5984
233233
#verify_ssl_cert: true
234+
#username: foo
235+
#password: bar
234236
- name: localhost
235237
host: localhost
236238
port: 5984
237239
#verify_ssl_cert: true
240+
#username: foo
241+
#password: bar
238242

239243
edgecast:
240244
- name: My Edgecase Account

etc/newrelic/newrelic_plugin_agent.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Application:
1818
# host: localhost
1919
# verify_ssl_cert: true
2020
# port: 5984
21+
# username: foo
22+
# password: bar
2123

2224
#edgecast:
2325
# name: My Edgecase Account

newrelic_plugin_agent/plugins/couchdb.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,13 @@ def fetch_data(self):
7878
:rtype: dict
7979
8080
"""
81+
kwargs = {'url': self.couchdb_stats_url,
82+
'verify': self.config.get('verify_ssl_cert', True)}
83+
if 'username' in self.config and 'password' in self.config:
84+
kwargs['auth'] = (self.config['username'], self.config['password'])
85+
8186
try:
82-
response = requests.get(self.couchdb_stats_url,
83-
verify=self.config.get('verify_ssl_cert',
84-
True))
87+
response = requests.get(**kwargs)
8588
except requests.ConnectionError as error:
8689
LOGGER.error('Error polling CouchDB: %s', error)
8790
return {}

0 commit comments

Comments
 (0)