web_log plugin: requests per ip protocol chart added
Ilya committed
Feb 10, 2017 at 17:23 UTC
e5f7b43e7ae28bfed31ab0c25359de684685ff86
1 file changed
+17
-10
python.d/web_log.chart.py
+17
-10
@@ -17,7 +17,7 @@ except ImportError:
17
priority = 60000
18
retries = 60
19
20
-ORDER = ['response_codes', 'response_time', 'requests_per_url', 'http_method', 'bandwidth', 'clients', 'clients_all']
20
+ORDER = ['response_codes', 'response_time', 'requests_per_url', 'http_method', 'requests_per_ipproto', 'bandwidth', 'clients', 'clients_all']
21
CHARTS = {
22
'response_codes': {
23
'options': [None, 'Response Codes', 'requests/s', 'responses', 'web_log.response_codes', 'stacked'],
@@ -58,6 +58,12 @@ CHARTS = {
58
'http_method': {
59
'options': [None, 'Requests Per HTTP Method', 'requests/s', 'requests', 'web_log.http_method', 'stacked'],
60
'lines': [
61
+ ]},
62
+ 'requests_per_ipproto': {
63
+ 'options': [None, 'Requests Per IP Protocol', 'requests/s', 'requests', 'web_log.requests_per_ipproto', 'stacked'],
64
+ 'lines': [
65
+ ['req_ipv4', 'ipv4', 'absolute', 1, 1],
66
+ ['req_ipv6', 'ipv6', 'absolute', 1, 1]
67
]}
68
}
69
@@ -81,7 +87,7 @@ class Service(LogService):
87
self.data = {'bytes_sent': 0, 'resp_length': 0, 'resp_time_min': 0,
88
'resp_time_max': 0, 'resp_time_avg': 0, 'unique_cur_ipv4': 0,
89
'unique_cur_ipv6': 0, '2xx': 0, '5xx': 0, '3xx': 0, '4xx': 0,
84
- '1xx': 0, '0xx': 0, 'unmatched': 0}
90
+ '1xx': 0, '0xx': 0, 'unmatched': 0, 'req_ipv4': 0, 'req_ipv6': 0}
91
92
def check(self):
93
if not self.log_path:
@@ -293,19 +299,20 @@ class Service(LogService):
299
bisect.insort_left(request_time, resp_time)
300
request_counter['count'] += 1
301
request_counter['sum'] += resp_time
302
+ # requests per ip proto
303
+ if '.' in match_dict['address']:
304
+ proto = 'ipv4'
305
+ to_netdata['req_ipv4'] += 1
306
+ else:
307
+ proto = 'ipv6'
308
+ to_netdata['req_ipv6'] += 1
309
# unique clients ips
310
if address_not_in_pool(self.unique_all_time, match_dict['address'],
311
self.storage['unique_tot_ipv4'] + self.storage['unique_tot_ipv6']):
299
- if '.' in match_dict['address']:
300
- self.storage['unique_tot_ipv4'] += 1
301
- else:
302
- self.storage['unique_tot_ipv6'] += 1
312
+ self.storage['unique_tot_' + proto] += 1
313
if address_not_in_pool(unique_current, match_dict['address'],
314
to_netdata['unique_cur_ipv4'] + to_netdata['unique_cur_ipv6']):
305
- if '.' in match_dict['address']:
306
- to_netdata['unique_cur_ipv4'] += 1
307
- else:
308
- to_netdata['unique_cur_ipv6'] += 1
315
+ to_netdata['unique_cur_' + proto] += 1
316
else:
317
to_netdata['unmatched'] += 1
318
# timings