diff options
Diffstat (limited to 'python.d/haproxy.chart.py')
-rw-r--r-- | python.d/haproxy.chart.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/python.d/haproxy.chart.py b/python.d/haproxy.chart.py index 67a6f7821..a9ee66650 100644 --- a/python.d/haproxy.chart.py +++ b/python.d/haproxy.chart.py @@ -2,7 +2,6 @@ # Description: haproxy netdata python.d module # Author: l2isbad -from base import UrlService, SocketService from collections import defaultdict from re import compile as re_compile @@ -11,6 +10,8 @@ try: except ImportError: from urllib.parse import urlparse +from base import UrlService, SocketService + # default module values (can be overridden per job in `config`) # update_every = 2 priority = 60000 @@ -73,7 +74,8 @@ METRICS = {'bin': {'algorithm': 'incremental', 'divisor': 1024}, 'scur': {'algorithm': 'absolute', 'divisor': 1}, 'qcur': {'algorithm': 'absolute', 'divisor': 1}} -REGEX = dict(url=re_compile(r'idle = (?P<idle>[0-9]+)'), socket=re_compile(r'Idle_pct: (?P<idle>[0-9]+)')) +REGEX = dict(url=re_compile(r'idle = (?P<idle>[0-9]+)'), + socket=re_compile(r'Idle_pct: (?P<idle>[0-9]+)')) class Service(UrlService, SocketService): @@ -81,11 +83,15 @@ class Service(UrlService, SocketService): if 'socket' in configuration: SocketService.__init__(self, configuration=configuration, name=name) self.poll = SocketService - self.options_ = dict(regex=REGEX['socket'], stat='show stat\n', info='show info\n') + self.options_ = dict(regex=REGEX['socket'], + stat='show stat\n'.encode(), + info='show info\n'.encode()) else: UrlService.__init__(self, configuration=configuration, name=name) self.poll = UrlService - self.options_ = dict(regex=REGEX['url'], stat=self.url, info=url_remove_params(self.url)) + self.options_ = dict(regex=REGEX['url'], + stat=self.url, + info=url_remove_params(self.url)) self.order = ORDER self.definitions = CHARTS @@ -208,4 +214,4 @@ def server_down(server, backend_name): def url_remove_params(url): parsed = urlparse(url or str()) - return '%s://%s%s' % (parsed.scheme, parsed.netloc, parsed.path) + return '{scheme}://{netloc}{path}'.format(scheme=parsed.scheme, netloc=parsed.netloc, path=parsed.path) |