Python.d PEP 8 cleanup, modules I-L (#4288)
* python.d/icecast.chart.py PEP 8 cleanup Fix formatting of container literals and quoting of strings. * python.d/ipfs.chart.py PEP 8 cleanup Fix formatting of container literals and quoting of strings. * python.d/isc_dhcpd.chart.py PEP 8 cleanup Fix formatting of container literals and quoting of strings. * python.d/litespeed.chart.py PEP 8 cleanup Fix formatting of container literals and quoting of strings.
Austin S. Hemmelgarn committed
Sep 26, 2018 at 11:40 UTC
6ec160563b988e035f0f9e9e096fcff60b924ba0
4 files changed
+111
-91
python.d/icecast.chart.py
+4
-4
@@ -16,10 +16,10 @@ ORDER = ['listeners']
16
17
CHARTS = {
18
'listeners': {
19
- 'options': [None, 'Number Of Listeners', 'listeners',
20
- 'listeners', 'icecast.listeners', 'line'],
19
+ 'options': [None, 'Number Of Listeners', 'listeners', 'listeners', 'icecast.listeners', 'line'],
20
'lines': [
22
- ]}
21
+ ]
22
+ }
23
}
24
25
@@ -87,7 +87,7 @@ class Service(UrlService):
87
try:
88
data = json.loads(raw_data)
89
except ValueError as error:
90
- self.error("JSON decode error:", error)
90
+ self.error('JSON decode error:', error)
91
return None
92
93
return data['icestats'].get('source')
python.d/ipfs.chart.py
+27
-15
@@ -27,31 +27,43 @@ CHARTS = {
27
'bandwidth': {
28
'options': [None, 'IPFS Bandwidth', 'kbits/s', 'Bandwidth', 'ipfs.bandwidth', 'line'],
29
'lines': [
30
- ["in", None, "absolute", 8, 1000],
31
- ["out", None, "absolute", -8, 1000]
32
- ]},
30
+ ['in', None, 'absolute', 8, 1000],
31
+ ['out', None, 'absolute', -8, 1000]
32
+ ]
33
+ },
34
'peers': {
35
'options': [None, 'IPFS Peers', 'peers', 'Peers', 'ipfs.peers', 'line'],
36
'lines': [
36
- ["peers", None, 'absolute']
37
- ]},
37
+ ['peers', None, 'absolute']
38
+ ]
39
+ },
40
'repo_size': {
41
'options': [None, 'IPFS Repo Size', 'GB', 'Size', 'ipfs.repo_size', 'area'],
42
'lines': [
41
- ["avail", None, "absolute", 1, 1e9],
42
- ["size", None, "absolute", 1, 1e9],
43
- ]},
43
+ ['avail', None, 'absolute', 1, 1e9],
44
+ ['size', None, 'absolute', 1, 1e9],
45
+ ]
46
+ },
47
'repo_objects': {
48
'options': [None, 'IPFS Repo Objects', 'objects', 'Objects', 'ipfs.repo_objects', 'line'],
49
'lines': [
47
- ["objects", None, "absolute", 1, 1],
48
- ["pinned", None, "absolute", 1, 1],
49
- ["recursive_pins", None, "absolute", 1, 1]
50
- ]},
50
+ ['objects', None, 'absolute', 1, 1],
51
+ ['pinned', None, 'absolute', 1, 1],
52
+ ['recursive_pins', None, 'absolute', 1, 1]
53
+ ]
54
+ }
55
}
56
53
-SI_zeroes = {'k': 3, 'm': 6, 'g': 9, 't': 12,
54
- 'p': 15, 'e': 18, 'z': 21, 'y': 24}
57
+SI_zeroes = {
58
+ 'k': 3,
59
+ 'm': 6,
60
+ 'g': 9,
61
+ 't': 12,
62
+ 'p': 15,
63
+ 'e': 18,
64
+ 'z': 21,
65
+ 'y': 24
66
+}
67
68
69
class Service(UrlService):
@@ -75,7 +87,7 @@ class Service(UrlService):
87
88
@staticmethod
89
def _recursive_pins(keys):
78
- return sum( 1 for k in keys if keys[k]["Type"] == b"recursive" )
90
+ return sum(1 for k in keys if keys[k]['Type'] == b'recursive')
91
92
@staticmethod
93
def _dehumanize(store_max):
python.d/isc_dhcpd.chart.py
+10
-9
@@ -26,17 +26,18 @@ ORDER = ['pools_utilization', 'pools_active_leases', 'leases_total']
26
27
CHARTS = {
28
'pools_utilization': {
29
- 'options': [None, 'Pools Utilization', '%', 'utilization',
30
- 'isc_dhcpd.utilization', 'line'],
31
- 'lines': []},
29
+ 'options': [None, 'Pools Utilization', '%', 'utilization', 'isc_dhcpd.utilization', 'line'],
30
+ 'lines': []
31
+ },
32
'pools_active_leases': {
33
- 'options': [None, 'Active Leases Per Pool', 'leases', 'active leases',
34
- 'isc_dhcpd.active_leases', 'line'],
35
- 'lines': []},
33
+ 'options': [None, 'Active Leases Per Pool', 'leases', 'active leases', 'isc_dhcpd.active_leases', 'line'],
34
+ 'lines': []
35
+ },
36
'leases_total': {
37
- 'options': [None, 'All Active Leases', 'leases', 'active leases',
38
- 'isc_dhcpd.leases_total', 'line'],
39
- 'lines': [['leases_total', 'leases', 'absolute']],
37
+ 'options': [None, 'All Active Leases', 'leases', 'active leases', 'isc_dhcpd.leases_total', 'line'],
38
+ 'lines': [
39
+ ['leases_total', 'leases', 'absolute']
40
+ ],
41
'variables': [
42
['leases_size']
43
]
python.d/litespeed.chart.py
+70
-63
@@ -25,95 +25,102 @@ ORDER = [
25
26
CHARTS = {
27
'net_throughput_http': {
28
- 'options': [
29
- None, 'Network Throughput HTTP', 'kilobits/s', 'net throughput', 'litespeed.net_throughput', 'area'],
28
+ 'options': [None, 'Network Throughput HTTP', 'kilobits/s', 'net throughput',
29
+ 'litespeed.net_throughput', 'area'],
30
'lines': [
31
- ["bps_in", "in", "absolute"],
32
- ["bps_out", "out", "absolute", -1]
33
- ]},
31
+ ['bps_in', 'in', 'absolute'],
32
+ ['bps_out', 'out', 'absolute', -1]
33
+ ]
34
+ },
35
'net_throughput_https': {
35
- 'options': [
36
- None, 'Network Throughput HTTPS', 'kilobits/s', 'net throughput', 'litespeed.net_throughput', 'area'],
36
+ 'options': [None, 'Network Throughput HTTPS', 'kilobits/s', 'net throughput',
37
+ 'litespeed.net_throughput', 'area'],
38
'lines': [
38
- ["ssl_bps_in", "in", "absolute"],
39
- ["ssl_bps_out", "out", "absolute", -1]
40
- ]},
39
+ ['ssl_bps_in', 'in', 'absolute'],
40
+ ['ssl_bps_out', 'out', 'absolute', -1]
41
+ ]
42
+ },
43
'connections_http': {
42
- 'options': [
43
- None, 'Connections HTTP', 'conns', 'connections', 'litespeed.connections', 'stacked'],
44
+ 'options': [None, 'Connections HTTP', 'conns', 'connections', 'litespeed.connections', 'stacked'],
45
'lines': [
45
- ["conn_free", "free", "absolute"],
46
- ["conn_used", "used", "absolute"]
47
- ]},
46
+ ['conn_free', 'free', 'absolute'],
47
+ ['conn_used', 'used', 'absolute']
48
+ ]
49
+ },
50
'connections_https': {
49
- 'options': [
50
- None, 'Connections HTTPS', 'conns', 'connections', 'litespeed.connections', 'stacked'],
51
+ 'options': [None, 'Connections HTTPS', 'conns', 'connections', 'litespeed.connections', 'stacked'],
52
'lines': [
52
- ["ssl_conn_free", "free", "absolute"],
53
- ["ssl_conn_used", "used", "absolute"]
54
- ]},
53
+ ['ssl_conn_free', 'free', 'absolute'],
54
+ ['ssl_conn_used', 'used', 'absolute']
55
+ ]
56
+ },
57
'requests': {
58
'options': [None, 'Requests', 'requests/s', 'requests', 'litespeed.requests', 'line'],
59
'lines': [
58
- ["requests", None, "absolute", 1, 100]
59
- ]},
60
+ ['requests', None, 'absolute', 1, 100]
61
+ ]
62
+ },
63
'requests_processing': {
64
'options': [None, 'Requests In Processing', 'requests', 'requests', 'litespeed.requests_processing', 'line'],
65
'lines': [
63
- ["requests_processing", "processing", "absolute"]
64
- ]},
66
+ ['requests_processing', 'processing', 'absolute']
67
+ ]
68
+ },
69
'pub_cache_hits': {
70
'options': [None, 'Public Cache Hits', 'hits/s', 'cache', 'litespeed.cache', 'line'],
71
'lines': [
68
- ["pub_cache_hits", "hits", "absolute", 1, 100]
69
- ]},
72
+ ['pub_cache_hits', 'hits', 'absolute', 1, 100]
73
+ ]
74
+ },
75
'private_cache_hits': {
76
'options': [None, 'Private Cache Hits', 'hits/s', 'cache', 'litespeed.cache', 'line'],
77
'lines': [
73
- ["private_cache_hits", "hits", "absolute", 1, 100]
74
- ]},
78
+ ['private_cache_hits', 'hits', 'absolute', 1, 100]
79
+ ]
80
+ },
81
'static_hits': {
82
'options': [None, 'Static Hits', 'hits/s', 'static', 'litespeed.static', 'line'],
83
'lines': [
78
- ["static_hits", "hits", "absolute", 1, 100]
79
- ]},
84
+ ['static_hits', 'hits', 'absolute', 1, 100]
85
+ ]
86
+ }
87
}
88
82
-t = namedtuple("T", ["key", "id", "mul"])
89
+t = namedtuple('T', ['key', 'id', 'mul'])
90
91
T = [
85
- t("BPS_IN", "bps_in", 8),
86
- t("BPS_OUT", "bps_out", 8),
87
- t("SSL_BPS_IN", "ssl_bps_in", 8),
88
- t("SSL_BPS_OUT", "ssl_bps_out", 8),
89
- t("REQ_PER_SEC", "requests", 100),
90
- t("REQ_PROCESSING", "requests_processing", 1),
91
- t("PUB_CACHE_HITS_PER_SEC", "pub_cache_hits", 100),
92
- t("PRIVATE_CACHE_HITS_PER_SEC", "private_cache_hits", 100),
93
- t("STATIC_HITS_PER_SEC", "static_hits", 100),
94
- t("PLAINCONN", "conn_used", 1),
95
- t("AVAILCONN", "conn_free", 1),
96
- t("SSLCONN", "ssl_conn_used", 1),
97
- t("AVAILSSL", "ssl_conn_free", 1),
92
+ t('BPS_IN', 'bps_in', 8),
93
+ t('BPS_OUT', 'bps_out', 8),
94
+ t('SSL_BPS_IN', 'ssl_bps_in', 8),
95
+ t('SSL_BPS_OUT', 'ssl_bps_out', 8),
96
+ t('REQ_PER_SEC', 'requests', 100),
97
+ t('REQ_PROCESSING', 'requests_processing', 1),
98
+ t('PUB_CACHE_HITS_PER_SEC', 'pub_cache_hits', 100),
99
+ t('PRIVATE_CACHE_HITS_PER_SEC', 'private_cache_hits', 100),
100
+ t('STATIC_HITS_PER_SEC', 'static_hits', 100),
101
+ t('PLAINCONN', 'conn_used', 1),
102
+ t('AVAILCONN', 'conn_free', 1),
103
+ t('SSLCONN', 'ssl_conn_used', 1),
104
+ t('AVAILSSL', 'ssl_conn_free', 1),
105
]
106
107
RE = re.compile(r'([A-Z_]+): ([0-9.]+)')
108
109
ZERO_DATA = {
103
- "bps_in": 0,
104
- "bps_out": 0,
105
- "ssl_bps_in": 0,
106
- "ssl_bps_out": 0,
107
- "requests": 0,
108
- "requests_processing": 0,
109
- "pub_cache_hits": 0,
110
- "private_cache_hits": 0,
111
- "static_hits": 0,
112
- "conn_used": 0,
113
- "conn_free": 0,
114
- "ssl_conn_used": 0,
115
- "ssl_conn_free": 0,
116
- }
110
+ 'bps_in': 0,
111
+ 'bps_out': 0,
112
+ 'ssl_bps_in': 0,
113
+ 'ssl_bps_out': 0,
114
+ 'requests': 0,
115
+ 'requests_processing': 0,
116
+ 'pub_cache_hits': 0,
117
+ 'private_cache_hits': 0,
118
+ 'static_hits': 0,
119
+ 'conn_used': 0,
120
+ 'conn_free': 0,
121
+ 'ssl_conn_used': 0,
122
+ 'ssl_conn_free': 0,
123
+}
124
125
126
class Service(SimpleService):
@@ -121,7 +128,7 @@ class Service(SimpleService):
128
SimpleService.__init__(self, configuration=configuration, name=name)
129
self.order = ORDER
130
self.definitions = CHARTS
124
- self.path = self.configuration.get('path', "/tmp/lshttpd/")
131
+ self.path = self.configuration.get('path', '/tmp/lshttpd/')
132
self.files = list()
133
134
def check(self):
@@ -129,17 +136,17 @@ class Service(SimpleService):
136
self.error('"path" not specified')
137
return False
138
132
- fs = glob.glob(os.path.join(self.path, ".rtreport*"))
139
+ fs = glob.glob(os.path.join(self.path, '.rtreport*'))
140
141
if not fs:
142
self.error('"{0}" has no "rtreport" files or dir is not readable'.format(self.path))
143
return None
144
138
- self.debug("stats files:", fs)
145
+ self.debug('stats files:', fs)
146
147
for f in fs:
148
if not is_readable_file(f):
142
- self.error("{0} is not readable".format(f))
149
+ self.error('{0} is not readable'.format(f))
150
continue
151
self.files.append(f)
152
@@ -167,7 +174,7 @@ class Service(SimpleService):
174
175
def parse_file(data, lines):
176
for line in lines:
170
- if not line.startswith(("BPS_IN:", "MAXCONN:", "REQ_RATE []:")):
177
+ if not line.startswith(('BPS_IN:', 'MAXCONN:', 'REQ_RATE []:')):
178
continue
179
m = dict(RE.findall(line))
180
for v in T: