mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-05 16:58:59 +00:00
45 lines
1.4 KiB
Python
Executable file
45 lines
1.4 KiB
Python
Executable file
#!/usr/bin/env python
|
|
|
|
import os
|
|
from vendor.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()
|