鈍足ランナーのIT日記

走るのが好きな5流のITエンジニアのブログ。

趣味の範囲は広いけど、どれも中途半端なクソブロガー楽しめるWebアプリを作ってあっと言わせたい。サーバーサイドPerl(Mojolicious)、クライアントサイドVue.js。Arduinoにも触手を伸ばす予定。

GrowthForecastいれたので、fluentdをさくらVPSへインストールしなくては

宝の持ち腐れとなるので、Fluentdをインストールしなくては。 ググろう。

インストール

CentOS5+にtd-agentをyumでインストールする

CentOS6.2+fluentdインストール(yum版)

td-agentインストールしてみた

起動方法、プラグインのインストールについて

sudo /etc/init.d/td-agent {start|stop|reload|restart|condrestart|status|configtest}

fluent-plugin-dstat

fluent-plugin-dstatの紹介

cd /tmp
wget http://dag.wieers.com/home-made/dstat/dstat-0.7.2.tar.bz2
tar xvf dstat-0.7.2.tar.bz2
cd dstat-0.7.2
sudo cp dstat /usr/sbin
sudo /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-growthforecast fluent-plugin-map fluent-plugin-dstat

設定ファイルの書き方

dstatをfluentd + GrowthForecastで可視化する

sudo vi /etc/td-agent/td-agent.conf
以下追記してゆく

<source>
  type dstat
  tag dstat
  option -cm
  delay 3
</source>

# GrowthForecast用にメッセージを加工する
<match dstat>
  type copy

  # CPU関連の結果だけを取り出す
  <store> 
    type map
    tag "perf.cpu"
    time time
    record record['dstat']['total cpu usage']
  </store>

  # メモリ関連の結果だけを取り出す
  <store> 
    type map
    tag "perf.mem"
    time time
    record record['dstat']['memory usage']
  </store>
</match>

# GrowthForecastに転送する
<match perf.**>
   type growthforecast
   gfapi_url http://localhost:5125/api/
   service dstat
   tag_for section
   remove_prefix perf
   name_key_pattern .*
</match>

# 書き換えた後には、設定のリロード
sudo /etc/init.d/td-agent restart

結果

うまくいきました・・ありがとうございます。