munin 2.0系の新機能として、CGIによって動的に生成することもできます。
以前は、5分毎にグラフが生成されていて監視ノードが多くなると、5分おきに負荷があがる懸念がありました
このグラフの動的生成を利用すると、muninのWEBページにアクセスがあるとグラフが生成されてるのでエコでサーバーの負荷も少なくなります
今回の手順は、前回に紹介したmunin 2.x系のインストール作業を済んでいる条件とします
munin 2.x系 インストール
munin.conf設定
htmlファイルもgraphを5分ごとのcronから、cgiで動的に生成に変更
# vi /etc/munin/munin.conf # graph_strategy cron, html_strategy cronをコメントアウト graph_strategy cron html_strategy cron # graph_strategy cgi, html_strategy cgiに変更 graph_strategy cgi html_strategy cgi
apache設定
動的生成の場合、Apacheのmod_rewrite機能をしようしているのでその設定をApacheに設定します、この設定では「munin.hoge.com」URLを使用しています
# vi /etc/httpd/conf/vhosts/hoge.conf
# munin.m-yabe.com
<VirtualHost xxx.xxx.xxxx.xxx:80>
ServerName munin.hoge.com
ServerAlias munin.hoge.com
ErrorLog logs/munin.hoge.com/munin_error.log
CustomLog logs/munin.hoge.com/munin_access.log common
DocumentRoot /var/www/html/munin/
ScriptAlias /munin-cgi/munin-cgi-graph /var/www/cgi-bin/munin-cgi-graph
ScriptAlias /munin-cgi/munin-cgi-html /var/www/cgi-bin/munin-cgi-html
# Rewrites
RewriteEngine On
# Static content in /static
RewriteRule ^/favicon.ico /var/www/html/munin/static/favicon.ico [L]
RewriteRule ^/static/(.*) /var/www/html/munin/static/$1 [L]
# HTML
RewriteCond %{REQUEST_URI} .html$ [or]
RewriteCond %{REQUEST_URI} =/
RewriteRule ^/(.*) /var/www/cgi-bin/munin-cgi-html/$1 [L]
# Images
RewriteRule ^/munin-cgi/munin-cgi-graph/(.*) /$1
RewriteCond %{REQUEST_URI} .png$
RewriteRule ^/(.*) /var/www/cgi-bin/munin-cgi-graph/$1 [L]
<Directory /var/www/html/munin/>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
# Ensure we can run (fast)cgi scripts
<Directory "/var/www/cgi-bin/">
Options +ExecCGI
<IfModule mod_fcgid.c>
SetHandler fcgid-script
</IfModule>
<IfModule !mod_fcgid.c>
SetHandler cgi-script
</IfModule>
</Directory>
</VirtualHost>
mod_fcgidをインストールします。インストールされている場合は不要です
# yum install mod_fcgid
apacheを再起動すると反映します
CentOS 6.x
# /etc/init.d/httpd restart
CentOS 7.x
# systemctl restart httpd
関連記事
munin 2.x系 インストール
munin 2.x インストール動的設定
munin でMariaDB(MySQL)の監視
(旧バージョン)
munin プラグイン追加 【apache】
munin インストール



コメント