2020-12-03 14:05:32 -05:00
|
|
|
#!/srv/newsblur/venv/newsblur3/bin/python
|
2011-12-02 16:22:38 -08:00
|
|
|
|
|
|
|
import os
|
2016-11-11 11:06:33 -08:00
|
|
|
from vendor.munin.cassandra import MuninCassandraPlugin
|
2011-12-02 16:22:38 -08:00
|
|
|
|
|
|
|
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()
|