サーバ監視ツール「munin」の使い方 ~ その3 ~ [2012/4/5]
前回の記事はこちら↓
サーバ監視ツール「munin」の使い方 ~ その1 ~
サーバ監視ツール「munin」の使い方 ~ その2 ~

今回は
前回のApacheやMySQLの監視でWebやDBの利用状況もグラフ化することができました。
利用状況や、混んでいる時間がだいぶ見やすくなりました。今回はNagiosとの棲み分けについてと、今後ますます、使われることが増えていくであろう、MySQLのストレージエンジンであるinnoDBと、分散データベースCassandraもMuninで状況を記録してみたいと思います。
MuninとNagios
Muninはメトリクス収集ツールです。その1でも触れましたが自動車のメーターやボイスレコーダーのように、起きたことを記録する用途のシステムです。Muninからも通知を飛ばすことはできますが、起きたことを異常とみなして人間に通知するのは別のそれ専用のソフトを使った方がいいです。Muninと監視&通知システムとして有名なNagios(ナギオス)と比較してみましょう。
| Munin | Nagios | |
|---|---|---|
| グラフ作成 | ○ | × |
| 通知 | ○ | ○ |
| 通知の細かい設定 | × | ○ |
| 管理画面 | × | ○ |
やることは似ています。が、Muninはメトリクス収集システム、Nagiosはアラート機能の付いた監視ツールで別物です。この二つは合わせて使うといいです。サウナ室にたとえて言うと、muninは温度計、Nagiosは非常ベルの働きをします。要は両方必要です。
※MuninとNagiosの連携もできるようですが、こちらは機会があれば紹介したいと思います。
innodb
MySQL コマンド、InnoDB Buffer Pool、InnoDB IO、InnoDB Log、InnoDB Transactions、Select types、Table locksなどが記録できます。
ライブラリをインストールする
1 2 3 | # yum install mysql-devel ※これが入っていないと以下のperl-DBD-MySQLがインストール失敗します。 # yum install --enablerepo=epel perl-IPC-ShareLite perl-Cache-Cache perl-Cache perl-DBD-MySQL |
シンボリックリンクを張る
1 2 3 4 5 6 7 | # ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_commands # ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_innodb_bpool # ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_innodb_io # ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_innodb_log # ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_innodb_tnx # ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_select_types # ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_table_locks |
権限を調整
※前回の設定よりさらに権限が必要です。
1 2 3 | mysql> GRANT ALL ON *.* TO munin@"localhost"IDENTIFIED BY "password"; FLUSH PRIVILEGES; |
設定ファイルにMySQLのログイン情報を記述する
1 2 3 4 5 6 | # vi /etc/munin/plugin-conf.d/munin-node ※以下記述例 [mysql*] env.mysqlconnection DBI:mysql:mysql;host=localhost;port=3306 env.mysqluser munin env.mysqlpassword password |
それぞれ動作テストをする
1 2 3 4 5 6 7 8 | # cd /etc/munin/plugins # /usr/sbin/munin-run mysql_commands # /usr/sbin/munin-run mysql_innodb_bpool # /usr/sbin/munin-run mysql_innodb_io # /usr/sbin/munin-run mysql_innodb_log # /usr/sbin/munin-run mysql_innodb_tnx # /usr/sbin/munin-run mysql_select_types # /usr/sbin/munin-run mysql_table_locks |
munin-nodeリスタート
1 | # /etc/init.d/munin-node restart;date |
グラフ例
うまくグラフが出ないときは
前回の「その他tips」のやり方で調べてみてください。
Cassandra
githubからダウンロード
https://github.com/jamesgolick/cassandra-munin-plugins/downloads
インストール
1 2 | # mkdir /usr/share/munin/plugins/cassandra-munin-plugins ※ここにソースをすべて置く # chmod 755 /usr/share/munin/plugins/cassandra-munin-plugins/jmx_ |
ポート確認
1 2 3 4 5 6 7 8 | # touch /usr/share/munin/plugins/cassandra-munin-plugins/.conf # grep JMX_PORT= /usr/local/apache-cassandra-1.0.8/conf/cassandra-env.sh ~結果(デフォルトなら、JMX_PORT="7199" ) # vi /etc/munin/plugin-conf.d/munin-node [jmx_*] env.jmxurl service:jmx:rmi:///jndi/rmi://localhost:7199/jmxrmi <h3>シンボリックリンクを張る</h3> <pre class="bash" style="font-family: monospace;">/usr/share/munin/plugins/cassandra-munin-plugins/*.conf |
にある*.confファイルの名前を以下の要領でリンク
1 2 3 4 5 6 7 8 9 10 | # cd /etc/munin/plugins # ln -s /usr/share/munin/plugins/cassandra-munin-plugins/jmx_ jmx_compactions_bytes # ln -s /usr/share/munin/plugins/cassandra-munin-plugins/jmx_ jmx_compactions_pending # ln -s /usr/share/munin/plugins/cassandra-munin-plugins/jmx_ jmx_flush_stage_pending # ln -s /usr/share/munin/plugins/cassandra-munin-plugins/jmx_ jmx_hh_pending # ln -s /usr/share/munin/plugins/cassandra-munin-plugins/jmx_ jmx_jvm_cpu # ln -s /usr/share/munin/plugins/cassandra-munin-plugins/jmx_ jmx_jvm_memory # ln -s /usr/share/munin/plugins/cassandra-munin-plugins/jmx_ jmx_ops_pending # ln -s /usr/share/munin/plugins/cassandra-munin-plugins/jmx_ jmx_storageproxy_latency # ln -s /usr/share/munin/plugins/cassandra-munin-plugins/jmx_ jmx_storageproxy_ops |
※上記のうち、Cassandraのバージョンによってはパラメータ名が微妙に変わって値が取れないものものあるので、注意
以下のstandard1は仮のKeyspace名なので、使いたいKeyspace名に置き換え(中身も)てリンク
1 2 3 4 5 6 | # ln -s /usr/share/munin/plugins/cassandra-munin-plugins/jmx_ jmx_standard1_keycache # ln -s /usr/share/munin/plugins/cassandra-munin-plugins/jmx_ jmx_standard1_latency # ln -s /usr/share/munin/plugins/cassandra-munin-plugins/jmx_ jmx_standard1_livesize # ln -s /usr/share/munin/plugins/cassandra-munin-plugins/jmx_ jmx_standard1_ops # ln -s /usr/share/munin/plugins/cassandra-munin-plugins/jmx_ jmx_standard1_rowcache # ln -s /usr/share/munin/plugins/cassandra-munin-plugins/jmx_ jmx_standard1_sstables |
munin-nodeリスタート
1 | # /etc/init.d/munin-node restart;date |
グラフ例
参考にさせていただきました
ウェブオペレーション――サイト運用管理の実践テクニック
https://github.com/
munin 楽々インストールでMySQLを監視する! | QuickKnowLedge
CassandraにPelopsでアクセスしてみた
http://www.techsutram.com/2011/03/dbdmysql-and-can-exec-no-such-file-or.html
https://www.centos.org/modules/newbb/viewtopic.php?topic_id=30319
次回
オリジナルでプラグインを作ってみることに挑戦したいと思います。
Munin関連の記事はこちら













