今回はmunin-nodeパッケージをインストールすれば作成されるプラグインの中からApache関連のプラグインをインストール、有効にして、グラフ生成されることを確認するところまで行います。
/usr/share/munin/plugins
ディレクトリにあるプラグインを使いたい場合は、該当のプラグインファイルを/etc/munin/pluginsディレクトリにシンボリックリンクを作成し、munin-nodeサービスを再起動することでプラグインを有効にすることが出来ます。
## シンボリックリンクの作成
ln -s /usr/share/munin/plugins/apache_accesses /etc/munin/plugins/
ln -s /usr/share/munin/plugins/apache_processes /etc/munin/plugins/
ln -s /usr/share/munin/plugins/apache_volume /etc/munin/plugins/
## munin-nodeサービス再起動
service munin-node restart
## munin-cronの手動実行
sudo -u munin /usr/bin/munin-cron
ここで言いたいことは、サブタイトルで既に伝えちゃいましたね。でも話させてください!
まず、munin-nodeパッケージのインストールで入るApache関連プラグインは3つあります。
# ls -l /usr/share/munin/plugins/apache_*
-rwxr-xr-x 1 root root 4375 12月 8 16:23 2013 /usr/share/munin/plugins/apache_accesses
-rwxr-xr-x 1 root root 5757 12月 8 16:23 2013 /usr/share/munin/plugins/apache_processes
-rwxr-xr-x 1 root root 4320 12月 8 16:23 2013 /usr/share/munin/plugins/apache_volume
3つのプラグインともにperlスクリプトで、以下のコードが記述されています。
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://127.0.0.1:%d/server-status?auto";
このコード見れば想像できますが、Apache関連プラグインで各種ステータス値を取得するためには mod_statusモジュール を有効にする必要があります。
mod_statusモジュールが有効でない場合では値が取得できないことを確認します。
munin-nodeパッケージでインストールされる/usr/sbin/munin-runコマンドは、引数に任意のプラグイン名を指定することでmunin-nodeで実行した時と同じ結果を標準出力に出すことができます。
# /usr/sbin/munin-run apache_processes
busy80.value U
idle80.value U
free80.value U
結果がUなので値が取れていないことが分かります。
そこでmod_statusを有効にします。今回は検証サーバなのでAllowディレクティブでall指定ですが、本番環境などの場合はアクセスを許可するホストを限定したほうがいいこともありますのでお気をつけください。
LoadModule status_module modules/mod_status.so
<IfModule mod_status.c>
ExtendedStatus On
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from all
</Location>
</IfModule>
Apacheを再起動します。
service httpd configtest
service httpd restart
/usr/sbin/munin-run
コマンドを再度実行します。
# /usr/sbin/munin-run apache_processes
busy80.value 1
idle80.value 10
free80.value 245
おぉぉーーー!!
値が取れました!!
/usr/sbin/munin-runコマンドで正常に値を取得できるようになれば、http:// <IPアドレス>/munin/にアクセスするとApacheの各種グラフのページが表示されるはずです。
以上がMuninのApache関連プラグインの導入方法です。
次回はMySQL関連プラグインの導入方法です。
Perl |
3
|
Linux |
16
|
Jenkins |
1
|
CI |
1
|
Bashシェル |
1
|
シェルスクリプト |
1
|
Munin |
7
|
Ruby on Rails |
7
|
plenv |
1
|
sudo |
2
|
Cobbler |
6
|
ruby |
1
|
rbenv |
1
|
WeeChat |
1
|
tmux |
2
|
Webistrano |
1
|
capistrano |
1
|
puppet |
8
|
growthforecast |
1
|
Supervisor |
1
|
perlbrew |
1
|
git |
2
|
Python |
1
|
pip |
1
|
PHP |
1
|
Nginx |
1
|
MySQL |
2
|
LXC |
2
|
RPM |
3
|
ImageMagick |
1
|
Subversion |
1
|
qmail |
3
|
yum |
1
|
ucspi-tcp |
1
|
daemontools |
1
|
Puppet |
1
|
IPVS |
1
|
Kickstart |
1
|
aaa |
0
|