LoginSignup
4
5

More than 5 years have passed since last update.

Unicornの監視

Posted at

監視っつってもいろいろあるが、まずは最低限として、メモリ使用量を。
ついでにワーカープロセス数も同じ手順でできるのでこれも。

ここではmuninを利用してる前提とする。他の監視ツール使ってるところは・・・がんばって。

手順

こいつを使うので、clone

user$
sudo su
root#
cd
git clone --depth 1 https://github.com/munin-monitoring/contrib.git munin-contrib

unicornのプラグインは2セットあって、

  • unicorn_
    • ps | grep unicornって感じで計測するので、複数アプリが1サーバに相乗りしてる場合は合計になる
  • unicorn_memory_statusunicorn_status
    • ちとめんどいけど、アプリごとに集計できる

今回は後者使う。複数アプリ相乗り前提で。

インストール。

root#
cp munin-contrib/plugins/unicorn/unicorn_{memory_,}status /usr/share/munin/plugins/

有効化。ここではmyappという名前のアプリのつもりでコマンド書くので、適宜書き換えを。

root#
cd /etc/munin/plugins
ln -s /usr/share/munin/plugins/unicorn_memory_status unicorn_memory_status_myapp
ln -s /usr/share/munin/plugins/unicorn_status unicorn_status_myapp

設定。

root#
vi /etc/munin/prugin-conf.d/unicorn
/etc/munin/prugin-conf.d/unicorn
[unicorn_memory_status_myapp]
  env.rails_root /path/to/myapp/current
[unicorn_status_myapp]
  env.rails_root /path/to/myapp/current

もちろん各自のアプリケーションのパスを書くこと。Capistrano使ってるならcurrentまで下る。

再起動。munin設定のあるある罠(再起動忘れ)はきちんと回避。

root#
systemctl restart munin-node

あとがき

CPUの監視だれか

4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5