summaryrefslogtreecommitdiffstats
path: root/python.d/nginx_log.chart.py
diff options
context:
space:
mode:
authorLennart Weller <lhw@ring0.de>2017-01-24 15:21:09 +0000
committerLennart Weller <lhw@ring0.de>2017-01-24 15:21:09 +0000
commit3ed3b02ed96ddab1c084811f3579b3a2aec83e04 (patch)
tree7a61ab288ae47800c4f11be5677d6ad8288dcd98 /python.d/nginx_log.chart.py
parentNew upstream version 1.4.0+dfsg (diff)
downloadnetdata-3ed3b02ed96ddab1c084811f3579b3a2aec83e04.tar.xz
netdata-3ed3b02ed96ddab1c084811f3579b3a2aec83e04.zip
New upstream version 1.5.0+dfsgupstream/1.5.0+dfsg
Diffstat (limited to 'python.d/nginx_log.chart.py')
-rw-r--r--python.d/nginx_log.chart.py39
1 files changed, 26 insertions, 13 deletions
diff --git a/python.d/nginx_log.chart.py b/python.d/nginx_log.chart.py
index 95fb123d..ef964a56 100644
--- a/python.d/nginx_log.chart.py
+++ b/python.d/nginx_log.chart.py
@@ -15,9 +15,11 @@ CHARTS = {
'options': [None, 'nginx status codes', 'requests/s', 'requests', 'nginx_log.codes', 'stacked'],
'lines': [
["2xx", None, "incremental"],
+ ["5xx", None, "incremental"],
["3xx", None, "incremental"],
["4xx", None, "incremental"],
- ["5xx", None, "incremental"]
+ ["1xx", None, "incremental"],
+ ["other", None, "incremental"]
]}
}
@@ -33,37 +35,48 @@ class Service(LogService):
#pattern = r'(?:" )([0-9][0-9][0-9]) ?'
self.regex = re.compile(pattern)
+ self.data = {
+ '1xx': 0,
+ '2xx': 0,
+ '3xx': 0,
+ '4xx': 0,
+ '5xx': 0,
+ 'other': 0
+ }
+
def _get_data(self):
"""
Parse new log lines
:return: dict
"""
- data = {'2xx': 0,
- '3xx': 0,
- '4xx': 0,
- '5xx': 0}
try:
raw = self._get_raw_data()
if raw is None:
return None
elif not raw:
- return data
+ return self.data
except (ValueError, AttributeError):
return None
regex = self.regex
for line in raw:
code = regex.search(line)
- beginning = code.group(1)[0]
+ try:
+ beginning = code.group(1)[0]
+ except AttributeError:
+ continue
if beginning == '2':
- data["2xx"] += 1
+ self.data["2xx"] += 1
elif beginning == '3':
- data["3xx"] += 1
+ self.data["3xx"] += 1
elif beginning == '4':
- data["4xx"] += 1
+ self.data["4xx"] += 1
elif beginning == '5':
- data["5xx"] += 1
-
- return data
+ self.data["5xx"] += 1
+ elif beginning == '1':
+ self.data["1xx"] += 1
+ else:
+ self.data["other"] += 1
+ return self.data