@cryptotaxi247 / netdata-1 / commits / 57ada03b8

haproxy plugin bugfix: encode requests before pass it to send method

Ilya committed Jul 22, 2017 at 14:28 UTC 57ada03b8dddd80ac571ce67a9f69921dcfccea7
1 file changed +11 -5
python.d/haproxy.chart.py
+11 -5
@@ -2,7 +2,6 @@
2 # Description: haproxy netdata python.d module
3 # Author: l2isbad
4
5 -from base import UrlService, SocketService
5 from collections import defaultdict
6 from re import compile as re_compile
7
@@ -11,6 +10,8 @@ try:
10 except ImportError:
11 from urllib.parse import urlparse
12
13 +from base import UrlService, SocketService
14 +
15 # default module values (can be overridden per job in `config`)
16 # update_every = 2
17 priority = 60000
@@ -73,7 +74,8 @@ METRICS = {'bin': {'algorithm': 'incremental', 'divisor': 1024},
74 'scur': {'algorithm': 'absolute', 'divisor': 1},
75 'qcur': {'algorithm': 'absolute', 'divisor': 1}}
76
76 -REGEX = dict(url=re_compile(r'idle = (?P<idle>[0-9]+)'), socket=re_compile(r'Idle_pct: (?P<idle>[0-9]+)'))
77 +REGEX = dict(url=re_compile(r'idle = (?P<idle>[0-9]+)'),
78 + socket=re_compile(r'Idle_pct: (?P<idle>[0-9]+)'))
79
80
81 class Service(UrlService, SocketService):
@@ -81,11 +83,15 @@ class Service(UrlService, SocketService):
83 if 'socket' in configuration:
84 SocketService.__init__(self, configuration=configuration, name=name)
85 self.poll = SocketService
84 - self.options_ = dict(regex=REGEX['socket'], stat='show stat\n', info='show info\n')
86 + self.options_ = dict(regex=REGEX['socket'],
87 + stat='show stat\n'.encode(),
88 + info='show info\n'.encode())
89 else:
90 UrlService.__init__(self, configuration=configuration, name=name)
91 self.poll = UrlService
88 - self.options_ = dict(regex=REGEX['url'], stat=self.url, info=url_remove_params(self.url))
92 + self.options_ = dict(regex=REGEX['url'],
93 + stat=self.url,
94 + info=url_remove_params(self.url))
95 self.order = ORDER
96 self.definitions = CHARTS
97
@@ -208,4 +214,4 @@ def server_down(server, backend_name):
214
215 def url_remove_params(url):
216 parsed = urlparse(url or str())
211 - return '%s://%s%s' % (parsed.scheme, parsed.netloc, parsed.path)
217 + return '{scheme}://{netloc}{path}'.format(scheme=parsed.scheme, netloc=parsed.netloc, path=parsed.path)