-
Notifications
You must be signed in to change notification settings - Fork 995
/
cassandra_cfcounts
executable file
·50 lines (45 loc) · 1.64 KB
/
cassandra_cfcounts
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
46
47
48
49
50
#!/usr/bin/env python
import os
from munin.cassandra import MuninCassandraPlugin
class CassandraCFCountsPlugin(MuninCassandraPlugin):
title = "read/write rate"
args = "--base 1000 -l 0"
vlabel = "ops per ${graph_period}"
@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_reads" % (kf, cf)
label = "%s.%s reads" % (kf, cf)
fs.append((name, dict(
label = label,
info = label,
type = "DERIVE",
min = "0",
)))
name = "%s_%s_writes" % (kf, cf)
label = "%s.%s writes" % (kf, cf)
fs.append((name, dict(
label = label,
info = label,
type = "DERIVE",
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():
name = "%s_%s" % (kf, cf)
values["%s_reads" % name] = cfstats['Read Count']
values["%s_writes" % name] = cfstats['Write Count']
return values
if __name__ == "__main__":
CassandraCFCountsPlugin().run()