$ sudo service mysqld start
$ mysql -uroot -e "GRANT ALL PRIVILEGES ON graphite.* TO 'graphite'@'localhost' IDENTIFIED BY 'foobar';"
$ mysql -uroot -e "CREATE DATABASE graphite;"
$ cd /tmp
$ git clone https://github.com/hotchpotch/fluent-plugin-graphite.git
$ cd fluent-plugin-graphite
$ /usr/lib64/fluent/ruby/bin/rake
$ sudo /usr/lib64/fluent/ruby/bin/fluent-gem install pkg/fluent-plugin-graphite-0.2.1.gem
んで、td-agent.confの設定。
<source>
type exec
command sh /etc/td-agent/stats.sh
format tsv
keys hostname,nginx,memcached
tag stats
run_interval 5
</source>
<match stats>
type copy
<store>
type map
tag "map.dstat.nginx-req"
time time
record {"key" => record["hostname"]+".nginx-req", "gauge" => record["nginx"] }
</store>
<store>
type map
tag "map.dstat.memcached-incr"
time time
record {"key" => record["hostname"]+".memcached-incr", "gauge" => record["memcached"] }
</store>
</match>
<source>
type dstat
tag dstat
option -lcn
delay 5
</source>
<match dstat>
type copy
<store>
type map
tag "map.dstat.loadavg-short"
time time
record {"key" => record["hostname"]+".loadavg-short", "gauge" => record["dstat"]["load avg"]["1m"].to_f*100 }
</store>
<store>
type map
tag "map.dstat.cpu-usr"
time time
record {"key" => record["hostname"]+".cpu-usr", "gauge" => record["dstat"]["total cpu usage"]["usr"] }
</store>
<store>
type map
tag "map.dstat.cpu-sys"
time time
record {"key" => record["hostname"]+".cpu-sys", "gauge" => record["dstat"]["total cpu usage"]["sys"] }
</store>
<store>
type map
tag "map.dstat.cpu-hiq"
time time
record {"key" => record["hostname"]+".cpu-hiq", "gauge" => record["dstat"]["total cpu usage"]["hiq"] }
</store>
<store>
type map
tag "map.dstat.cpu-siq"
time time
record {"key" => record["hostname"]+".cpu-siq", "gauge" => record["dstat"]["total cpu usage"]["siq"] }
</store>
<store>
type map
tag "map.dstat.net-recv"
time time
record {"key" => record["hostname"]+".net-recv", "gauge" => record["dstat"]["net/total"]["recv"] }
</store>
<store>
type map
tag "map.dstat.net-send"
time time
record {"key" => record["hostname"]+".net-send", "gauge" => record["dstat"]["net/total"]["send"] }
</store>
</match>
<match map.dstat.*>
type graphite
host 監視サーバのアドレス
port 2003
key_prefix dstat
flush_interval 5s
</match>