web_log bugfix: properly parse squid response codes
Ilya committed
Aug 7, 2017 at 10:30 UTC
609ebf67567fad3380e9fc7b9d91d4d0778621d3
1 file changed
+15
-9
python.d/web_log.chart.py
+15
-9
@@ -1,17 +1,20 @@
1
# -*- coding: utf-8 -*-
2
# Description: web log netdata python.d module
3
# Author: l2isbad
4
-import re
4
+
5
import bisect
6
-from os import access, R_OK
7
-from os.path import getsize
6
+import re
7
+
8
from collections import namedtuple, defaultdict
9
from copy import deepcopy
10
+from os import access, R_OK
11
+from os.path import getsize
12
13
try:
14
from itertools import filterfalse
15
except ImportError:
16
from itertools import ifilterfalse as filterfalse
17
+
18
from base import LogService
19
import msg
20
@@ -937,18 +940,21 @@ class Squid(Mixin):
940
:return:
941
"""
942
if code not in self.data:
940
- self.add_new_dimension(dimension_id=code, chart_key='squid_code')
943
+ self.add_new_dimension(dimension_id=code,
944
+ chart_key='squid_code')
945
self.data[code] += 1
942
- if '_' not in code:
943
- return
946
+
947
for tag in code.split('_'):
948
try:
949
chart_key = SQUID_CODES[tag]
950
except KeyError:
951
continue
949
- if tag not in self.data:
950
- self.add_new_dimension(dimension_id=tag, chart_key=chart_key)
951
- self.data[tag] += 1
952
+ dimension_id = '_'.join(['code_detailed', tag])
953
+ if dimension_id not in self.data:
954
+ self.add_new_dimension(dimension_id=dimension_id,
955
+ dimension=tag,
956
+ chart_key=chart_key)
957
+ self.data[dimension_id] += 1
958
959
960
def get_timings(timings, time):