@cryptotaxi247 / netdata-1 / commits / 521d62968

varnish plugin: cache hit/miss/hitpass current poll stats added

Ilya committed Jan 15, 2017 at 02:48 UTC 521d629689449e5cac33c4b59c18e2698d86f834
1 file changed +24 -4
python.d/varnish.chart.py
+24 -4
@@ -13,7 +13,7 @@ from subprocess import Popen, PIPE
13 priority = 60000
14 retries = 60
15
16 -ORDER = ['request_rate', 'hit_rate', 'transfer_rates', 'session', 'backend_traffic', 'bad', 'uptime']
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']
@@ -91,7 +91,12 @@ CHARTS = {'allocations':
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, 'Hit rates','percent', 'hit_rate', 'varnish.hit_rate', 'line']},
94 + 'options': [None, 'All history hit rate','percent', 'Cache hit rate', 'varnish.hit_rate', 'line']},
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']},
100 'losthdr':
101 {'lines': [['losthdr', None, 'incremental', 1, 1]],
102 'options': [None, 'HTTP Header overflows', 'units', 'losthdr', 'varnish.losthdr', 'line']},
@@ -188,6 +193,7 @@ class Service(SimpleService):
193 self.rgx_bck = (compile(r'VBE.([\d\w_.]+)\(.*?\).(beresp[\w_]+)\s+(\d+)'),
194 compile(r'VBE.boot.([\w\d_]+).(beresp[\w_]+)\s+(\d+)'))
195 self.extra_charts = self.configuration.get('extra_charts', [])
196 + self.cache_prev = list()
197
198 def check(self):
199 # Cant start without 'varnishstat' command
@@ -255,14 +261,28 @@ class Service(SimpleService):
261 to_netdata.update({'_'.join([n, k]): int(v) for n, k, v in data_backend})
262
263 # 3. ADD additional keys to dict
258 - # 3.1 Cache hit/miss/hitpass overall in percent
264 + # 3.1 Cache hit/miss/hitpass OVERALL in percent
265 cache_summary = sum([to_netdata.get('cache_hit', 0), to_netdata.get('cache_miss', 0),
266 to_netdata.get('cache_hitpass', 0)])
267 to_netdata['cache_hit_perc'] = find_percent(to_netdata.get('cache_hit', 0), cache_summary, 10000)
268 to_netdata['cache_miss_perc'] = find_percent(to_netdata.get('cache_miss', 0), cache_summary, 10000)
269 to_netdata['cache_hitpass_perc'] = find_percent(to_netdata.get('cache_hitpass', 0), cache_summary, 10000)
270
265 - # 3.2 Copy random stuff to new keys (do we need this?)
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]])
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)
278 + else:
279 + to_netdata['cache_hit_cperc'] = 0
280 + to_netdata['cache_miss_cperc'] = 0
281 + to_netdata['cache_hitpass_cperc'] = 0
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?)
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)