This repository was archived by the owner on Jun 2, 2021. It is now read-only.
File tree 4 files changed +29
-16
lines changed
newrelic_plugin_agent/plugins
4 files changed +29
-16
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,8 @@ def add_datapoints(self, stats):
76
76
77
77
@property
78
78
def apache_stats_url (self ):
79
+ if 'scheme' not in self .config :
80
+ self .config ['scheme' ] = 'http'
79
81
return '%(scheme)s://%(host)s:%(port)s%(path)s?auto' % self .config
80
82
81
83
def fetch_data (self ):
@@ -84,10 +86,13 @@ def fetch_data(self):
84
86
:rtype: str
85
87
86
88
"""
89
+ kwargs = {'url' : self .apache_stats_url ,
90
+ 'verify' : self .config .get ('verify_ssl_cert' , True )}
91
+ if 'username' in self .config and 'password' in self .config :
92
+ kwargs ['auth' ] = (self .config ['username' ], self .config ['password' ])
93
+
87
94
try :
88
- response = requests .get (self .apache_stats_url ,
89
- verify = self .config .get ('verify_ssl_cert' ,
90
- True ))
95
+ response = requests .get (** kwargs )
91
96
except requests .ConnectionError as error :
92
97
LOGGER .error ('Error polling ApacheHTTPD: %s' , error )
93
98
return {}
@@ -105,8 +110,6 @@ def fetch_data(self):
105
110
def poll (self ):
106
111
LOGGER .info ('Polling ApacheHTTPD via %s' , self .apache_stats_url )
107
112
start_time = time .time ()
108
- if 'scheme' not in self .config :
109
- self .config ['scheme' ] = 'http'
110
113
self .derive = dict ()
111
114
self .gauge = dict ()
112
115
self .rate = dict ()
Original file line number Diff line number Diff line change @@ -59,18 +59,23 @@ def add_datapoints(self, stats):
59
59
60
60
@property
61
61
def nginx_stats_url (self ):
62
- return 'http://%(host)s:%(port)s/%(path)s' % self .config
62
+ if 'scheme' not in self .config :
63
+ self .config ['scheme' ] = 'http'
64
+ return '%{scheme}://%(host)s:%(port)s/%(path)s' % self .config
63
65
64
66
def fetch_data (self ):
65
67
"""Fetch the data from the Nginx server for the specified data type
66
68
67
69
:rtype: str
68
70
69
71
"""
72
+ kwargs = {'url' : self .nginx_stats_url ,
73
+ 'verify' : self .config .get ('verify_ssl_cert' , True )}
74
+ if 'username' in self .config and 'password' in self .config :
75
+ kwargs ['auth' ] = (self .config ['username' ], self .config ['password' ])
76
+
70
77
try :
71
- response = requests .get (self .nginx_stats_url ,
72
- verify = self .config .get ('verify_ssl_cert' ,
73
- True ))
78
+ response = requests .get (** kwargs )
74
79
except requests .ConnectionError as error :
75
80
LOGGER .error ('Error polling Nginx: %s' , error )
76
81
return {}
Original file line number Diff line number Diff line change @@ -417,9 +417,9 @@ def rabbitmq_base_url(self):
417
417
:rtype: str
418
418
419
419
"""
420
- port = self .config .get ('port' ,self .DEFAULT_PORT )
421
- secure = self .config .get ('secure' ,False )
422
- host = self .config .get ('host' ,self .DEFAULT_HOST )
420
+ port = self .config .get ('port' , self .DEFAULT_PORT )
421
+ secure = self .config .get ('secure' , False )
422
+ host = self .config .get ('host' , self .DEFAULT_HOST )
423
423
if secure :
424
424
return 'https://' + host + ':' + str (port ) + '/api'
425
425
else :
Original file line number Diff line number Diff line change @@ -174,18 +174,23 @@ def add_datapoints(self, stats):
174
174
175
175
@property
176
176
def riak_stats_url (self ):
177
- return 'http://%(host)s:%(port)s/stats' % self .config
177
+ if 'scheme' not in self .config :
178
+ self .config ['scheme' ] = 'http'
179
+ return '%{scheme}://%(host)s:%(port)s/stats' % self .config
178
180
179
181
def fetch_data (self ):
180
182
"""Fetch the data from the Riak server for the specified data type
181
183
182
184
:rtype: dict
183
185
184
186
"""
187
+ kwargs = {'url' : self .riak_stats_url ,
188
+ 'verify' : self .config .get ('verify_ssl_cert' , True )}
189
+ if 'username' in self .config and 'password' in self .config :
190
+ kwargs ['auth' ] = (self .config ['username' ], self .config ['password' ])
191
+
185
192
try :
186
- response = requests .get (self .riak_stats_url ,
187
- verify = self .config .get ('verify_ssl_cert' ,
188
- True ))
193
+ response = requests .get (** kwargs )
189
194
except requests .ConnectionError as error :
190
195
LOGGER .error ('Error polling Riak: %s' , error )
191
196
return {}
You can’t perform that action at this time.
0 commit comments