dstat  が万能なのでredis infoのキーを眺められるプラグインをつくった。
redis-cli info の total_commands_processed を眺める場合。
DSTAT_REDIS_* な環境変数を設定することでなんでもできるし
### Author: Masakazu Ohtsuka <o.masakazu@gmail.com>
class Config():
  def __init__(self):
    import ConfigParser
    self.conf = ConfigParser.ConfigParser()
    import inspect
    this_file = inspect.getfile(inspect.currentframe())
    conf_file = this_file + ".conf"
    try:
      with open(conf_file):
        self.conf.read(conf_file)
    except IOError:
      print "conf file "+conf_file+" not found, using only ENV"
  # prioritize ENV variable > conf file
  def get(self,key):
    ret = os.getenv("DSTAT_REDIS_" + key.upper())
    if not ret:
      try:
        ret = self.conf.get("DEFAULT",key)
      except: pass
    return ret
config = Config()
global redis_info_keys
redis_info_keys = config.get("info_keys")
if not redis_info_keys: raise Exception, "provide conf file or DSTAT_REDIS_INFO_KEYS env"
redis_info_keys = redis_info_keys.split(',')
global column_width
column_width = config.get("column_width") or 10
global redis_host
redis_host   = config.get("host") or '127.0.0.1'
global redis_port
redis_port   = config.get("port") or 6379
global redis_db
redis_db     = config.get("db") or 0
class dstat_plugin(dstat):
    """
    Redis info plugin.
    """
    def __init__(self):
        self.name = 'redis'
        self.nick = ('')
        self.vars = redis_info_keys
        self.type = 'f'
        self.width = column_width
        self.scale = 0
    def check(self):
        try:
            import redis
            self.r = redis.Redis(host=redis_host,port=redis_port,db=redis_db)
        except:
            raise Exception, 'Plugin needs the redis module'
    def extract(self):
        info = self.r.info()
        for key in self.vars:
            self.val[key] = info[key]
 
次にこれを fluent-plugin-dstat  を使い fluentd  に流し込み、fluent-plugin-growthforecast  を使って GrowthForecast  でグラフにしよう。
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 
# td-agent/templates/default/td-agent.conf.erb
 <source>
   type dstat
   tag dstat.<%= node[:hostname] %>
   option --redis
   delay 30
 </source>
 
 <match dstat.*>
   type map
   tag  "mapped." + tag
   time time
   record record["dstat"]
 </match>
 
 <match mapped.dstat.*>
   type           flatten_hash
   add_tag_prefix flattened.
 </match>
 
 <match flattened.mapped.dstat.**>
   type growthforecast
   gfapi_url http://growthforecast/api/
   service dstat
   tag_for section
   remove_prefix flattened.mapped.dstat
   name_key_pattern .*
 </match> 
と、こうなる
このプラグインの組み合わせにたどり着くまで大変だった!<%= node[:hostname] %> 毎にgrowthforecastの section ができるので捗る気がする。
dstatのプラグイン  は公式のものがたくさんあるのでそれらを参考にすればわりと簡単に書ける。
kazeburo wareなアラートシステムを心待ちにしております