< この記事をシェア >
muninにてMySQL関連を監視項目に追加する方法です。

muninが元から持っているプラグインで使用できるmysql周りのものは↓になります。
・MySQL Connections
・MySQL queries
・MySQL Queries in cache
・MySQL slow queries
・MySQL threads
・MySQL throughput
また↑に加え、mysql_qcacheやmysql_connectionsを追加したい場合はgithubにお世話になります。
munin備え付けのMysql監視プラグインを追加
といってもmuninでmysql監視やるぞーという意味でpluginsフォルダ下にあるmysql関連のものをリンクしてやるだけです。
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_commands
ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_slow
ln -s /usr/share/munin/plugins/mysql_bytes /etc/munin/plugins/mysql_bytes
ln -s /usr/share/munin/plugins/mysql_innodb /etc/munin/plugins/mysql_innodb
ln -s /usr/share/munin/plugins/mysql_isam_space_ /etc/munin/plugins/mysql_isam_space_
ln -s /usr/share/munin/plugins/mysql_queries /etc/munin/plugins/mysql_queries
ln -s /usr/share/munin/plugins/mysql_slowqueries /etc/munin/plugins/mysql_slowqueries
ln -s /usr/share/munin/plugins/mysql_threads /etc/munin/plugins/mysql_threads
qcache、mem、connectionsを追加する
こっちはgithubから持ってきてリンクします。
cd /usr/share/munin/plugins
wget https://raw.github.com/munin-monitoring/contrib/master/plugins/mysql/mysql_qcache
wget https://raw.github.com/munin-monitoring/contrib/master/plugins/mysql/mysql_qcache_mem
wget https://raw.github.com/munin-monitoring/contrib/master/plugins/mysql/mysql_connections
ln -s /usr/share/munin/plugins/mysql_qcache /etc/munin/plugins/mysql_qcache
ln -s /usr/share/munin/plugins/mysql_qcache_mem /etc/munin/plugins/mysql_qcache_mem
ln -s /usr/share/munin/plugins/mysql_connections /etc/munin/plugins/mysql_connections
プラグインファイル(munin-node)の修正
最後に
vi /etc/munin/plugin-conf.d/munin-node
munin-nodeのプラグインファイルに↓を追加します。
[mysql_*]
env.mysqlopts -u 【ユーザー名】 -p【パスワード】
env.mysqladmin /usr/bin/mysqladmin
env.mysqlconnection DBI:mysql:mysql;host=127.0.0.1;port=3306
env.mysqluser 【ユーザー名】
env.mysqlpassword 【パスワード】
MySQLのユーザー名、パスワード、ポート、ホストを指定する必要があります。
ポートがデフォルトで自分がMySQLを持っているDBサーバーなのでここではhost=127.0.0.1;port=3306としています。
↑どちらの設定も完了後はmunin-nodeを再起動する必要があります。
/etc/init.d/munin-node restart
できあがりはこんな感じ

munin監視が実行された後、muninのUI上にmysqlの項目が登場しているのがわかります。

ちゃんとグラフも生成されています。
muninのMysql監視を入れておけば、DBサーバーとして動いているサーバーの監視もラクチンになるので設定しておきましょー
< この記事をシェア >
\\どうかフォローをお願いします…//
このmuninでDBサーバー(MySQL)の監視を行う設定方法の最終更新日は2014年8月22日です。
記事の内容に変化やご指摘がありましたら問い合わせフォームまたはusedoorのTwitterまたはusedoorのFacebookページよりご連絡ください。