Chinachu のダッシュボードに新たにサーバー監視を出来るように自分で追加してみる。 線形代数死ね
Muninとは
サーバのさまざまな情報をグラフ化して表示するソフトです。 同じようなものにcactiとかZabbixとかがありますが、Muninはとても手軽。 温度監視は出来ませんがlm-sensorsとプラグインを使うことで可能になる。
Muninとlm-sensorsをインストールする
【Debian系】
[source]
apt-get install munin
apt-get install lm-sensors
[/source]
【RedHat系】
[source]
yum install munin
yum install lm_sensors
[/source]
【共通】
[source] //lm sensorsの設定
sensors-detect //全部Enterでいい
//プラグインを有効にする
ln -s /usr/share/munin/plugins/sensors_ /etc/munin/plugins/sensors_fan
ln -s /usr/share/munin/plugins/sensors_ /etc/munin/plugins/sensors_volt
ln -s /usr/share/munin/plugins/sensors_ /etc/munin/plugins/sensors_temp
//自動起動をonにする
chkconfig munin-node on //Debian系は忘れた。
//muninのグラフ画像を保存するディレクトリを作る
mkdir ~/chinachu/web/munin
[/source]
muninのグラフ画像をコピーするスクリプトをcronで5分おきに設定
[bash]
!/bin/bash
LANG=C PNGDIR=/var/cache/munin/www/localdomain/localhost.localdomain WEBDIR=$HOME/chinachu/web
cp -f ${PNGDIR}/*-day.png ${WEBDIR}/munin/
exit 0 [/bash]
これをどっかに保存してcronで設定して実行権限を
[source] chmod u+x munin.sh [/source]
[source]
crontab -e
0-59/5 * * * * /home/chinachu/chinachu/web/munin/munin.sh [/source]
Chinachuのstatus.jsを書き換える
[php]
vi ~/chinachu/web/page/dashboard/status.js
if (global.chinachu.status.operator.alive === true) { new sakura.ui.Alert({ title : 'Munin', type : 'green', body : '<br clear="all" /><div style="float: left;margin: 5px 0px 0px 5px;"><img src="../munin/cpu-day.png" /></div><div style="float: left;margin: 5px 0px 0px 5px;"><img src="../munin/memory-day.png" /></div><div style="float: left;margin: 5px 0px 0px 5px;"><img src="../munin/sensors_temp-day.png" /></div><br clear="all" />', disableClose: true }).render(this.view.content);
service chinachu-operator restart
service chinachu-wui restart //こっちだけでいいと思う
[/php]
こんな感じにすると
こんな感じになる。