サーバの性能を監視するためにmuninを導入する。
様々なデータをグラフ化することができ、しきい値を超えるとアラーとメールを送信するなどが可能。
ServersMan@VPSがどの程度の性能で動いているのか、他のVPSによって性能劣化が生じないのかを見れるかも。
まずはrrdtool-1.4.xを導入する。
下記のパッケージが必要になる。
・cairo
・cairo-devel
・libxml2
・libxml2-devel
・pango
・pango-devel
依存関係のあるパッケージがたくさんあるが気にせずインストールする。
# yum install cairo cairo-devel libxml2 libxml2-devel pango pango-devel
rrdtoolをインストールする。
$ wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.4.tar.gz $ tar xvzf rrdtool-1.4.4.tar.gz $ cd rrdtool-1.4.4 $ ./configure --prefix=/usr/local/rrdtool --enable-perl-site-install $ make # paco -D make install
muninに必要なPerlモジュールをインストールしていく。
・perl-Net-SSLeay (base)
・perl-URI(base)
・perl-MD5 (dag)
・perl-HTML-Template (dag)
・perl-Params-Validate (dag)
・perl-TimeDate (dag)
・perl-Log-Log4perl (dag)
・Time::HiRes (cpan)
・Getopt::Long (cpan)
・Storable (cpan)
・Text::Balanced (cpan)
munin用のユーザを作成する。
# /usr/sbin/groupadd -g 200 munin # /usr/sbin/useradd -u 200 -g 200 -s /sbin/nologin munin
muninをダウンロードしてインストールする。
$ wget munin $ tar xvzf xvzf munin-2.0-alpha1.tar.gz $ cd munin-2.0-alpha1
makeファイルを編集する。
Makefile.config
PREFIX = $(DESTDIR)/usr/local/munin CONFDIR = $(DESTDIR)/etc/munin HTMLDIR = /var/www/kaju.jp/htdocs/munin CGIDIR = /var/www/kaju.jp/cgi-bin/munin DBDIR = $(DESTDIR)/var/lib/munin LOGDIR = $(DESTDIR)/var/log/munin
いよいよmuninのインストール。
・Manager # paco -D make install ・Agent # paco -D make install-common-prime install-node-prime install-plugins-prime
Managerの設定。
各AgentのIPアドレスを登録していく。
/etc/munin/munin.conf
# a simple host tree [kaju.jp] address 127.0.0.1 use_node_name yes
Managerは各Agentに接続し情報を収集する。
Manager自体はcronで起動される。
/etc/crontab
*/5 * * * * munin test -x /usr/local/munin/bin/munin-cron && /usr/local/munin/bin/munin-cron
ログにエラーが出ていないことを確認しておく。
Nov 7 05:00:01 bruna crond[28611]: (munin) CMD (test -x /usr/local/munin/bin/munin-cron && /usr/local/munin/bin/munin-cron)
引き続きAgentの設定をする。
ManagerとAgentが同一サーバなのでAgentはlocalhostとのみでLISTENするようにしておく。
/etc/munin/munin-node.conf
# Set this if the client doesn't report the correct hostname when # telnetting to localhost, port 4949 # host_name kaju.jp # Which address to bind to; #host * host 127.0.0.1
Agentの起動スクリプトをテンプレートからコピーする。
# cp dists/redhat/munin-node.rc /etc/rc.d/init.d/munin # /sbin/chkconfig --add munin # /sbin/chkconfig --list munin munin 0:off 1:off 2:on 3:on 4:on 5:on 6:off # /sbin/service munin start Starting Munin Node: [ OK ]
起動確認。
# ps aux |grep munin root 11713 0.0 1.1 9144 5948 ? Ss 18:10 0:00 /usr/local/munin/sbin/munin-node # netstat -an |less Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 127.0.0.1:4949 0.0.0.0:* LISTEN # cat /var/log/munin/munin-node.log Process Backgrounded 2010/09/15-18:10:54 Munin::Node::Server (type Net::Server::Fork) starting! pid(11713) Using default listen value of 128 Binding to TCP port 4949 on host 127.0.0.1 Setting gid to "0 0"
muninで監視したいプラグインを有効にする。
・自動 # /usr/local/munin/sbin/munin-node-configure --shell --families=auto,contrib |sh -x ・手動 # ln -s /usr/local/munin/lib/plugins/cpu /etc/munin/plugins/cpu
プラグインの動作確認。
# /usr/local/munin/sbin/munin-run --servicedir /etc/munin/plugins cpu user.value 53160 nice.value 0 system.value 8722 idle.value 76199051 iowait.value 3178 irq.value 0 softirq.value 0 steal.value 0
これでmuninが動作しサーバのデータ収集を開始する。
念のため各種ログでエラーが出ていないことを確認しておく。
# cat /var/log/munin/munin-update.log 2010/09/15 18:55:01 Opened log file 2010/09/15 18:55:01 [INFO]: Starting munin-update 2010/09/15 18:55:11 [INFO] Reaping Munin::Master::UpdateWorker<jp;kaju.jp>. Exit value/signal: 18/0 2010/09/15 18:55:11 [INFO]: Munin-update finished (10.13 sec) # cat /var/log/munin/munin-html.log 2010/09/16 10:00:07 Opened log file 2010/09/16 10:00:07 [INFO] Starting munin-html, getting lock /var/run/munin/munin-html.lock 2010/09/16 10:00:07 [INFO] Process 44313 is dead, stealing lock, removing file 2010/09/16 10:00:07 [INFO] Releasing lock file /var/run/munin/munin-html.lock 2010/09/16 10:00:07 [INFO] munin-html finished (0.40 sec) # cat /var/log/munin/munin-graph.log 2010/09/16 10:00:00 Opened log file 2010/09/16 10:00:00 Starting munin-graph 2010/09/16 10:00:00 Munin-graph finished (0.08 sec) 2010/09/16 10:00:04 Graphed service : if_err_venet0 (3.58 sec for 4 graphs) # cat /var/log/munin/munin-limits.log 2010/09/15 18:55:12 Opened log file 2010/09/15 18:55:12 [INFO] Starting munin-limits, getting lock /var/run/munin/munin-limits.lock 2010/09/15 18:55:12 [INFO] munin-limits finished (0.00 sec)
あとはブラウザで出力先に指定したディレクトリにアクセスすればOK。
【エラー情報1】
Agent起動時に下記のエラーが出た場合はmunin-node.confのhost_nameを設定する。
# tail /var/log/munin/munin-node.log Use of uninitialized value in scalar assignment at /usr/lib/perl5/site_perl/5.8.8/Munin/Node/Service.pm line 74.
【エラー情報2】
munin-cron起動時に下記のエラーが出た場合はURI.pmがないのでperl-URIをインストールする。
Can't locate URI.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/Node.pm line 63. BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/Node.pm line 63. Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/UpdateWorker.pm line 17. BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/UpdateWorker.pm line 17. Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/Update.pm line 17. BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/Update.pm line 17. Compilation failed in require at /usr/local/munin/lib/munin-update line 13. BEGIN failed--compilation aborted at /usr/local/munin/lib/munin-update line 13.
【エラー情報3】
munin-cron起動時に下記のエラーが出た場合はRRDs.pmがないのでRRDToolのconfigureオプションに–enable-perl-site-installを付ける。
Can't locate RRDs.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/Utils.pm line 22. BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/Utils.pm line 22. Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/UpdateWorker.pm line 18. BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/UpdateWorker.pm line 18. Compilation failed in require at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/Update.pm line 17. BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Munin/Master/Update.pm line 17. Compilation failed in require at /usr/local/munin/lib/munin-update line 13. BEGIN failed--compilation aborted at /usr/local/munin/lib/munin-update line 13.
コメント