@cryptotaxi247 / netdata-1 / commits / 4e2266eed

varnish plugin: memory usage chart added. Sort all charts into 7 groups

Ilya committed Jan 15, 2017 at 14:56 UTC 4e2266eed7a6ae7e70fee384e450c3ef791bcb27
1 file changed +40 -40
python.d/varnish.chart.py
+40 -40
@@ -13,16 +13,16 @@ from subprocess import Popen, PIPE
13 priority = 60000
14 retries = 60
15
16 -ORDER = ['hit_rate', 'chit_rate', 'request_rate', 'transfer_rates', 'session', 'backend_traffic', 'bad', 'uptime']
17 -EXTRA_ORDER = ['request_rate', 'hit_rate', 'backend_traffic', 'objects', 'transfer_rates', 'threads', 'memory_usage',
18 - 'objects_per_objhead', 'losthdr', 'hcb', 'esi', 'session', 'session_herd', 'shm_writes',
19 - 'shm', 'allocations', 'vcl', 'bans', 'bans_lurker', 'expunge', 'lru', 'bad', 'gzip', 'uptime']
16 +ORDER = ['hit_rate', 'chit_rate', 'request_rate', 'transfer_rates', 'session', 'backend_traffic', 'memory_usage', 'bad', 'uptime']
17 +EXTRA_ORDER = ['hit_rate','chit_rate', 'request_rate', 'transfer_rates', 'session', 'backend_traffic', 'bad',
18 + 'objects', 'threads', 'memory_usage', 'objects_per_objhead', 'losthdr', 'hcb', 'esi', 'session_herd',
19 + 'shm_writes', 'shm', 'allocations', 'vcl', 'bans', 'bans_lurker', 'expunge', 'lru', 'gzip', 'uptime']
20
21 CHARTS = {'allocations':
22 {'lines': [['sm_nreq', None, 'incremental', 1, 1],
23 ['sma_nreq', None, 'incremental', 1, 1],
24 ['sms_nreq', None, 'incremental', 1, 1]],
25 - 'options': [None, 'Memory allocation requests', 'units', 'allocations', 'varnish.alloc','line']},
25 + 'options': [None, 'Memory allocation requests', 'units', 'Extra charts', 'varnish.alloc','line']},
26 'backend_traffic':
27 {'lines': [['backend_conn_bt', 'conn', 'incremental', 1, 1],
28 ['backend_unhealthy', 'unhealthy', 'incremental', 1, 1],
@@ -33,7 +33,7 @@ CHARTS = {'allocations':
33 ['backend_toolate', 'toolate', 'incremental', 1, 1],
34 ['backend_retry', 'retry', 'incremental', 1, 1],
35 ['backend_req', 'req', 'incremental', 1, 1]],
36 - 'options': [None, 'Backend traffic', 'units', 'backend_traffic', 'varnish.backend_traf', 'line']},
36 + 'options': [None, 'Backend health', 'units', 'Backend health', 'varnish.backend_traf', 'line']},
37 'bad':
38 {'lines': [['sess_drop_b', None, 'incremental', 1, 1],
39 ['backend_unhealthy_b', None, 'incremental', 1, 1],
@@ -48,7 +48,7 @@ CHARTS = {'allocations':
48 ['esi_warnings_b', None, 'incremental', 1, 1],
49 ['sess_fail_b', None, 'incremental', 1, 1],
50 ['sess_pipe_overflow_b', None, 'incremental', 1, 1]],
51 - 'options': [None, 'Misbehavior', 'units', 'bad', 'varnish.bad', 'line']},
51 + 'options': [None, 'Misbehavior', 'units', 'Problems summary', 'varnish.bad', 'line']},
52 'bans':
53 {'lines': [['bans', None, 'absolute', 1, 1],
54 ['bans_added', 'added', 'incremental', 1, 1],
@@ -62,61 +62,61 @@ CHARTS = {'allocations':
62 ['bans_dups', 'dups', 'absolute', 1, 1],
63 ['bans_persisted_bytes', 'pers_bytes', 'absolute', 1, 1],
64 ['bans_persisted_fragmentation', 'pers_fragmentation', 'absolute', 1, 1]],
65 - 'options': [None, 'Bans', 'units', 'bans', 'varnish.bans', 'line']},
65 + 'options': [None, 'Bans', 'units', 'Extra charts', 'varnish.bans', 'line']},
66 'bans_lurker':
67 {'lines': [['bans_lurker_tested', 'tested', 'incremental', 1, 1],
68 ['bans_lurker_tests_tested', 'tests_tested', 'incremental', 1, 1],
69 ['bans_lurker_obj_killed', 'obj_killed', 'incremental', 1, 1],
70 ['bans_lurker_contention', 'contention', 'incremental', 1, 1]],
71 - 'options': [None, 'Ban Lurker', 'units', 'bans_lurker', 'varnish.bans_lurker', 'line']},
71 + 'options': [None, 'Ban Lurker', 'units', 'Extra charts', 'varnish.bans_lurker', 'line']},
72 'esi':
73 {'lines': [['esi_parse', None, 'incremental', 1, 1],
74 ['esi_errors', None, 'incremental', 1, 1],
75 ['esi_warnings', None, 'incremental', 1, 1]],
76 - 'options': [None, 'ESI', 'units', 'esi', 'varnish.esi', 'line']},
76 + 'options': [None, 'ESI', 'units', 'Extra charts', 'varnish.esi', 'line']},
77 'expunge':
78 {'lines': [['n_expired', None, 'incremental', 1, 1],
79 ['n_lru_nuked_e', None, 'incremental', 1, 1]],
80 - 'options': [None, 'Object expunging', 'units', 'expunge', 'varnish.expunge', 'line']},
80 + 'options': [None, 'Object expunging', 'units', 'Extra charts', 'varnish.expunge', 'line']},
81 'gzip':
82 {'lines': [['n_gzip', None, 'incremental', 1, 1],
83 ['n_gunzip', None, 'incremental', 1, 1]],
84 - 'options': [None, 'GZIP activity', 'units', 'gzip', 'varnish.gzip', 'line']},
84 + 'options': [None, 'GZIP activity', 'units', 'Extra charts', 'varnish.gzip', 'line']},
85 'hcb':
86 {'lines': [['hcb_nolock', 'nolock', 'incremental', 1, 1],
87 ['hcb_lock', 'lock', 'incremental', 1, 1],
88 ['hcb_insert', 'insert', 'incremental', 1, 1]],
89 - 'options': [None, 'Critbit data', 'units', 'hcb', 'varnish.hcb', 'line']},
89 + 'options': [None, 'Critbit data', 'units', 'Extra charts', 'varnish.hcb', 'line']},
90 'hit_rate':
91 {'lines': [['cache_hit_perc', 'hit', 'absolute', 1, 100],
92 ['cache_miss_perc', 'miss', 'absolute', 1, 100],
93 ['cache_hitpass_perc', 'hitpass', 'absolute', 1, 100]],
94 - 'options': [None, 'All history hit rate','percent', 'Cache hit rate', 'varnish.hit_rate', 'line']},
94 + 'options': [None, 'All history hit rate ratio','percent', 'Cache perfomance', 'varnish.hit_rate', 'stacked']},
95 'chit_rate':
96 {'lines': [['cache_hit_cperc', 'hit', 'absolute', 1, 100],
97 ['cache_miss_cperc', 'miss', 'absolute', 1, 100],
98 ['cache_hitpass_cperc', 'hitpass', 'absolute', 1, 100]],
99 - 'options': [None, 'Current poll hit rate (prev / current * 100)','percent', 'Cache hit rate', 'varnish.hit_rate', 'line']},
99 + 'options': [None, 'Current poll hit rate ratio','percent', 'Cache perfomance', 'varnish.chit_rate', 'stacked']},
100 'losthdr':
101 {'lines': [['losthdr', None, 'incremental', 1, 1]],
102 - 'options': [None, 'HTTP Header overflows', 'units', 'losthdr', 'varnish.losthdr', 'line']},
102 + 'options': [None, 'HTTP Header overflows', 'units', 'Extra charts', 'varnish.losthdr', 'line']},
103 'lru':
104 {'lines': [['n_lru_nuked', 'nuked', 'incremental', 1, 1],
105 ['n_lru_moved', 'moved', 'incremental', 1, 1]],
106 - 'options': [None, 'LRU activity', 'units', 'lru', 'varnish.lru', 'line']},
106 + 'options': [None, 'LRU activity', 'units', 'Extra charts', 'varnish.lru', 'line']},
107 'memory_usage':
108 - {'lines': [['sms_balloc', None, 'absolute', 1, 1],
109 - ['sms_nbytes', None, 'absolute', 1, 1]],
110 - 'options': [None, 'Memory usage', 'units', 'memory_usage', 'varnish.memory_usage', 'line']},
108 + {'lines': [['s0.g_space', 'available', 'absolute', 1, 1048576],
109 + ['s0.g_bytes', 'allocated', 'absolute', -1, 1048576]],
110 + 'options': [None, 'Memory usage', 'megabytes', 'Memory usage', 'varnish.memory_usage', 'stacked']},
111 'objects':
112 {'lines': [['n_object', 'object', 'absolute', 1, 1],
113 ['n_objectcore', 'objectcore', 'absolute', 1, 1],
114 ['n_vampireobject', 'vampireobject, ''absolute', 1, 1],
115 ['n_objecthead', 'objecthead', 'absolute', 1, 1]],
116 - 'options': [None, 'Number of objects', 'units', 'objects', 'varnish.objects', 'line']},
116 + 'options': [None, 'Number of objects', 'units', 'Extra charts', 'varnish.objects', 'line']},
117 'objects_per_objhead':
118 {'lines': [['obj_per_objhead', 'per_objhead', 'absolute', 1, 100]],
119 - 'options': [None, 'Objects per objecthead', 'units', 'objects_per_objhead', 'varnish.objects_per_objhead', 'line']},
119 + 'options': [None, 'Objects per objecthead', 'units', 'Extra charts', 'varnish.objects_per_objhead', 'line']},
120 'request_rate':
121 {'lines': [['sess_conn_rr', None, 'incremental', 1, 1],
122 ['client_req', None, 'incremental', 1, 1],
@@ -127,7 +127,7 @@ CHARTS = {'allocations':
127 ['backend_unhealthy', None, 'incremental', 1, 1],
128 ['s_pipe', None, 'incremental', 1, 1],
129 ['s_pass', None, 'incremental', 1, 1]],
130 - 'options': [None, 'Request rates', 'units', 'request_rate', 'varnish.request_rate', 'line']},
130 + 'options': [None, 'Request rates', 'units', 'Varnish statistics', 'varnish.request_rate', 'line']},
131 'session':
132 {'lines': [['sess_conn', 'conn', 'incremental', 1, 1],
133 ['sess_drop', 'drop', 'incremental', 1, 1],
@@ -139,39 +139,39 @@ CHARTS = {'allocations':
139 ['sess_pipeline', 'pipeline', 'incremental', 1, 1],
140 ['sess_readahead' , 'readhead', 'incremental', 1, 1]],
141
142 - 'options': [None, 'Sessions', 'units', 'session', 'varnish.session', 'line']},
142 + 'options': [None, 'Sessions', 'units', 'Varnish statistics', 'varnish.session', 'line']},
143 'session_herd':
144 {'lines': [['sess_herd', None, 'incremental', 1, 1]],
145 - 'options': [None, 'Session herd', 'units', 'session_herd', 'varnish.session_herd', 'line']},
145 + 'options': [None, 'Session herd', 'units', 'Extra charts', 'varnish.session_herd', 'line']},
146 'shm':
147 {'lines': [['shm_flushes', 'flushes', 'incremental', 1, 1],
148 ['shm_cont', 'cont', 'incremental', 1, 1],
149 ['shm_cycles', 'cycles', 'incremental', 1, 1]],
150 - 'options': [None, 'SHM writes and records', 'units', 'shm', 'varnish.shm', 'line']},
150 + 'options': [None, 'SHM writes and records', 'units', 'Extra charts', 'varnish.shm', 'line']},
151 'shm_writes':
152 {'lines': [['shm_records', 'records', 'incremental', 1, 1],
153 ['shm_writes', 'writes', 'incremental', 1, 1]],
154 - 'options': [None, 'SHM writes and records', 'units', 'shm_writes', 'varnish.shm_writes', 'line']},
154 + 'options': [None, 'SHM writes and records', 'units', 'Extra charts', 'varnish.shm_writes', 'line']},
155 'threads':
156 {'lines': [['threads', None, 'absolute', 1, 1],
157 ['threads_created', 'created', 'incremental', 1, 1],
158 ['threads_failed', 'failed', 'incremental', 1, 1],
159 ['threads_limited', 'limited', 'incremental', 1, 1],
160 ['threads_destroyed', 'destroyed', 'incremental', 1, 1]],
161 - 'options': [None, 'Thread status', 'units', 'threads', 'varnish.threads', 'line']},
161 + 'options': [None, 'Thread status', 'units', 'Extra charts', 'varnish.threads', 'line']},
162 'transfer_rates':
163 - {'lines': [['s_resp_hdrbytes', 'resp_hdrbytes', 'incremental', 8, 1],
164 - ['s_resp_bodybytes', 'resp_bodybytes', 'incremental', 8, 1]],
165 - 'options': [None, 'Transfer rates', 'bits/s', 'transfer_rates', 'varnish.transfer_rates', 'line']},
163 + {'lines': [['s_resp_hdrbytes', 'header', 'incremental', 8, 1000],
164 + ['s_resp_bodybytes', 'body', 'incremental', -8, 1000]],
165 + 'options': [None, 'Transfer rates', 'kilobit/s', 'Varnish statistics', 'varnish.transfer_rates', 'area']},
166 'uptime':
167 {'lines': [['uptime', None, 'absolute', 1, 1]],
168 - 'options': [None, 'Varnish uptime', 'seconds', 'uptime', 'varnish.uptime', 'line']},
168 + 'options': [None, 'Varnish uptime', 'seconds', 'Varnish statistics', 'varnish.uptime', 'line']},
169 'vcl':
170 {'lines': [['n_backend', None, 'absolute', 1, 1],
171 ['n_vcl', None, 'incremental', 1, 1],
172 ['n_vcl_avail', None, 'incremental', 1, 1],
173 ['n_vcl_discard', None, 'incremental', 1, 1]],
174 - 'options': [None, 'VCL', 'units', 'vcl', 'varnish.vcl', 'line']}}
174 + 'options': [None, 'VCL', 'units', 'Extra charts', 'varnish.vcl', 'line']}}
175
176 DIRECTORIES = ['/bin/', '/usr/bin/', '/sbin/', '/usr/sbin/']
177
@@ -270,8 +270,8 @@ class Service(SimpleService):
270
271 # 3.2 Cache hit/miss/hitpass CURRENT in percent
272 if self.cache_prev:
273 - cache_summary = sum([to_netdata.get('cache_hit', 0) - self.cache_prev[0], to_netdata.get('cache_miss', 0) - self.cache_prev[1],
274 - to_netdata.get('cache_hitpass', 0) - self.cache_prev[2]])
273 + cache_summary = sum([to_netdata.get('cache_hit', 0), to_netdata.get('cache_miss', 0),
274 + to_netdata.get('cache_hitpass', 0)]) - sum(self.cache_prev)
275 to_netdata['cache_hit_cperc'] = find_percent(to_netdata.get('cache_hit', 0) - self.cache_prev[0], cache_summary, 10000)
276 to_netdata['cache_miss_cperc'] = find_percent(to_netdata.get('cache_miss', 0) - self.cache_prev[1], cache_summary, 10000)
277 to_netdata['cache_hitpass_cperc'] = find_percent(to_netdata.get('cache_hitpass', 0) - self.cache_prev[2], cache_summary, 10000)
@@ -282,7 +282,7 @@ class Service(SimpleService):
282
283 self.cache_prev = [to_netdata.get('cache_hit', 0), to_netdata.get('cache_miss', 0), to_netdata.get('cache_hitpass', 0)]
284
285 - # 3.3 Copy random stuff to new keys (do we need this?)
285 + # 3.2 Copy random stuff to new keys (do we need this?)
286 to_netdata['obj_per_objhead'] = find_percent(to_netdata.get('n_object', 0),
287 to_netdata.get('n_objecthead', 0), 100)
288 to_netdata['backend_conn_bt'] = to_netdata.get('backend_conn', 0)
@@ -320,18 +320,18 @@ class Service(SimpleService):
320 self.definitions.update({''.join([backend[0], '_resp_stats']): {
321 'options': [None,
322 '%s response statistics' % backend[0].capitalize(),
323 - "bits/s",
323 + "kilobit/s",
324 'Backend response',
325 'varnish.backend',
326 'area'],
327 'lines': [[''.join([backend[0], '_beresp_hdrbytes']),
328 - 'header', 'incremental', 8, 1],
328 + 'header', 'incremental', 8, 1000],
329 [''.join([backend[0], '_beresp_bodybytes']),
330 - 'body', 'incremental', -8, 1]]}})
330 + 'body', 'incremental', -8, 1000]]}})
331
332
333 def find_percent(value1, value2, multiply):
334 - # If value 2 is 0 return 0
334 + # If value2 is 0 return 0
335 if not value2:
336 return 0
337 else: