「Munin」の版間の差分
細 (誤字) |
(同期) |
||
| (5人の利用者による、間の7版が非表示) | |||
| 1行目: | 1行目: | ||
| − | [[Category: |
+ | [[Category:システムモニタ]] |
[[en:Munin]] |
[[en:Munin]] |
||
[http://munin-monitoring.org/ プロジェクトウェブページ] より: |
[http://munin-monitoring.org/ プロジェクトウェブページ] より: |
||
| 5行目: | 5行目: | ||
:''Munin'' はコンピュータに何があったのか調べる事ができるモニタリングツールです。調べた全ての情報をウェブインターフェースを介して表示する事ができます。インストールが完了した後は、沢山のモニタリングプラグインたちがあなたに代わって仕事をしてくれる事でしょう。 |
:''Munin'' はコンピュータに何があったのか調べる事ができるモニタリングツールです。調べた全ての情報をウェブインターフェースを介して表示する事ができます。インストールが完了した後は、沢山のモニタリングプラグインたちがあなたに代わって仕事をしてくれる事でしょう。 |
||
| − | :Munin を使えばネットワーク、SAN、アプリケーション、気象状況等による計算機の性能評価が簡単になります。性能の問題について「おや、この日は何が違ったのかな |
+ | :Munin を使えばネットワーク、SAN、アプリケーション、気象状況等による計算機の性能評価が簡単になります。性能の問題について「おや、この日は何が違ったのかな?」とか簡単に分かるようになります。リソース毎の過不足を簡単に判断できるようになるでしょう。 |
| − | :Munin は優れた [http://oss.oetiker.ch/rrdtool/ RRDTool] (著 Tobi Oetiker) と Perl で書かれたフレームワーク、それと様々な言語で書かれたプラグインたちによって構成されています。Munin は マスター/ノード アーキテクチャー を採っていて、マスターが全てのノードに対し定期的にデータ収集を行います。データは RRDファイル に記録され、必要に応じてグラフを更新します。とりあえずの目標としてプラグイン |
+ | :Munin は優れた [http://oss.oetiker.ch/rrdtool/ RRDTool] (著 Tobi Oetiker) と Perl で書かれたフレームワーク、それと様々な言語で書かれたプラグインたちによって構成されています。Munin は マスター/ノード アーキテクチャー を採っていて、マスターが全てのノードに対し定期的にデータ収集を行います。データは RRDファイル に記録され、必要に応じてグラフを更新します。とりあえずの目標としてプラグイン(グラフ)を自在に扱える様になりましょう。 |
と、いうわけで、 Munin はシステムの統計を採りグラフに図示してくれるものです。詳しくはオスロ大学の [http://munin.ping.uio.no/ Munin install] など見ると良いでしょう。 |
と、いうわけで、 Munin はシステムの統計を採りグラフに図示してくれるものです。詳しくはオスロ大学の [http://munin.ping.uio.no/ Munin install] など見ると良いでしょう。 |
||
| − | == インストール |
+ | == インストール == |
| + | マスター機には {{Pkg|munin}} パッケージを、監視したい各デバイスには {{Pkg|munin-node}} を[[インストール]]してください。 |
||
| − | Munin はクライアント−サーバーモデルです。クライアントを munin-node 、サーバーを munin と称します(ドキュメントでは "munin-master"となっていたりもするけど)。 |
||
| + | マスター機自身を監視対象とする場合は、両方のパッケージを同じマシンにインストールすることも可能です。 |
||
| − | munin-master は1台のマシンにインストールし、 munin-node は監視したい全てのマシンにインストールします。ここでは、とりあえず1台のマシンについてのみインストールする事を考えてみるとしましょう。より詳しく知りたいのならば [http://munin-monitoring.org/wiki/Documentation Munin documentation wiki] を見ましょうね。 |
||
| + | さらに詳しいドキュメントは、[https://munin-monitoring.org/wiki/Documentation Munin ドキュメント Wiki] にあります。 |
||
| − | === munin と munin-node について === |
||
| − | |||
| − | 執筆現在に於いて munin (munin-master) と munin-node は extra リポジトリにパッケージがあります。 |
||
| − | |||
| − | ==== パッケージの確認 ==== |
||
| − | |||
| − | # pacman -Ss munin |
||
| − | |||
| − | extra/munin 1.4.6-2 |
||
| − | A distributed monitoring/graphing tool |
||
| − | extra/munin-node 1.4.6-2 |
||
| − | A distributed monitoring/graphing tool |
||
| − | |||
| − | ==== インストール ==== |
||
| − | |||
| − | # pacman -S munin munin-node |
||
| − | |||
| − | === ウェブサーバーの必要性について === |
||
| − | |||
| − | このガイドでは Munin で静的な HTML とグラフ画像を設定されたディレクトリへ出力する様にセットアップを行います。生成されたファイルはローカルのブラウザからならそのまま見ることも出来るでしょう。しかし、もしリモートのマシンから見たいのならば適当なウェブサーバーを予めセットアップしておく必要があります。例えば、 |
||
| − | |||
| − | *[[LAMP|Apache]] |
||
| − | *[[Lighttpd]] |
||
| − | *[[Nginx]] |
||
| − | |||
| − | などなど。他にサーバーについては詳しく知りたければ[[:Category:ウェブサーバー|ウェブサーバーカテゴリ]]も参考になるかもしれません。 |
||
| − | |||
| − | === IPv6 === |
||
| − | |||
| − | munin-node で IPv6 をサポートするには ({{ic|/etc/munin/munin-node.conf}} で {{ic|host :::1}} を使う) 以下のパッケージをインストールする必要があります: |
||
| − | |||
| − | *{{Pkg|perl-socket6}} |
||
| − | *{{Pkg|perl-io-socket-inet6}} |
||
== 設定 == |
== 設定 == |
||
| − | === |
+ | === Munin master === |
| + | ==== ディレクトリ ==== |
||
| − | デーモンを追加して |
||
| + | ''munin-master'' が生成する HTML やグラフ画像を書き込むためのディレクトリを作成します。このディレクトリには、munin ユーザーが書き込み権限を持っている必要があります。 |
||
| − | # systemctl enable munin-node |
||
| + | 以下の例では {{ic|/srv/http/munin}} を使用しています。Webサーバーがインストールされて起動していれば、生成された出力は [http://localhost/munin/ http://localhost/munin/] で閲覧できます: |
||
| − | 起動して置きましょう |
||
| − | |||
| − | # systemctl start munin-node |
||
| − | |||
| − | 詳しくは[[デーモン]]を見て下さい。 |
||
| − | |||
| − | === プラグイン === |
||
| − | |||
| − | {{ic|munin-node-configure}} を実行しましょう。{{ic|--suggest}} オプションを付けると、インストールしたマシンで使えそうなプラグインのお勧めリストが表示されます: |
||
| − | |||
| − | # munin-node-configure --suggest |
||
| − | |||
| − | 使用したいプラグインがあれば、もう一度コマンドを実行します。{{ic|--shell}} オプションを付けると {{ic|munin-node-configure}} によってお勧めされたプラグインが設定されるでしょう: |
||
| − | |||
| − | # munin-node-configure --shell | sh |
||
| − | |||
| − | ==== SNMP について設定したい場合 ==== |
||
| − | |||
| − | 例えば SNMP サーバーが SERVER というホスト名で、 バージョン v2c 、 コミュニティ名 COMMUNITY で稼働している際は次の様にお勧めリストの確認を行います: |
||
| − | |||
| − | # munin-node-configure --suggest --snmp SERVER --snmpversion snmpv2c --snmpcommunity COMMUNITY |
||
| − | |||
| − | この結果をシェル用に出力し、その出力をシェルに渡すには次の様にします: |
||
| − | |||
| − | # munin-node-configure --shell --snmp SERVER --snmpversion snmpv2c --snmpcommunity COMMUNITY | sh |
||
| − | |||
| − | === ディレクトリ === |
||
| − | |||
| − | munin-master がHTMLやグラフ画像を生成する為のディレクトリを設定し、作成して於きましょう。 |
||
| − | |||
| − | {{ic|/etc/munin/munin.conf}} の以下の {{ic|htmldir}} のコメントを外します: |
||
| − | |||
| − | htmldir /srv/http/munin |
||
| − | |||
| − | これで {{ic|/srv/http/munin}} へ出力が設定されます。 |
||
| − | |||
| − | ディレクトリについては作成するだけでなく、ユーザー munin がこのディレクトリへの書き込み権限を満たす様にするのも忘れないようにしましょう。 |
||
# mkdir /srv/http/munin |
# mkdir /srv/http/munin |
||
# chown munin:munin /srv/http/munin |
# chown munin:munin /srv/http/munin |
||
| + | {{ic|/etc/munin/munin.conf}} の {{ic|htmldir}} エントリのコメントを外し、前のステップで作成したディレクトリに変更します: |
||
| − | 適当なウェブサーバーが標準設定のまま (ドキュメントルートが {{ic|/srv/http}})で稼働していれば、このディレクトリを [http://localhost/munin/ http://localhost/munin/] で表示する事が出来るでしょう。 |
||
| + | htmldir /srv/http/munin |
||
| − | === ホスト名 === |
||
| + | ==== Cron ==== |
||
| − | munin を実行する前に、システムのホスト名を設定しておくと良いでしょう。{{ic|/etc/munin/munin.conf}} で標準では {{ic|myhostname}} となっている筈です。お好みの名前を付けてあげて下さいね。ホスト名は {{ic|/var/lib/munin}} の .rrdファイル、HTML やグラフ画像のグループ化に適用されます。 |
||
| − | === |
+ | ===== crontab ===== |
次の設定で5分措きに munin がデータを更新し、HTMLとグラフ画像を生成します: |
次の設定で5分措きに munin がデータを更新し、HTMLとグラフ画像を生成します: |
||
| 122行目: | 54行目: | ||
とかコマンドを実行すると良いでしょう。 |
とかコマンドを実行すると良いでしょう。 |
||
| − | === systemd タイマー === |
+ | ===== systemd タイマー ===== |
cron ジョブではなく systemd のタイマーを使うこともできます。 |
cron ジョブではなく systemd のタイマーを使うこともできます。 |
||
| 158行目: | 90行目: | ||
最後に、{{ic|munin-cron.timer}} を有効化してください。 |
最後に、{{ic|munin-cron.timer}} を有効化してください。 |
||
| + | ==== パーミッション ==== |
||
| − | === ユーザー munin へのアクセス権の設定 === |
||
| + | {{ic|/etc/munin/munin.conf}} で {{ic|graph_strategy cgi}} が有効になっている場合、{{ic|/usr/share/munin/cgi/munin-cgi-graph}} スクリプトが PNG ファイルをこのディレクトリに書き込めるように、{{ic|/var/lib/munin/cgi-tmp}} ディレクトリの所有者とグループが {{ic|munin}} になっていることを確認してください。 |
||
| − | 多くのプラグインがログファイルを読もうとします。そう云う訳でユーザー munin を log グループに追加して措きましょう: |
||
| − | # |
+ | # chown munin: /var/lib/munin/cgi-tmp |
| − | == テスト == |
+ | ==== テスト ==== |
| + | {{ic|munin-cron}} が実行されるように設定されると、Munin はグラフの生成を開始できるようになります。すべてのノードで {{ic|munin-node.service}} が実行中であることを確認してください。ノードが稼働してからこのセクションに戻るには、先に [[#Munin node]] セクションに進むと良いでしょう。 |
||
| − | Munin は既に使える状態になっています。さあ、{{ic|munin-node}} を稼働させましょう: |
||
| + | {{ic|munin}} ユーザーとして手動で {{ic|munin-cron}} コマンドを実行すると、次の cron 実行を待たずに HTML とグラフ画像の生成を即座にトリガーできます: |
||
| − | # systemctl start munin-node |
||
| + | [munin]$ munin-cron |
||
| − | もしも手作業で HTML とグラフ画像を生成したいのならば、 |
||
| + | Munin のログ出力が設定されている場合、ログは通常 {{ic|/var/log/munin/}} にあります。別のターミナルで {{ic|munin-cron}} 実行後に {{ic|munin-update.log}} を監視することで、問題の診断に役立つ場合があります: |
||
| − | # munin --shell=/bin/bash |
||
| − | $ munin-cron |
||
| + | # tail -f /var/log/munin/munin-update.log |
||
| − | とかすると良いでしょう。後はブラウザで出力ディレクトリ或いは [http://localhost/munin/ http://localhost/munin/] を表示する等してインターフェースをテストしましょう。 |
||
| + | === Munin node === |
||
| − | {{Note|グラフにデータが集まりだすのには時間がかかるので30分くらい待って見ましょうね。}} |
||
| − | == |
+ | ==== デーモン ==== |
| + | ノード側では、{{ic|munin-node.service}} を[[起動/有効化]]します。 |
||
| − | Munin には沢山のプラグインがあってキミにインストールされるのを待っているよ!手始めに [http://muninexchange.projects.linpro.no/ MuninExchange] を見るといいよ、素敵だろ?まあ、時にはお目当てのプラグインを見付けられない事もあるだろうけど…そんな時は自分で書けばいいよ!簡単だから [http://munin-monitoring.org/wiki/HowToWritePlugins HowToWritePlugins] を見ながらやってみるといいよ。 |
||
| − | === |
+ | ==== IPv6 ==== |
| + | ''munin-node'' で IPv6 をサポートするには、以下のように設定します: |
||
| − | 基本的には全てのプラグインはマナーに則って追加されるよ(いやまあ勿論、例外はあるからプラグイン毎によく確認してね!): |
||
| + | {{hc|/etc/munin/munin-node.conf| |
||
| − | 先ずはプラグインをダウンロードするなどして、それを {{ic|/usr/lib/munin/plugins}} に複製なり移動なりしよう。 |
||
| + | host :::1 |
||
| + | }} |
||
| + | 以下をインストールしてください: |
||
| − | # cp <plugin> /usr/lib/munin/plugins/ |
||
| + | *{{Pkg|perl-socket6}} |
||
| − | そして {{ic|/etc/munin/plugins}} にシンボリックリンクを張るんだ: |
||
| + | *{{Pkg|perl-io-socket-inet6}} |
||
| + | ==== カスタマイズ ==== |
||
| − | # ln -s /usr/lib/munin/plugins/<plugin> /etc/munin/plugins/<plugin> |
||
| + | Munin を実行する前に、システムのホスト名を設定しておくと良いでしょう。{{ic|/etc/munin/munin.conf}} では、デフォルトのホスト名は {{ic|myhostname}} になっています。これを任意のホスト名に変更可能です。ホスト名は、{{ic|/var/lib/munin}} 内の {{ic|.rrd}} ファイルのグループ化や命名に使用され、さらに指定された ''munin-master'' のディレクトリ内で HTML ファイルやグラフをグループ化するのにも使用されます。 |
||
| − | {{Note|ワイルドカードプラグインと云われる幾つかのプラグインについては… - 別々の名前でリンクを張る事で複数のデバイスを扱えたりもするよ。こんな様なプラグインたちはプラグインの末尾がアンダースコアで終わっていて、{{ic|<plugin>_<device>}} とかリンクを張る事で {{ic|<device>}} に対応する様に動作するんだ。例としては {{ic|if_}} プラグインとかを見るといいよ。}} |
||
| + | ==== プラグイン ==== |
||
| − | さあ、プラグインをテストしよう。プラグインのフルパスを入れる必要は無いよ、次にように munin-run を実行しよう: |
||
| + | {{ic|munin-node-configure}} を {{ic|--suggest}} オプション付きで実行すると、Munin が現在の環境に適していると思われるプラグインを提案してくれます: |
||
| − | # munin-run <plugin> |
||
| + | # munin-node-configure --suggest |
||
| − | それから munin-node を 再起動するんだ: |
||
| + | 使用したいプラグインが提案された場合は、その提案に従い、再度コマンドを実行します。{{ic|munin-node-configure}} による提案に満足したら、{{ic|--shell}} オプションを使ってプラグインを設定できます: |
||
| − | # systemctl restart munin-node |
||
| + | # munin-node-configure --shell | sh |
||
| − | 後はウェブページが更新されれば完了さ。 |
||
| − | === |
+ | ===== 追加方法 ===== |
| + | 基本的に、すべてのプラグインは以下の手順で追加できます(例外もあるため、それぞれのプラグインのドキュメントを確認してください): |
||
| − | プラグインを削除したいのなら、{{ic|/etc/munin/plugins}} のシンボリックリンクを削除すればいい。{{ic|/usr/lib/munin/plugins}} から削除する必要は無いよ。 |
||
| + | プラグインをダウンロードし、{{ic|/usr/lib/munin/plugins}} にコピーまたは移動します: |
||
| − | # rm /etc/munin/plugins/<plugin> |
||
| + | # cp ''plugin'' /usr/lib/munin/plugins/ |
||
| − | === デバッグ作業 === |
||
| + | 次に、プラグインを {{ic|/etc/munin/plugins}} にリンクします: |
||
| − | 思惑通りに動いてくれないプラグイン(何も出力されてないっぽいとか)に出会してしまったなら、そのプラグインを直接実行して見るというのも良いかもしれません。例えば、{{ic|apache_accesses}} プラグインを直接実行するには、 |
||
| + | |||
| + | # ln -s /usr/lib/munin/plugins/''plugin'' /etc/munin/plugins/ |
||
| + | |||
| + | {{Note|一部のプラグイン(ワイルドカードプラグイン)は、複数のデバイスで同時に使用できます。これらは末尾がアンダースコア()で終わり、{{ic|<plugin><device>}} の形式でリンクして使用します。例としては {{ic|if_}} プラグインがあります。}} |
||
| + | |||
| + | 次にプラグインをテストします。プラグインのフルパスを使う必要はありません。{{ic|munin-run}} が自動で認識してくれます: |
||
| + | |||
| + | # munin-run ''plugin'' |
||
| + | |||
| + | そして {{ic|munin-node.service}} を[[ヘルプ:読み方#systemd ユニットのコントロール|再起動]]し、Webページを更新してください。 |
||
| + | |||
| + | ===== 追加プラグイン ===== |
||
| + | |||
| + | Munin にはまだまだたくさんのプラグインが存在します。インストールして使える状態になっています。[http://muninexchange.projects.linpro.no/ MuninExchange] は探し始めるのに最適な場所です。また、必要なプラグインが見つからない場合は、自分で作成するのも簡単です。Munin のドキュメント Wiki の [http://guide.munin-monitoring.org/en/latest/develop/plugins/ Developing Plugins] を参照してください。 |
||
| + | |||
| + | ===== 削除方法 ===== |
||
| + | |||
| + | プラグインを削除したい場合は、{{ic|/etc/munin/plugins}} にあるリンクファイルを削除するだけで OK です。{{ic|/usr/lib/munin/plugins}} からプラグイン本体を削除する必要はありません。 |
||
| + | |||
| + | # rm /etc/munin/plugins/''plugin'' |
||
| + | |||
| + | ===== デバッグ ===== |
||
| + | |||
| + | 期待通りに動作しないプラグイン(出力が全く無いなど)がある場合は、直接実行してみると良いでしょう。例えば、ここまでの手順に従っていると、{{ic|apache_accesses}} プラグインが有効になっていても全く出力されないことに気づくかもしれません。このプラグインを直接実行するには: |
||
# munin-run apache_accesses |
# munin-run apache_accesses |
||
| + | 次のようなエラーが表示されることがあります: |
||
| − | とかします。 |
||
| + | |||
| + | LWP::UserAgent not found at /etc/munin/plugins/apache_accesses line 86. |
||
| + | |||
| + | これは、Perl の関数が見つからないことを意味しています。この場合、不足しているライブラリ (ここでは {{Pkg|perl-libwww}}) を[[インストール]]することで問題を解決できます。 |
||
| + | |||
| + | ==== パーミッション ==== |
||
| + | |||
| + | 多くのプラグインがログファイルを読み込むため、{{ic|munin}} ユーザーを {{ic|log}} グループに[[ユーザーとグループ#ユーザーを追加する例|追加]]すると便利です: |
||
| + | |||
| + | # usermod -a -G log munin |
||
| + | |||
| + | == Web server (オプション) == |
||
| + | |||
| + | このガイドでは、Munin を設定して静的 HTML およびグラフ画像を生成し、任意のディレクトリに書き込むようにします。これらの生成されたファイルは、ローカルの任意のウェブブラウザで閲覧可能です。生成されたファイルをリモートマシンから閲覧したい場合は、以下のいずれかのウェブサーバーをインストールして設定する必要があります: |
||
| + | |||
| + | * [[Apache HTTP Server]] |
||
| + | * [[Lighttpd]] |
||
| + | * [[Nginx]] |
||
| + | |||
| + | または [[ウェブサーバー]] カテゴリにある他のサーバーのいずれか。 |
||
| + | |||
| + | === Apache === |
||
| + | |||
| + | ==== Apache VirtualHost の例 ==== |
||
| + | |||
| + | 以下の情報に基づいています: |
||
| + | |||
| + | * http://guide.munin-monitoring.org/en/stable-2.0/example/webserver/apache-virtualhost.html |
||
| + | * http://munin-monitoring.org/wiki/MuninConfigurationMasterCGI{{Dead link|2021|05|17|status=404}} |
||
| + | |||
| + | 次のメジャーリリースの Munin では、よりシンプルになります。以下を確認してください: |
||
| + | |||
| + | * https://web.archive.org/web/20180128051736/http://guide.munin-monitoring.org/en/latest/example/webserver/apache-virtualhost.html |
||
| + | |||
| + | ==== 基本的な静的 HTML ==== |
||
| + | |||
| + | <nowiki><VirtualHost *:80> |
||
| + | ServerName localhost |
||
| + | ServerAdmin root@localhost |
||
| + | |||
| + | DocumentRoot /srv/http/munin |
||
| + | |||
| + | ErrorLog /var/log/httpd/munin-error.log |
||
| + | CustomLog /var/log/httpd/munin-access.log combined |
||
| + | </VirtualHost></nowiki> |
||
| + | |||
| + | ==== DynaZoom 機能を備えた静的 HTML ==== |
||
| + | |||
| + | {{pkg|perl-cgi-fast}} をインストールします。 |
||
| + | |||
| + | 以下のいずれかを有効にする必要があります: |
||
| + | |||
| + | * {{ic|mod_cgid}}(または {{ic|mod_cgi}}、mpm_prefork_module を使用している場合)を {{ic|httpd.conf}} 内でアンコメント |
||
| + | * または {{AUR|mod_fcgid}} をインストールし、{{ic|LoadModule fcgid_module modules/mod_fcgid.so}} を {{ic|httpd.conf}} に追加 |
||
| + | |||
| + | <VirtualHost *:80> |
||
| + | ServerName localhost |
||
| + | ServerAdmin root@localhost |
||
| + | |||
| + | DocumentRoot /srv/http/munin |
||
| + | |||
| + | ErrorLog /var/log/httpd/munin-error.log |
||
| + | CustomLog /var/log/httpd/munin-access.log combined |
||
| + | |||
| + | # Rewrites |
||
| + | RewriteEngine On |
||
| + | |||
| + | # Images |
||
| + | RewriteRule ^/munin-cgi(.*) /usr/share/munin/cgi/$1 [L] |
||
| + | |||
| + | # Ensure we can run (fast)cgi scripts |
||
| + | <Directory "/usr/share/munin/cgi"> |
||
| + | Require all granted |
||
| + | Options +ExecCGI |
||
| + | <IfModule mod_fcgid.c> |
||
| + | SetHandler fcgid-script |
||
| + | </IfModule> |
||
| + | <IfModule !mod_fcgid.c> |
||
| + | SetHandler cgi-script |
||
| + | </IfModule> |
||
| + | </Directory> |
||
| + | </VirtualHost> |
||
| + | |||
| + | ==== DynaZoom パーミッション ==== |
||
| + | |||
| + | Munin がグラフを描画できず、{{ic|Could not draw graph "/var/lib/munin/cgi-tmp/munin-cgi-graph/"}} のようなメッセージをログに記録する場合は、{{ic|/var/lib/munin/cgi-tmp/munin-cgi-graph/}} にグループ権限が設定されていることを確認してください。これにより、{{ic|munin-cgi-graph}} ディレクトリに、{{ic|drwxrwxr-x 3 munin http 4096 Aug 9 20:11 munin-cgi-graph}} などの書き込み可能なグループ権限が与えられます: |
||
| + | |||
| + | {{ic|ls -l /var/lib/munin/cgi-tmp/}} |
||
| + | |||
| + | グループ権限が設定されていない場合は、次のようにします。 |
||
| + | |||
| + | {{ic|chmod g+w /var/lib/munin/cgi-tmp/munin-cgi-graph/}} |
||
| + | |||
| + | ==== Full dynamic ==== |
||
| + | |||
| + | {{ic|html_strategy}} および {{ic|graph_strategy}} を {{ic|cgi}} に設定する場合、この VirtualHost を使用します。ページの読み込みには時間がかかりますが、{{ic|munin-cron}} の実行時間は短くなります。これは、多数のノードをポーリングしており、{{ic|munin-cron}} が5分以上かかる可能性がある場合に有効です。 |
||
| + | |||
| + | {{pkg|perl-cgi-fast}} をインストールします。 |
||
| + | |||
| + | 以下のいずれかを有効にする必要があります: |
||
| + | |||
| + | * {{ic|mod_cgid}}(または {{ic|mod_cgi}})を {{ic|httpd.conf}} でアンコメント |
||
| + | * または {{AUR|mod_fcgid}} をインストールして、{{ic|httpd.conf}} に以下を追加 |
||
| + | |||
| + | <VirtualHost *:80> |
||
| + | ServerName localhost |
||
| + | ServerAdmin root@localhost |
||
| + | |||
| + | DocumentRoot /srv/http/munin |
||
| + | |||
| + | ErrorLog /var/log/httpd/munin-error.log |
||
| + | CustomLog /var/log/httpd/munin-access.log combined |
||
| + | |||
| + | |||
| + | # Rewrites |
||
| + | RewriteEngine On |
||
| + | |||
| + | # Static content in /static |
||
| + | RewriteRule ^/favicon.ico /etc/munin/static/favicon.ico [L] |
||
| + | RewriteRule ^/static/(.*) /etc/munin/static/$1 [L] |
||
| + | |||
| + | # HTML |
||
| + | RewriteCond %{REQUEST_URI} .html$ [or] |
||
| + | RewriteCond %{REQUEST_URI} =/ |
||
| + | RewriteRule ^/(.*) /usr/share/munin/cgi/munin-cgi-html/$1 [L] |
||
| + | |||
| + | # Images |
||
| + | RewriteRule ^/munin-cgi(.*) /usr/share/munin/cgi/$1 [L] |
||
| + | |||
| + | <Directory "/etc/munin/static"> |
||
| + | Require all granted |
||
| + | </Directory> |
||
| + | |||
| + | # Ensure we can run (fast)cgi scripts |
||
| + | <Directory "/usr/share/munin/cgi"> |
||
| + | Require all granted |
||
| + | Options +ExecCGI |
||
| + | <IfModule mod_fcgid.c> |
||
| + | SetHandler fcgid-script |
||
| + | </IfModule> |
||
| + | <IfModule !mod_fcgid.c> |
||
| + | SetHandler cgi-script |
||
| + | </IfModule> |
||
| + | </Directory> |
||
| + | </VirtualHost> |
||
| + | |||
| + | === Nginx === |
||
| + | |||
| + | ==== Munin 2.0.x ==== |
||
| + | |||
| + | この Nginx 設定例は、Munin 2.0.x の {{ic|munin}} マスターインストールに基づいています。FastCGI を必要とし、{{ic|munin.conf}} で {{ic|html_strategy cgi}} および {{ic|graph_strategy cgi}} を使用します。 |
||
| + | |||
| + | Munin-Master に {{Pkg|nginx}}, {{Pkg|perl-cgi-fast}}, {{Pkg|perl-html-template-expr}} を[[インストール]]します。 |
||
| + | |||
| + | ''cgi'' 戦略を使用するため、systemd ソケットファイルを有効化して、Nginx FastCGI 設定が以下のソケットに接続できるようにします {{ic|/run/munin/fcgi-graph.sock}}、{{ic|/run/munin/fcgi-html.sock}} |
||
| + | |||
| + | 次を[[起動/有効化]]してください、{{ic|munin-graph.socket}} と {{ic|munin-html.socket}} |
||
| + | |||
| + | Munin 用の vhost 設定ファイルを作成 |
||
| + | |||
| + | {{hc|/etc/nginx/sites-available/munin| |
||
| + | server { |
||
| + | server_name yourhost.example.com; |
||
| + | listen 80; |
||
| + | access_log /var/log/nginx/munin-access.log; |
||
| + | error_log /var/log/nginx/munin-error.log info; |
||
| + | location ^~ /munin-cgi/munin-cgi-graph/ { |
||
| + | fastcgi_split_path_info ^(/munin-cgi/munin-cgi-graph)(.*); |
||
| + | fastcgi_param PATH_INFO $fastcgi_path_info; |
||
| + | fastcgi_pass unix:/run/munin/fcgi-graph.sock; |
||
| + | include fastcgi_params; |
||
| + | } |
||
| + | location /munin/static/ { |
||
| + | alias /etc/munin/static/; |
||
| + | } |
||
| + | location /munin/ { |
||
| + | fastcgi_split_path_info ^(/munin)(.*); |
||
| + | fastcgi_param PATH_INFO $fastcgi_path_info; |
||
| + | fastcgi_pass unix:/run/munin/fcgi-html.sock; |
||
| + | include fastcgi_params; |
||
| + | } |
||
| + | } |
||
| + | }} |
||
| + | |||
| + | その後、ウェブサーバー({{ic|nginx.service}})を[[再起動]]します。 |
||
| + | |||
| + | うまくいけば、ブラウザで {{ic|http://yourhost.example.com/munin/}} にアクセスすると Munin の概要ページが表示されるはずです。 |
||
| + | |||
| + | ==== Munin 2.1.x ==== |
||
| + | |||
| + | Munin 2.1.x はまだ Arch リポジトリにはありませんが、このバージョンでは FastCGI を使用せず、代わりに [http://guide.munin-monitoring.org/en/latest/reference/munin-httpd.html#munin-httpd munin-httpd] が使用されるようになります。 |
||
| + | [https://web.archive.org/web/20180221235730/http://guide.munin-monitoring.org/en/latest/example/webserver/nginx.html このページ] に設定例があります。 |
||
| − | エラーがあれば、例えば "LWP::UserAgent not found at /etc/munin/plugins/apache_accesses line 86." だとか出力されるかもしれません。ちなみにこの場合は、Perlの関数が見つからないという問題で、不足しているライブラリ {{Pkg|perl-libwww}} をインストールしてあげると良いかもしれません。 |
||
| + | ==ヒントとテクニック== |
||
| − | ==Tips and Tricks== |
||
===MySQL=== |
===MySQL=== |
||
2025年4月18日 (金) 20:14時点における最新版
プロジェクトウェブページ より:
- Munin はコンピュータに何があったのか調べる事ができるモニタリングツールです。調べた全ての情報をウェブインターフェースを介して表示する事ができます。インストールが完了した後は、沢山のモニタリングプラグインたちがあなたに代わって仕事をしてくれる事でしょう。
- Munin を使えばネットワーク、SAN、アプリケーション、気象状況等による計算機の性能評価が簡単になります。性能の問題について「おや、この日は何が違ったのかな?」とか簡単に分かるようになります。リソース毎の過不足を簡単に判断できるようになるでしょう。
- Munin は優れた RRDTool (著 Tobi Oetiker) と Perl で書かれたフレームワーク、それと様々な言語で書かれたプラグインたちによって構成されています。Munin は マスター/ノード アーキテクチャー を採っていて、マスターが全てのノードに対し定期的にデータ収集を行います。データは RRDファイル に記録され、必要に応じてグラフを更新します。とりあえずの目標としてプラグイン(グラフ)を自在に扱える様になりましょう。
と、いうわけで、 Munin はシステムの統計を採りグラフに図示してくれるものです。詳しくはオスロ大学の Munin install など見ると良いでしょう。
インストール
マスター機には munin パッケージを、監視したい各デバイスには munin-node をインストールしてください。
マスター機自身を監視対象とする場合は、両方のパッケージを同じマシンにインストールすることも可能です。
さらに詳しいドキュメントは、Munin ドキュメント Wiki にあります。
設定
Munin master
ディレクトリ
munin-master が生成する HTML やグラフ画像を書き込むためのディレクトリを作成します。このディレクトリには、munin ユーザーが書き込み権限を持っている必要があります。
以下の例では /srv/http/munin を使用しています。Webサーバーがインストールされて起動していれば、生成された出力は http://localhost/munin/ で閲覧できます:
# mkdir /srv/http/munin # chown munin:munin /srv/http/munin
/etc/munin/munin.conf の htmldir エントリのコメントを外し、前のステップで作成したディレクトリに変更します:
htmldir /srv/http/munin
Cron
crontab
次の設定で5分措きに munin がデータを更新し、HTMLとグラフ画像を生成します:
# crontab /etc/munin/munin-cron-entry -u munin
ユーザー munin へのメール配送のエイリアスも設定して措くと良いでしょう。もしも postfix を使っているのならば /etc/postfix/aliases に次のように設定し、
munin: root
それから
# newaliases
とかコマンドを実行すると良いでしょう。
systemd タイマー
cron ジョブではなく systemd のタイマーを使うこともできます。
タイマーにはサービスユニットの設定が必要です:
/etc/systemd/system/munin-cron.service
[Unit] Description=Survey monitored computers After=network.target [Service] User=munin ExecStart=/usr/bin/munin-cron
タイマーユニットの設定:
/etc/systemd/system/munin-cron.timer
[Unit] Description=Survey monitored computers every five minutes [Timer] OnCalendar=*-*-* *:00/5:00 [Install] WantedBy=multi-user.target
systemd の設定をリロードして、munin-cron.timer を起動し、問題が発生しないことを確認してください:
$ journalctl --unit munin-cron.service $ less /var/log/munin/munin-update.log
最後に、munin-cron.timer を有効化してください。
パーミッション
/etc/munin/munin.conf で graph_strategy cgi が有効になっている場合、/usr/share/munin/cgi/munin-cgi-graph スクリプトが PNG ファイルをこのディレクトリに書き込めるように、/var/lib/munin/cgi-tmp ディレクトリの所有者とグループが munin になっていることを確認してください。
# chown munin: /var/lib/munin/cgi-tmp
テスト
munin-cron が実行されるように設定されると、Munin はグラフの生成を開始できるようになります。すべてのノードで munin-node.service が実行中であることを確認してください。ノードが稼働してからこのセクションに戻るには、先に #Munin node セクションに進むと良いでしょう。
munin ユーザーとして手動で munin-cron コマンドを実行すると、次の cron 実行を待たずに HTML とグラフ画像の生成を即座にトリガーできます:
[munin]$ munin-cron
Munin のログ出力が設定されている場合、ログは通常 /var/log/munin/ にあります。別のターミナルで munin-cron 実行後に munin-update.log を監視することで、問題の診断に役立つ場合があります:
# tail -f /var/log/munin/munin-update.log
Munin node
デーモン
ノード側では、munin-node.service を起動/有効化します。
IPv6
munin-node で IPv6 をサポートするには、以下のように設定します:
/etc/munin/munin-node.conf
host :::1
以下をインストールしてください:
カスタマイズ
Munin を実行する前に、システムのホスト名を設定しておくと良いでしょう。/etc/munin/munin.conf では、デフォルトのホスト名は myhostname になっています。これを任意のホスト名に変更可能です。ホスト名は、/var/lib/munin 内の .rrd ファイルのグループ化や命名に使用され、さらに指定された munin-master のディレクトリ内で HTML ファイルやグラフをグループ化するのにも使用されます。
プラグイン
munin-node-configure を --suggest オプション付きで実行すると、Munin が現在の環境に適していると思われるプラグインを提案してくれます:
# munin-node-configure --suggest
使用したいプラグインが提案された場合は、その提案に従い、再度コマンドを実行します。munin-node-configure による提案に満足したら、--shell オプションを使ってプラグインを設定できます:
# munin-node-configure --shell | sh
追加方法
基本的に、すべてのプラグインは以下の手順で追加できます(例外もあるため、それぞれのプラグインのドキュメントを確認してください):
プラグインをダウンロードし、/usr/lib/munin/plugins にコピーまたは移動します:
# cp plugin /usr/lib/munin/plugins/
次に、プラグインを /etc/munin/plugins にリンクします:
# ln -s /usr/lib/munin/plugins/plugin /etc/munin/plugins/
次にプラグインをテストします。プラグインのフルパスを使う必要はありません。munin-run が自動で認識してくれます:
# munin-run plugin
そして munin-node.service を再起動し、Webページを更新してください。
追加プラグイン
Munin にはまだまだたくさんのプラグインが存在します。インストールして使える状態になっています。MuninExchange は探し始めるのに最適な場所です。また、必要なプラグインが見つからない場合は、自分で作成するのも簡単です。Munin のドキュメント Wiki の Developing Plugins を参照してください。
削除方法
プラグインを削除したい場合は、/etc/munin/plugins にあるリンクファイルを削除するだけで OK です。/usr/lib/munin/plugins からプラグイン本体を削除する必要はありません。
# rm /etc/munin/plugins/plugin
デバッグ
期待通りに動作しないプラグイン(出力が全く無いなど)がある場合は、直接実行してみると良いでしょう。例えば、ここまでの手順に従っていると、apache_accesses プラグインが有効になっていても全く出力されないことに気づくかもしれません。このプラグインを直接実行するには:
# munin-run apache_accesses
次のようなエラーが表示されることがあります:
LWP::UserAgent not found at /etc/munin/plugins/apache_accesses line 86.
これは、Perl の関数が見つからないことを意味しています。この場合、不足しているライブラリ (ここでは perl-libwww) をインストールすることで問題を解決できます。
パーミッション
多くのプラグインがログファイルを読み込むため、munin ユーザーを log グループに追加すると便利です:
# usermod -a -G log munin
Web server (オプション)
このガイドでは、Munin を設定して静的 HTML およびグラフ画像を生成し、任意のディレクトリに書き込むようにします。これらの生成されたファイルは、ローカルの任意のウェブブラウザで閲覧可能です。生成されたファイルをリモートマシンから閲覧したい場合は、以下のいずれかのウェブサーバーをインストールして設定する必要があります:
または ウェブサーバー カテゴリにある他のサーバーのいずれか。
Apache
Apache VirtualHost の例
以下の情報に基づいています:
- http://guide.munin-monitoring.org/en/stable-2.0/example/webserver/apache-virtualhost.html
- http://munin-monitoring.org/wiki/MuninConfigurationMasterCGI[リンク切れ 2021-05-17]
次のメジャーリリースの Munin では、よりシンプルになります。以下を確認してください:
基本的な静的 HTML
<VirtualHost *:80>
ServerName localhost
ServerAdmin root@localhost
DocumentRoot /srv/http/munin
ErrorLog /var/log/httpd/munin-error.log
CustomLog /var/log/httpd/munin-access.log combined
</VirtualHost>
DynaZoom 機能を備えた静的 HTML
perl-cgi-fast をインストールします。
以下のいずれかを有効にする必要があります:
mod_cgid(またはmod_cgi、mpm_prefork_module を使用している場合)をhttpd.conf内でアンコメント- または mod_fcgidAUR をインストールし、
LoadModule fcgid_module modules/mod_fcgid.soをhttpd.confに追加
<VirtualHost *:80>
ServerName localhost
ServerAdmin root@localhost
DocumentRoot /srv/http/munin
ErrorLog /var/log/httpd/munin-error.log
CustomLog /var/log/httpd/munin-access.log combined
# Rewrites
RewriteEngine On
# Images
RewriteRule ^/munin-cgi(.*) /usr/share/munin/cgi/$1 [L]
# Ensure we can run (fast)cgi scripts
<Directory "/usr/share/munin/cgi">
Require all granted
Options +ExecCGI
<IfModule mod_fcgid.c>
SetHandler fcgid-script
</IfModule>
<IfModule !mod_fcgid.c>
SetHandler cgi-script
</IfModule>
</Directory>
</VirtualHost>
DynaZoom パーミッション
Munin がグラフを描画できず、Could not draw graph "/var/lib/munin/cgi-tmp/munin-cgi-graph/" のようなメッセージをログに記録する場合は、/var/lib/munin/cgi-tmp/munin-cgi-graph/ にグループ権限が設定されていることを確認してください。これにより、munin-cgi-graph ディレクトリに、drwxrwxr-x 3 munin http 4096 Aug 9 20:11 munin-cgi-graph などの書き込み可能なグループ権限が与えられます:
ls -l /var/lib/munin/cgi-tmp/
グループ権限が設定されていない場合は、次のようにします。
chmod g+w /var/lib/munin/cgi-tmp/munin-cgi-graph/
Full dynamic
html_strategy および graph_strategy を cgi に設定する場合、この VirtualHost を使用します。ページの読み込みには時間がかかりますが、munin-cron の実行時間は短くなります。これは、多数のノードをポーリングしており、munin-cron が5分以上かかる可能性がある場合に有効です。
perl-cgi-fast をインストールします。
以下のいずれかを有効にする必要があります:
mod_cgid(またはmod_cgi)をhttpd.confでアンコメント- または mod_fcgidAUR をインストールして、
httpd.confに以下を追加
<VirtualHost *:80>
ServerName localhost
ServerAdmin root@localhost
DocumentRoot /srv/http/munin
ErrorLog /var/log/httpd/munin-error.log
CustomLog /var/log/httpd/munin-access.log combined
# Rewrites
RewriteEngine On
# Static content in /static
RewriteRule ^/favicon.ico /etc/munin/static/favicon.ico [L]
RewriteRule ^/static/(.*) /etc/munin/static/$1 [L]
# HTML
RewriteCond %{REQUEST_URI} .html$ [or]
RewriteCond %{REQUEST_URI} =/
RewriteRule ^/(.*) /usr/share/munin/cgi/munin-cgi-html/$1 [L]
# Images
RewriteRule ^/munin-cgi(.*) /usr/share/munin/cgi/$1 [L]
<Directory "/etc/munin/static">
Require all granted
</Directory>
# Ensure we can run (fast)cgi scripts
<Directory "/usr/share/munin/cgi">
Require all granted
Options +ExecCGI
<IfModule mod_fcgid.c>
SetHandler fcgid-script
</IfModule>
<IfModule !mod_fcgid.c>
SetHandler cgi-script
</IfModule>
</Directory>
</VirtualHost>
Nginx
Munin 2.0.x
この Nginx 設定例は、Munin 2.0.x の munin マスターインストールに基づいています。FastCGI を必要とし、munin.conf で html_strategy cgi および graph_strategy cgi を使用します。
Munin-Master に nginx, perl-cgi-fast, perl-html-template-expr をインストールします。
cgi 戦略を使用するため、systemd ソケットファイルを有効化して、Nginx FastCGI 設定が以下のソケットに接続できるようにします /run/munin/fcgi-graph.sock、/run/munin/fcgi-html.sock
次を起動/有効化してください、munin-graph.socket と munin-html.socket
Munin 用の vhost 設定ファイルを作成
/etc/nginx/sites-available/munin
server {
server_name yourhost.example.com;
listen 80;
access_log /var/log/nginx/munin-access.log;
error_log /var/log/nginx/munin-error.log info;
location ^~ /munin-cgi/munin-cgi-graph/ {
fastcgi_split_path_info ^(/munin-cgi/munin-cgi-graph)(.*);
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass unix:/run/munin/fcgi-graph.sock;
include fastcgi_params;
}
location /munin/static/ {
alias /etc/munin/static/;
}
location /munin/ {
fastcgi_split_path_info ^(/munin)(.*);
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass unix:/run/munin/fcgi-html.sock;
include fastcgi_params;
}
}
その後、ウェブサーバー(nginx.service)を再起動します。
うまくいけば、ブラウザで http://yourhost.example.com/munin/ にアクセスすると Munin の概要ページが表示されるはずです。
Munin 2.1.x
Munin 2.1.x はまだ Arch リポジトリにはありませんが、このバージョンでは FastCGI を使用せず、代わりに munin-httpd が使用されるようになります。
このページ に設定例があります。
ヒントとテクニック
MySQL
MySQL プラグインは AUR のパッケージに依存しています: perl-dbi, perl-cache-cacheAUR, perl-ipc-shareliteAUR
また、データベースにアクセスするときは専用の MySQL ユーザーを使うことが推奨されています。ユーザーを作成するには以下の MySQL コマンドを実行:
MariaDB> CREATE USER 'muninuser'@'localhost' IDENTIFIED BY 'muninpassword'; MariaDB> GRANT SUPER,PROCESS ON *.* TO 'muninuser'@'localhost'; MariaDB> GRANT SELECT ON mysql.* TO 'muninuser'@'localhost'; MariaDB> FLUSH PRIVILEGES;
この新しいユーザーを使うように Munin を設定するには、以下を作成:
/etc/munin/plugin-conf.d/mysql_
[mysql_*]
env.mysqlconnection DBI:mysql:mysql;host=127.0.0.1;port=3306
env.mysqluser muninuser
env.mysqlpassword muninpassword
S.M.A.R.T.
S.M.A.R.T. データの監視を有効にするには smartmontools パッケージをインストールして、以下を使用:
/etc/munin/plugin-conf.d/munin-node
[smart_*]
user root
group disk
そして監視するディスクのシンボリックリンクを適切に作成してください。sda の場合:
# ln -s /usr/lib/munin/plugins/smart_ /etc/munin/plugins/smart_sda
lm_sensors
lm_sensors をインストールして Lm sensors#lm_sensors の設定 に従って設定を行って下さい。それが全て終わったら、シンボリックリンクを作成:
# ln -s /usr/lib/munin/plugins/sensors_ /etc/munin/plugins/sensors_fan # ln -s /usr/lib/munin/plugins/sensors_ /etc/munin/plugins/sensors_temp # ln -s /usr/lib/munin/plugins/sensors_ /etc/munin/plugins/sensors_volt