Munin/設定
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
**設定 [#m16d0ae4]
稼働までにいくつか罠(はまりどころ)があるので、この順序が...
#contents
----
***munin-node.conf [#t92c534b]
ノードの設定と、デーモンの起動を先に完了させる。
変更点のみ。
ノードへの接続を許可するIPアドレスを正規表現で指定。
普通はマスターサーバのIPアドレスを指定する。
allow ^127\.0\.0\.1$
allow ^xxx\.xxx\.xxx\.xxx$
Net::CIDR導入済みなら
# cidr_allow 127.0.0.1/32
# cidr_allow 192.0.2.0/24
# cidr_deny 192.0.2.42/32
でコントロール可。
バインドアドレスを設定。マスター内ノードなら 127.0.0.1 ...
host 0.0.0.0
***プラグインのシンボリックリンク生成 [#ka6eed04]
/usr/local/munin/sbin/munin-node-configure --shell --fam...
で、大抵はよしなにしてくれる。
足りない物、余計な物はあとで手動変更。
プラグインは
/usr/local/munin/etc/plugins
に設定、
スクリプト実体は
/usr/local/munin/lib/plugins
にある。
中には古かったり環境に合わないスクリプトもあるので、
スクリプト自体に手を入れる必要も出てくる。
実体スクリプトは一つで、シンボリックリンク先の名前を変更...
アンダーバーで終わっていたり(mysql_など)、アンダーバーが...
そのようなスクリプトは
/usr/local/munin/lib/plugins/mysql_ suggest
と、suggest を引数にすると、アンダーバー以下に指定する文...
不足分や追加があり、手動変更するときの参考に。
表示されないものはスクリプトを読む('A`)
***環境変数ファイル作成 [#zfc59fac]
各プラグインで利用する環境変数を書いたファイルを作る。
場所は
/usr/local/munin/etc/plugin-conf.d/
ファイル名は何でも良い=存在すると読み込まれる
環境変数の内容については、
/usr/local/munin/bin/munindoc <スクリプト>
で、表示されるマニュアル内に大抵書いてある。
書いてない物、間違っている物もあるので注意が必要。
***ノードエージェント起動 [#c028224f]
後ほど動作確認で必要になるため、~
起動スクリプトを導入してサービス起動する。~
起動しないときは logs/munin-node.log を確認。Perlのモジュ...
なお、スクリプト自体がおかしい事もよくあるので、その際は...
***オーナー変更 [#sc0a2ccd]
ここから、マスターサーバの設定。
インストールディレクトリを/usr/local/muninとする。
以下のオーナーを変更する。
ただし、マスターサーバにノードも入っている場合は
var/munin-nodeを除外すること。
cd /usr/local/munin/var
chown munin.munin ./
※※※はまりポイント※※※
特に var/cgi-tmp はRRDToolsのPNG生成場所のため、muninユ...
デフォルト放置だと画像生成出来ず残念画面になる。
***munin.conf [#cecb2d00]
マスターサーバーの設定。
基本Makefile.configで指定する。
#dbdir /usr/local/munin/var
#htmldir /usr/local/munin/www/docs
#logdir /usr/local/munin/log
#rundir /usr/local/munin/var/run
#tmpldir /usr/local/munin/etc/templates
includedir /usr/local/munin/etc/munin-conf.d
#graph_period minute
graph_strategy cgi ←グラフ生成方法をcgiへ変更
#munin_cgi_graph_jobs 6
cgiurl_graph /cgi-bin/munin-cgi-graph ←cgiを指定
#max_graph_jobs 6
html_strategy cgi ←ページ生成方法をcgiへ変更
rrdcached_socket /var/run/munin/rrdcached.sock ←RRDTool...
通知先設定はまたそのうち。
#contact.someuser.command mail -s "Munin notification" s...
#contact.anotheruser.command mail -s "Munin notification...
#contact.nagios.command /usr/bin/send_nsca nagios.host.c...
# a simple host tree
[localhost]
address 127.0.0.1
use_node_name yes
# 各ノードでtelnet localhost 4949 → nodes で表示される名...
[hoge]
address xxx.xxx.xxx.xxx
use_node_name no
***/etc/hosts [#q163a1e2]
マスターサーバの hosts に、ノードのホスト名とIPアドレス...
hoge xxx.xxx.xxx.xxx
***rrdcached [#b82fdb16]
socketにはwebサーバのオーナー(daemon,nobody,apacheなど)...
・muninユーザで起動して
・グループをwebサーバのオーナーに変更する
という方針。
※-s オプションでグループオーナは変更出来るがオーナの変更...
動作確認用にフロントで動かす時は -g オプションを指定、
ベースディレクトリオプション -b には muninのvarディレク...
先にジャーナルやPIDファイルを置けるように適宜 mkdirやchm...
sudo -u munin /usr/local/rrdtools/bin/rrdcached \
-p /var/run/munin/rrdcached.pid \ ←PIDファイ...
-B -b /usr/local/munin/var \ ←ベースディ...
-F -j /var/run/munin/rrdcached-journal/ \ ←ジャーナル...
-m 0660 -l /var/run/munin/rrdcached.sock \ ←-m で権限...
-w 1800 -z 1800 -f 3600 \ ←-w で書込...
-g ←デーモンではなくフロントで実行
フロントでの確認作業時は別仮想端末からソケットのグループ...
chgrp nobody /var/run/munin/rrdcached.sock
最終的には起動スクリプト内でグループ変更する。
サンプルスクリプト類はRRDToolsの <source dir>/etc 以下に...
確認方法。
ノードが一つは動いていること。マスターサーバ内ノードが楽...
別仮想端末でマスターサーバにログインし
su - munin
/usr/local/munin/bin/munin-cron
とする。
/usr/local/munin/logs/munin-update.log に最初のデータが...
/usr/local/munin/var/以下のノードのディレクトリを確認す...
データが生成されていればよし。
***FastCGI設定 [#z77c1e99]
spawn-fcgiを利用するので用意する。EPELが楽。
spawn-fcgiの起動スクリプトをコピーして
munin-fcgi-graph
munin-fcgi-html
の二つを作成。sysconfig/spawn-fcgiも同様。
sysconfig以下のファイル内容を編集。
PID=/var/run/munin/fcgi-html.pid
SOCKET=/var/run/munin/fcgi-html.sock
OPTIONS="-u munin -g munin -U nobody -s $SOCKET -S -M 06...
ユーザはmuninで作成(-u -g)、のちnobodyへ変更(-U)。
起動スクリプトも適宜編集し、起動する。
※※※はまりポイント※※※
ノードのデータが無い時点では、起動してもすぐ落ちる。
なので、先のノードデータ取得とrrdcachedの確認をやってお...
最終的に上記のperlのプロセスが二つ上がっていればよし。
***Webサーバの設定 [#g8f0087d]
FastCGI前提のため、Apacheよりnginxの方が相性がよかろうと...
ここではnginxを利用する。~
http://munin.example.comのようなVirtualHost...
http://example.com/munin/のような標準的なディレク...
端折るとよくわからなくなるので、ひとまず全部載せ。
user nobody;
worker_processes 2;
error_log logs/error.log;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 10;
gzip on;
server {
listen 80;
server_name example.com;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
#### location定義は原則上から順に評価
location ~ /\.ht {
deny all;
}
#### Munin
location ^~ /munin-cgi/munin-cgi-graph/ {
access_log off;
#munin-cgi-graph に渡す環境変数PATH_INFOを抽...
fastcgi_split_path_info ^(/munin-cgi/munin-c...
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass unix:/var/run/munin/fcgi-graph....
include fastcgi_params;
}
location /munin/static/ {
alias /usr/local/munin/www/docs/static/;
}
location /munin/ {
alias /usr/local/munin/www/docs/;
#munin-cgi-html に渡す環境変数PATH_INFOを抽...
fastcgi_split_path_info ^(/munin)(.*);
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass unix:/var/run/munin/fcgi-html.s...
include fastcgi_params;
}
#### End of Munin
#### PHP Default
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_ro...
include fastcgi_params;
}
}
}
ページ自体表示されずに、エラーが502の場合はsocketに渡っ...
渡す内容(PATH_INFOの内容)がおかしい、socket自体おかしい...
nginxのerror_logを参照(情報量は少ない)。
グラフ画像が表示されない場合で、エラーが500の場合はrrdto...
muninのmunin-cgi-graph.logやmunin-update.logを参照。
トップページと先にテストしたノードのグラフが表示されれば...
***cron [#mc7d949d]
ノードデータのポーリング設定。~
上で上手く表示されているならだいたい大丈夫。~
あとは個別にログを見ながら修正する。
muninユーザーで5分間隔実行する。
/etc/cron.d/munin
#
# cron-jobs for munin
#
MAILTO=root
*/5 * * * * munin test -x /usr/local/munin/bin/munin-cro...
終了行:
**設定 [#m16d0ae4]
稼働までにいくつか罠(はまりどころ)があるので、この順序が...
#contents
----
***munin-node.conf [#t92c534b]
ノードの設定と、デーモンの起動を先に完了させる。
変更点のみ。
ノードへの接続を許可するIPアドレスを正規表現で指定。
普通はマスターサーバのIPアドレスを指定する。
allow ^127\.0\.0\.1$
allow ^xxx\.xxx\.xxx\.xxx$
Net::CIDR導入済みなら
# cidr_allow 127.0.0.1/32
# cidr_allow 192.0.2.0/24
# cidr_deny 192.0.2.42/32
でコントロール可。
バインドアドレスを設定。マスター内ノードなら 127.0.0.1 ...
host 0.0.0.0
***プラグインのシンボリックリンク生成 [#ka6eed04]
/usr/local/munin/sbin/munin-node-configure --shell --fam...
で、大抵はよしなにしてくれる。
足りない物、余計な物はあとで手動変更。
プラグインは
/usr/local/munin/etc/plugins
に設定、
スクリプト実体は
/usr/local/munin/lib/plugins
にある。
中には古かったり環境に合わないスクリプトもあるので、
スクリプト自体に手を入れる必要も出てくる。
実体スクリプトは一つで、シンボリックリンク先の名前を変更...
アンダーバーで終わっていたり(mysql_など)、アンダーバーが...
そのようなスクリプトは
/usr/local/munin/lib/plugins/mysql_ suggest
と、suggest を引数にすると、アンダーバー以下に指定する文...
不足分や追加があり、手動変更するときの参考に。
表示されないものはスクリプトを読む('A`)
***環境変数ファイル作成 [#zfc59fac]
各プラグインで利用する環境変数を書いたファイルを作る。
場所は
/usr/local/munin/etc/plugin-conf.d/
ファイル名は何でも良い=存在すると読み込まれる
環境変数の内容については、
/usr/local/munin/bin/munindoc <スクリプト>
で、表示されるマニュアル内に大抵書いてある。
書いてない物、間違っている物もあるので注意が必要。
***ノードエージェント起動 [#c028224f]
後ほど動作確認で必要になるため、~
起動スクリプトを導入してサービス起動する。~
起動しないときは logs/munin-node.log を確認。Perlのモジュ...
なお、スクリプト自体がおかしい事もよくあるので、その際は...
***オーナー変更 [#sc0a2ccd]
ここから、マスターサーバの設定。
インストールディレクトリを/usr/local/muninとする。
以下のオーナーを変更する。
ただし、マスターサーバにノードも入っている場合は
var/munin-nodeを除外すること。
cd /usr/local/munin/var
chown munin.munin ./
※※※はまりポイント※※※
特に var/cgi-tmp はRRDToolsのPNG生成場所のため、muninユ...
デフォルト放置だと画像生成出来ず残念画面になる。
***munin.conf [#cecb2d00]
マスターサーバーの設定。
基本Makefile.configで指定する。
#dbdir /usr/local/munin/var
#htmldir /usr/local/munin/www/docs
#logdir /usr/local/munin/log
#rundir /usr/local/munin/var/run
#tmpldir /usr/local/munin/etc/templates
includedir /usr/local/munin/etc/munin-conf.d
#graph_period minute
graph_strategy cgi ←グラフ生成方法をcgiへ変更
#munin_cgi_graph_jobs 6
cgiurl_graph /cgi-bin/munin-cgi-graph ←cgiを指定
#max_graph_jobs 6
html_strategy cgi ←ページ生成方法をcgiへ変更
rrdcached_socket /var/run/munin/rrdcached.sock ←RRDTool...
通知先設定はまたそのうち。
#contact.someuser.command mail -s "Munin notification" s...
#contact.anotheruser.command mail -s "Munin notification...
#contact.nagios.command /usr/bin/send_nsca nagios.host.c...
# a simple host tree
[localhost]
address 127.0.0.1
use_node_name yes
# 各ノードでtelnet localhost 4949 → nodes で表示される名...
[hoge]
address xxx.xxx.xxx.xxx
use_node_name no
***/etc/hosts [#q163a1e2]
マスターサーバの hosts に、ノードのホスト名とIPアドレス...
hoge xxx.xxx.xxx.xxx
***rrdcached [#b82fdb16]
socketにはwebサーバのオーナー(daemon,nobody,apacheなど)...
・muninユーザで起動して
・グループをwebサーバのオーナーに変更する
という方針。
※-s オプションでグループオーナは変更出来るがオーナの変更...
動作確認用にフロントで動かす時は -g オプションを指定、
ベースディレクトリオプション -b には muninのvarディレク...
先にジャーナルやPIDファイルを置けるように適宜 mkdirやchm...
sudo -u munin /usr/local/rrdtools/bin/rrdcached \
-p /var/run/munin/rrdcached.pid \ ←PIDファイ...
-B -b /usr/local/munin/var \ ←ベースディ...
-F -j /var/run/munin/rrdcached-journal/ \ ←ジャーナル...
-m 0660 -l /var/run/munin/rrdcached.sock \ ←-m で権限...
-w 1800 -z 1800 -f 3600 \ ←-w で書込...
-g ←デーモンではなくフロントで実行
フロントでの確認作業時は別仮想端末からソケットのグループ...
chgrp nobody /var/run/munin/rrdcached.sock
最終的には起動スクリプト内でグループ変更する。
サンプルスクリプト類はRRDToolsの <source dir>/etc 以下に...
確認方法。
ノードが一つは動いていること。マスターサーバ内ノードが楽...
別仮想端末でマスターサーバにログインし
su - munin
/usr/local/munin/bin/munin-cron
とする。
/usr/local/munin/logs/munin-update.log に最初のデータが...
/usr/local/munin/var/以下のノードのディレクトリを確認す...
データが生成されていればよし。
***FastCGI設定 [#z77c1e99]
spawn-fcgiを利用するので用意する。EPELが楽。
spawn-fcgiの起動スクリプトをコピーして
munin-fcgi-graph
munin-fcgi-html
の二つを作成。sysconfig/spawn-fcgiも同様。
sysconfig以下のファイル内容を編集。
PID=/var/run/munin/fcgi-html.pid
SOCKET=/var/run/munin/fcgi-html.sock
OPTIONS="-u munin -g munin -U nobody -s $SOCKET -S -M 06...
ユーザはmuninで作成(-u -g)、のちnobodyへ変更(-U)。
起動スクリプトも適宜編集し、起動する。
※※※はまりポイント※※※
ノードのデータが無い時点では、起動してもすぐ落ちる。
なので、先のノードデータ取得とrrdcachedの確認をやってお...
最終的に上記のperlのプロセスが二つ上がっていればよし。
***Webサーバの設定 [#g8f0087d]
FastCGI前提のため、Apacheよりnginxの方が相性がよかろうと...
ここではnginxを利用する。~
http://munin.example.comのようなVirtualHost...
http://example.com/munin/のような標準的なディレク...
端折るとよくわからなくなるので、ひとまず全部載せ。
user nobody;
worker_processes 2;
error_log logs/error.log;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 10;
gzip on;
server {
listen 80;
server_name example.com;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
#### location定義は原則上から順に評価
location ~ /\.ht {
deny all;
}
#### Munin
location ^~ /munin-cgi/munin-cgi-graph/ {
access_log off;
#munin-cgi-graph に渡す環境変数PATH_INFOを抽...
fastcgi_split_path_info ^(/munin-cgi/munin-c...
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass unix:/var/run/munin/fcgi-graph....
include fastcgi_params;
}
location /munin/static/ {
alias /usr/local/munin/www/docs/static/;
}
location /munin/ {
alias /usr/local/munin/www/docs/;
#munin-cgi-html に渡す環境変数PATH_INFOを抽...
fastcgi_split_path_info ^(/munin)(.*);
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass unix:/var/run/munin/fcgi-html.s...
include fastcgi_params;
}
#### End of Munin
#### PHP Default
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_ro...
include fastcgi_params;
}
}
}
ページ自体表示されずに、エラーが502の場合はsocketに渡っ...
渡す内容(PATH_INFOの内容)がおかしい、socket自体おかしい...
nginxのerror_logを参照(情報量は少ない)。
グラフ画像が表示されない場合で、エラーが500の場合はrrdto...
muninのmunin-cgi-graph.logやmunin-update.logを参照。
トップページと先にテストしたノードのグラフが表示されれば...
***cron [#mc7d949d]
ノードデータのポーリング設定。~
上で上手く表示されているならだいたい大丈夫。~
あとは個別にログを見ながら修正する。
muninユーザーで5分間隔実行する。
/etc/cron.d/munin
#
# cron-jobs for munin
#
MAILTO=root
*/5 * * * * munin test -x /usr/local/munin/bin/munin-cro...
ページ名: