forked from samuel/python-munin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcassandra_key_cache_ratio
More file actions
executable file
·45 lines (40 loc) · 1.4 KB
/
Copy pathcassandra_key_cache_ratio
File metadata and controls
executable file
·45 lines (40 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
import os
from munin.cassandra import MuninCassandraPlugin
class CassandraKeyCacheRatioPlugin(MuninCassandraPlugin):
title = "key cache hit ratio"
args = "--base 1000 -l 0"
vlabel = "ratio"
scale = False
@property
def fields(self):
fs = []
cfstats = self.cfstats()
for kf, kfstats in cfstats.items():
if not self.keyspaces or kf not in self.keyspaces:
continue
for cf, cfstats in kfstats['cf'].items():
name = "%s_%s" % (kf, cf)
label = "%s.%s" % (kf, cf)
fs.append((name, dict(
label = label,
info = label,
type = "GAUGE",
max = "1",
min = "0",
)))
return fs
def execute(self):
cfstats = self.cfstats()
values = {}
for kf, kfstats in cfstats.items():
if not self.keyspaces or kf not in self.keyspaces:
continue
for cf, cfstats in kfstats['cf'].items():
if cfstats['Key cache hit rate'] != 'NaN':
values["%s_%s" % (kf, cf)] = cfstats['Key cache hit rate']
else:
values["%s_%s" % (kf, cf)] = "U"
return values
if __name__ == "__main__":
CassandraKeyCacheRatioPlugin().run()