mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-05 16:58:59 +00:00
45 lines
1.1 KiB
Text
45 lines
1.1 KiB
Text
![]() |
#!/usr/bin/env python
|
||
|
from utils.munin.base import MuninGraph
|
||
|
import os, redis
|
||
|
|
||
|
class NBMuninGraph(MuninGraph):
|
||
|
|
||
|
|
||
|
def __init__(self, *args, **kwargs):
|
||
|
super(NBMuninGraph, self).__init__(*args, **kwargs)
|
||
|
self.host = os.environ["REDIS_HOST"]
|
||
|
|
||
|
@property
|
||
|
def graph_config(self):
|
||
|
graph = {
|
||
|
'graph_category' : 'redis',
|
||
|
'graph_title' : 'Redis DB sizes',
|
||
|
'graph_args' : '-l 0',
|
||
|
}
|
||
|
|
||
|
stats = self.stats
|
||
|
graph.update(dict((("%s.label" % s['_id'], s['_id']) for s in stats)))
|
||
|
graph.update(dict((("%s.draw" % s['_id'], 'LINE1') for s in stats)))
|
||
|
|
||
|
return graph
|
||
|
|
||
|
def calculate_metrics(self):
|
||
|
return self.stats
|
||
|
|
||
|
@property
|
||
|
def stats(self):
|
||
|
r = redis.Redis(self.host)
|
||
|
info = r.info()
|
||
|
dbs = dict([(k, v) for k, v in info.items() if k.startswith('db')])
|
||
|
sizes = {}
|
||
|
for db, values in dbs.items():
|
||
|
for key, value in values.items():
|
||
|
sizes[db+"_"+key] = value
|
||
|
return sizes
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
NBMuninGraph().run()
|
||
|
|
||
|
|