fixed bug in nginx_log module where the reported values were defined as incremental but returned as absolute
Costa Tsaousis (ktsaou) committed
Dec 23, 2016 at 23:09 UTC
fc0109c6aa0c62b86208653a1d1b1b73391e8729
1 file changed
+22
-12
python.d/nginx_log.chart.py
+22
-12
@@ -15,9 +15,11 @@ CHARTS = {
15
'options': [None, 'nginx status codes', 'requests/s', 'requests', 'nginx_log.codes', 'stacked'],
16
'lines': [
17
["2xx", None, "incremental"],
18
+ ["5xx", None, "incremental"],
19
["3xx", None, "incremental"],
20
["4xx", None, "incremental"],
20
- ["5xx", None, "incremental"]
21
+ ["1xx", None, "incremental"],
22
+ ["other", None, "incremental"]
23
]}
24
}
25
@@ -33,21 +35,26 @@ class Service(LogService):
35
#pattern = r'(?:" )([0-9][0-9][0-9]) ?'
36
self.regex = re.compile(pattern)
37
38
+ self.data = {
39
+ '1xx': 0,
40
+ '2xx': 0,
41
+ '3xx': 0,
42
+ '4xx': 0,
43
+ '5xx': 0,
44
+ 'other': 0
45
+ }
46
+
47
def _get_data(self):
48
"""
49
Parse new log lines
50
:return: dict
51
"""
41
- data = {'2xx': 0,
42
- '3xx': 0,
43
- '4xx': 0,
44
- '5xx': 0}
52
try:
53
raw = self._get_raw_data()
54
if raw is None:
55
return None
56
elif not raw:
50
- return data
57
+ return self.data
58
except (ValueError, AttributeError):
59
return None
60
@@ -60,13 +67,16 @@ class Service(LogService):
67
continue
68
69
if beginning == '2':
63
- data["2xx"] += 1
70
+ self.data["2xx"] += 1
71
elif beginning == '3':
65
- data["3xx"] += 1
72
+ self.data["3xx"] += 1
73
elif beginning == '4':
67
- data["4xx"] += 1
74
+ self.data["4xx"] += 1
75
elif beginning == '5':
69
- data["5xx"] += 1
70
-
71
- return data
76
+ self.data["5xx"] += 1
77
+ elif beginning == '1':
78
+ self.data["1xx"] += 1
79
+ else:
80
+ self.data["other"] += 1
81
82
+ return self.data