文書の表示以前のリビジョンバックリンク文書の先頭へ この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。 ====== ウェブ監視 ====== {{indexmenu_n>6}} [[ja:documentation:start|Pandora FMS ドキュメント一覧に戻る]] <wrap #ks1 /> ===== クラッシックなウェブ監視 ===== ==== 概要 ==== In Pandora FMS, the Web Server works in a separate server, the [[:en:documentation:pandorafms:introduction:02_architecture#network_server|Network server]]. This system operates on the principle of //web transaction//, where each completed transaction against one or more WEB pages is defined by one or more consecutive steps, which must be completed successfully in order to consider the transaction as successfully completed. Pandora FMS では、ウェブサーバは [[:ja:documentation:pandorafms:introduction:02_architecture#network_server|ネットワークサーバ]] 内で動作します。このシステムは //Web トランザクション// の原理に基づいて動作します。つまり、1 つ以上の Web ページに対する各トランザクションは、1 つ以上の連続したステップによって定義され、トランザクションが正常に完了したとみなされるには、これらのステップが正常に完了している必要があります。 <WRAP center round info 90%> * **The Network Server has important limitations,such as dynamic management of JavaScript at runtime**. * For more complex web transactions, Pandora FMS has another much more powerful (and complex) component called [[:en:documentation:pandorafms:monitoring:13_user_monitorization|WUX (Web User Experience) monitoring]]. </WRAP> <WRAP center round info 90%> * **ネットワークサーバには、実行時の JavaScript の動的管理などの重要な制限があります**。 * より複雑な Web トランザクション用に、Pandora FMS には [[:ja:documentation:pandorafms:monitoring:13_user_monitorization|WUX 監視 (Web ユーザエクスペリエンス)]] と呼ばれる、さらに強力な (そして複雑な) コンポーネントがあります。 </WRAP> <wrap #ks1_2 /> ==== インストールと設定 ==== The [[:en:documentation:pandorafms:installation:04_configuration#networkserver|Network Server]] is enabled by default. Depending on the number of requests you may have to increase the number of threads and the default timeout: [[:ja:documentation:pandorafms:installation:04_configuration#networkserver|ネットワークサーバ]]はデフォルトで有効になっています。リクエスト数に応じて、スレッド数とデフォルトのタイムアウト値を増やす必要がある場合があります。 web_threads 1 web_timeout 60 # Use curl or LWP web_engine curl <WRAP center round info 90%> Pandora FMS has protection against CSRF and when debugging web checks you could get this message: \\ ''Cannot verify the origin of the request'' \\ Take into account this protection to consider the use of "[[:en:documentation:pandorafms:monitoring:13_user_monitorization|WUX monitoring]]". </WRAP> <WRAP center round info 90%> Pandora FMS には CSRF に対する保護機能があり、Web チェックをデバッグするときに次のメッセージが表示される場合があります: \\ ''Cannot verify the origin of the request'' \\ この保護機能を考慮して、"[[:ja:documentation:pandorafms:monitoring:13_user_monitorization|WUX モニタリング]]" の使用を検討してください。 </WRAP> <wrap #ks1_3 /> ==== ウェブモジュールの作成 ==== To remotely monitor a web page, once the agent has been created, click on the top tab of the modules (<wrap :en>**Modules**</wrap>). In there, select <wrap :en>**Create a new web module**</wrap> and click <wrap :en>**Create**</wrap>: ウェブページをリモート監視するには、エージェントを作成したら、モジュールのトップタブ(<wrap :ja>**モジュール(Modules)**</wrap>)をクリックします。そこで、<wrap :ja>**ウェブモジュールの新規作成(Create a new web module)**</wrap>を選択し、<wrap :ja>**作成(Create)**</wrap>をクリックします。 Select the type of WEB check: ウェブチェックのタイプを選択します: * <wrap :en>**Remote HTTP module to check latency**</wrap>: It obtains the total time elapsed from the first request until the last one is checked (in a WEB test there are one or more intermediate requests that complete the transaction). If at check definition, the transaction is defined to be performed more than once, the average time of each request will be used. * <wrap :en>**Remote HTTP module to check server response**</wrap>: It gets 1 ( ''OK'' ) or 0 ( ''CRITICAL'' ) as a result of checking the whole transaction. If there are several attempts, but at least one of them fails, the test as a whole is considered to fail as well. Precisely, the number of attempts is sometimes used to avoid false positives, for that purpose use the //retries// field in advanced fields. * <wrap :en>**Remote HTTP module to retrieve numeric data**</wrap>: It gets a numeric value, parsing the HTTP response using a regular expression to get that value. * <wrap :en>**Remote HTTP module to retrieve string data**</wrap>: Analogous to the previous point but with a text string. * <wrap :en>**Remote HTTP module to check server status code**</wrap>: By means of the **curl** tool, duly enabled with the ''web_engine curl'' configuration token, HTTP headers may be returned. * **Remote HTTP module to check latency**: 最初のリクエストから最後のチェックが完了するまでのトータルの時間を取得します (ウェブチェックを完了するには、1つ以上のトランザクションがあります)。複数のリクエストが定義されている場合、それぞれの平均時間が利用されます。 * **Remote HTTP module to check server response**: すべてのトランザクションの結果をチェックし、1 (正常) もしくは、0 (異常) を返します。一部のステップが失敗すると、全体を障害として認識します。誤検出を避けるために、リトライ回数を設定することができます。 障害が発生した場合にテストを何回か実行する場合は、//リトライ// フィールドを使用してください(下記の詳細フィールドを参照)。 * **Remote HTTP module to retrieve numeric data**: 正規表現を利用して HTTP 応答から数値を取得します。 * **Remote HTTP module to retrieve string data**: 正規表現を利用して HTTP 応答から文字列を取得します。 * **Remote HTTP module to check server status code:**: ''web_engine curl'' の設定トークンで **curl** ツールの利用を有効化すると、HTTPヘッダーを返すことができます。 <wrap :en>**Web checks**</wrap>: This essential field defines the WEB check to be performed. It is defined in one or more steps, or simple requests. The checks start with the ''task_begin'' tag and end with the ''task_end'' tag. <wrap :ja>**ウェブチェック**</wrap>: この必須フィールドは、実行するウェブチェックを定義します。これは、1つ以上のステップ、または単純なリクエストで定義されます。チェックは ''task_begin'' タグで始まり、''task_end'' タグで終了します。 Several additional variables are available for form testing: フォームのテストには、いくつかの追加変数を使用できます。 * <wrap :en>**resource**</wrap> (1 or 0): Download all web resources (images, videos, etc.). * <wrap :en>**cookie**</wrap> (1 or 0): Keep a cookie, or an open session for later checks. * <wrap :en>**variable_name**</wrap>: Name of a variable in a form. * <wrap :en>**variable_value**</wrap>: Value of the previous variable in the form. * **resource (1 または 0)**:ウェブリソース (画像、ビデオなど) のすべてをダウンロードします。 * **cookie (1 または 0)**:クッキーを保持し、以降のチェックのためにセッションを保持します。 * **variable_name**:フォームの変数名です。 * **variable_value**:上記変数名に対する値です。 簡単なトランザクションの例を以下に示します。 <code> task_begin head http://apache.org/ task_end </code> コマンドを追加した別の例: <code> task_begin get http://apache.org/ cookie 0 resource 0 check_string Apache Software Foundation task_end </code> この基本的な例では、ウェブページに文字列があるかどうかをチェックしています。これは変数 **check_string** があるためです。 この変数では、HTML 自体をチェックすることはできません。テキストのサブストリングのみを検索します。 私たちは、Webサイト <[[http://apache.org|http://apache.org]]> で "Apache Software Foundation" を探しています。 その文字列が存在する場合、チェックは OK を返します(サーバーの応答を確認するリモート HTTP モジュールの場合) 文字列が Web ページに存在しないことを確認するには、'check_not_string' を利用できます。 <code> check_not_string Section 3 </code> <WRAP center round important 90%> In some cases of domain redirection, checks may not work. One way to solve this is to modify the module pointing to the final domain, e.g. ''curl -L''. </WRAP> <WRAP center round important 90%> ドメインリダイレクトの場合、チェックが機能しないことがあります。これを解決する一つの方法は、最終的なドメインを指すようにモジュールを変更することです。例: ''curl -L'' </WRAP> <wrap #ks1_4 /> ==== ウェブの応答時間チェック ==== To check the response time or latency of a web page, select the module type **Remote HTTP module to check latency**. Example: ウェブの応答時間をチェックしたい場合は、モジュールタイプ **Remote HTTP module to check latency** を選択します。例: <code> task_begin get https://pandorafms.com task_end </code> * For the download time to include all resources (JavaScript, CSS, images, etc.), ''resource 1'' must be added in a line before ''task_end''. * Web checks also support the use of proxy in the **Proxy URL** token. * すべてのリソース (JavaScript、CSS、画像など) のダウンロード時間取得には、''task_end'' の前の行に ''resource 1'' を追加する必要があります。 * Web チェックでは、**Proxy URL** トークンでのプロキシの使用もサポートされています。 <WRAP center round tip 90%> The web download time **is not** the time it takes to display a website in a browser, as this is usually dependent on the JavaScript load time. </WRAP> <WRAP center round tip 90%> ウェブサイトのダウンロード時間は、ブラウザで Web サイトを表示するのにかかる時間ではありません。通常、これはJavaScriptの読み込み時間に依存し、JavaScriptをダウンロードしますが、実行しません。 </WRAP> <wrap #ks1_5 /> ==== ウェブページのフォームのチェック ==== A form check is much more complex than simply checking text on a web page. In order to perform this type of check, you must have the necessary credentials. In addition, you need to //go// to the page and get the HTML code to get the variable names, and then you need to have minimal knowledge of HTML to enter the query for the Network Server. フォームチェックは、Webページ上のテキストを単純にチェックするよりもはるかに複雑です。この種のチェックを実行するには、必要な認証情報が必要です。さらに、ページにアクセスしてHTMLコードを取得し、変数名を取得する必要があります。さらに、ネットワークサーバへのクエリを入力するには、最低限のHTMLの知識が必要です。 <WRAP center round tip 90%> The practical method to design a WEB transactional test with several steps is to test them one by one in debugging mode. </WRAP> <WRAP center round tip 90%> 複数のステップを含む WEB トランザクションテストを設計する実用的な方法は、デバッグモードでステップを 1 つずつテストすることです。 </WRAP> Pandora コンソールのログイン URL が以下であると仮定します。 http://192.168.70.116/pandora_console/ HTML コードを確認すると、ログインフォームの変数は次の通りです。 * ''nick''> ユーザ名 * ''pass''> パスワード フォームの認証を通すためには、変数 ''variable_name'' および ''variable_value'' の両方が必要です。Pandora FMS コンソールのデフォルトは、''admin'' および ''pandora'' です。 最初のステップはフォームへのアクセスです。次に、ユーザとパスワードを送り認証します。(認証の成功を 2つ目のステップで確認します) <code> task_begin post http://192.168.70.116/pandora_console/index.php?login=1 variable_name nick variable_value admin variable_name pass variable_value pandora cookie 1 resource 1 task_end </code> 上記の設定で、ウェブページにアクセスし認証することができます。これにより、認証した状態でのウェブページ上の何らかのチェックを実行できます。cookie 1 トークンを使用して、前の手順で取得した cookie の永続性を維持します。 それらがなければ、セッションを再現することはできません。 2つ目のステップでは、ユーザーの詳細ページにアクセスし電話番号を探します。ユーザ "admin" のデフォルトは、555-555-555 です。 コンソールに正しくログインできているかどうかがわかります。 <code> task_begin get http://192.168.70.116/pandora_console/index.php?sec=workspace&sec2=operation/users/user_edit cookie 1 resource 1 check_string 555-555-5555 task_end </code> 最後にコンソールからログアウトし、ログアウトメッセージを探します。 <code> task_begin get http://192.168.70.116/pandora_console/index.php?bye=bye cookie 1 resource 1 check_string Logged out task_end </code> <wrap #ks1_6 /> ==== サーバステータスコードの確認 ==== To check the server status code of a website, select the type of module <wrap :en>**Remote HTTP module to check server status code**</wrap>: ウェブサイトのサーバステータスコードを確認するには、モジュールの種類を選択します <wrap :en>**Remote HTTP module to check server status code**</wrap>: <code> task_begin head https://pandorafms.com task_end </code> * It is important to use the ''head'' parameter to obtain the status code. * In server configuration, in section [[:en:documentation:pandorafms:installation:04_configuration#web_engine|web_engine]] ''curl'' must be typed in. * ステータス コードを取得するには、''head'' パラメータを使用することが重要です。 * サーバ設定のセクション [[:ja:documentation:pandorafms:installation:04_configuration#web_engine|web_engine]] に ''curl'' と入力する必要があります。 <wrap #ks1_7 /> ==== HTTP の簡単な認証 ==== Some pages may require simple HTTP authentication. It is generally used as a quick check, a minimal security //greeting// that allows access to more advanced security checks (encryption, data persistence, etc.). 一部のページでは、シンプルなHTTP認証が必要となる場合があります。これは通常、より高度なセキュリティチェック(暗号化、データの永続化など)へのアクセスを可能にする、最低限のセキュリティチェックとして使用されます。 <WRAP center round important 90%> * The use of quotation marks in the password for ''http_auth_pass'' is not supported. * Avoid using single quotation marks. </WRAP> <WRAP center round important 90%> * ''http_auth_pass'' に指定するパスワードではクォーテーションには対応していません。 * シングルクォート '' ' '' の利用は避けてください。 </WRAP> <wrap #ks1_8 /> ==== WEB サービスおよび API モニタリング ==== Pandora FMS と Goliat webチェックにて、[[https://en.wikipedia.org/wiki/Representational_state_transfer|REST]] APIを監視することができます。ただし、SOAP や XML-RPC を用いた API は監視できません。 例えば、動作しているときに数値(0からn)で返すような特定の Web API を監視したい場合、次のようなコードで、Pandora は何も応答が無い場合に障害と認識します。 <code> task_begin get http://artica.es/integria/include/api.php?user=my_user&pass=my_pass&op=get_stats&ms=opened,,1 check_string \n[0-9]+ task_end </code> 実際の応答は次の通りです。 <code> HTTP/1.1 200 OK Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Connection: close Date: Mon, 13 May 2013 15:39:27 GMT Pragma: no-cache Server: Apache Vary: Accept-Encoding Content-Type: text/html Expires: Thu, 19 Nov 1981 08:52:00 GMT Client-Date: Mon, 13 May 2013 15:39:27 GMT Client-Peer: 64.90.57.215:80 Client-Response-Num: 1 Client-Transfer-Encoding: chunked Set-Cookie: a81d4c5e530ad73e256b7729246d3d2c=pcasWqI6pZzT2x2AuWo602; path=/ 0 </code> 正規表現で出力を確認することにより、全体が正しく動作しているかを確認できます。より複雑な出力の場合は、それに合わせた正規表現を用います。データ部分だけでなく、応答内容全体をチェックすることに注意してください。そのため、HTTP ヘッダーにもマッチさせることができます。 別の例: <code> task_begin get https://swapi.dev/api/planets/1/ get_content Tatooine task_end </code> この場合、モジュールが監視を実行できるようにするデータのタイプは、'Remote HTTP module to retrieve string data (web_content_string)' である必要があります。 <code> task_begin get https://pokeapi.co/api/v2/pokemon/ditto/ get_content imposter task_end </code> 上記のモジュールと同様に、モジュールが正しく機能するには、定義されたデータのタイプが Remote HTTP module to retrieve string data (web_content_string)' である必要があります。 **get_content_advanced** でモジュールを作成することもできます。 <code> task_begin get https://api.hillbillysoftware.com/Awards/ByYear/1990 get_content_advanced "Nominee":"([A-Za-z]]+)","Year":"1990" task_end </code> この呼び出しは以下を返します。 [[:wiki:apiwiki1.png?id=ja:documentation:03_monitoring:06_web_monitoring&media=wiki:apiwiki1.png|{{ :wiki:apiwiki1.png?nolink&600 }}]] Pandora FMS は、次のように結果を表示します。 [[:wiki:apiwiki2.png?id=ja:documentation:03_monitoring:06_web_monitoring&media=wiki:apiwiki2.png|{{ :wiki:apiwiki2.png?nolink&400 }}]] <WRAP center round important 90%> * It is important to correctly define the capture groups in parentheses so that the call is performed properly. * When making API calls, it is important to note that the target API must have permissions to be queried. </WRAP> <WRAP center round important 90%> * 呼び出しが適切に実行されるように、括弧内のキャプチャグループを正しく定義することが重要です。 * API 呼び出しを行う場合、対象 API にクエリを実行するための権限が必要であることに注意することが重要です。 </WRAP> <wrap #ks1_9 /> ==== 拡張オプション ==== <wrap #ks1_9_1 /> === HTTP ヘッダーのカスタマイズ === //header// オプションで、HTTP ヘッダのカスタマイズしたり追加したりできます。たとえば、//Host// HTTP ヘッダーを変更するには次のようにします。 <code> task_begin get http://192.168.1.5/index.php header Host 192.168.1.1 task_end </code> <wrap #ks1_9_2 /> === ウェブチェックのデバッグ === ウェブチェックをデバッグしたい場合は、''debug <ログファイル>'' オプションを追加します。''ログファイル.req'' および ''ログファイル.res'' というファイルが作成され、HTTP リクエストと応答が記録されます。たとえば次のようにします。 <code> task_begin get http://192.168.1.5/index.php debug /tmp/request.log task_end </code> <wrap #ks1_9_3 /> === LWP の代わりの Curl の利用 === LWP は、複数スレッドで HTTPS リクエストを実行するとクラッシュすることがあります(OpenSSL の制約による)。代替としては [[https://curl.se/dlwiz/|curl ツール]] を利用することです。この問題を解決するためには、///etc/pandora/pandora_server.conf// を編集し、次の行を加えます。 <code> web_engine curl </code> Pandora FMS サーバを再起動すると、ウェブチェックに LWP の代わりに Curl バイナリが利用されます。 <wrap #ks2 /> ===== 高度なトランザクション監視 ===== In addition to the feature offered by PFMS Web server, there is another way to perform transactional monitoring: the [[:en:documentation:pandorafms:monitoring:13_user_monitorization|WEB User Experience Monitoring (WUX)]]. PFMS ウェブサーバが提供する機能に加えて、トランザクション監視を実行する別の方法があります: [[:ja:documentation:pandorafms:monitoring:13_user_monitorization|WEB ユーザエクスペリエンス監視 (WUX)]]。 [[ja:documentation:start|Pandora FMS ドキュメント一覧に戻る]] ===== (OBSOLETE) ===== ==== プロキシ経由でのウェブチェック ==== ウェブチェックは、プロキシ経由でも行うことができます。プロキシを設定するには、//拡張オプション(Advanced options)// をクリックすると表示される、//プロキシURL(Proxy URL)// フィールドにプロキシの URL を設定する必要があります。 例えば、URL は次のようになります。 http://proxy.domain.com:8080 認証が必要なプロキシの場合は、次のように ''my-user'' にユーザ名、''my_pwd'' にパスワードを指定します。 http://my_user:my_pwd@proxy.domain.com:8080 {{ wiki:Goliat_proxy_conf.png?700 }} ==== Webコンテンツの取得 ==== Sometimes monitoring does not consist of finding out whether a specific Web site is working or how long it takes, but to get a real time value, such as the total number of modules registered in the same PFMS server [[:en:documentation:08_technical_reference:02_annex_externalapi#get_total_modules|through the API]]. For this example a module called **Remote HTTP module to retrieve numeric data** will be used with the appropriate regular expression: 特定の Web サイトが稼動しているか、どれくらい時間がかかっているかを知りたいわけではなく、[[:ja:documentation:08_technical_reference:02_annex_externalapi#get_total_modules|API を通して]]Pandora FMS サーバに登録されたモジュール数などのコンテンツの内容を確認したい場合もあります。そのためには、適切な正規表現で **Remote HTTP module to retrieve numeric data** モジュールを利用します。 <code> task_begin get http://127.0.0.1/pandora_console/include/api.php?apipass=1234&user=internal_API&pass=1234&op=get&op2=total_modules&id=0 get_content \d+ task_end </code> 出力は次のようになります。 {{ :wiki:pfms-creating_web_modules-goliat_server-img_100.png }} It is also possible to specify a more complex regular expression for collecting data from more complex HTTP responses with the ''get_content_advanced'' configuration token. In this **didactic** example, the year is obtained in the footer of Pandora FMS official documentation (and stored in a string data type, **Remote HTTP module to retrieve string data**):{{ :wiki:pfms-creating_web_modules-goliat_server-img_110.png }} また、より複雑な HTTP 応答からのデータを収集するための正規表現を設定トークン ''get_content_advanced'' で指定することもできます。この**実践的な**例では、Pandora FMS 公式ドキュメントのフッターから年を取得します(また、文字列データタイプ **Remote HTTP module to retrieve string data** で保存します: {{ :wiki:pfms-creating_web_modules-goliat_server-img_110.png }} <code> task_begin get https://pandorafms.com/manual/ get_content_advanced \(c\) ([\d]+) Pandora FMS\(tm\) </span> task_end </code> {{ :wiki:pfms-creating_web_modules-goliat_server-img_120.png }}Note that the inverse interval has been used: if a string **other than** ''2022'' is received, the module will go into critical. {{ :wiki:pfms-creating_web_modules-goliat_server-img_120.png }}しきい値の反転が使用されていることに注意してください。''2022'' 以外の文字列を受信すると、モジュールは障害状態になります。 <WRAP center round important 75%> * The part of the regular expression defined in ''get_content_advanced'' must be enclosed in brackets. * If the text to be looked for contains parentheses, you must escape the characters by means of the backslash ''\''. </WRAP> <WRAP center round important 75%> * ''get_content_advanced'' に定義する正規表現は、カッコでくくらなければいけません。 * 検索するテキストにカッコが含まれている場合は、バックスラッシュ ''\'' を使用して文字をエスケープする必要があります。 </WRAP> {{ :wiki:pfms-creating_web_modules-goliat_server-img_130.png }} To configure the thresholds that will trigger warning or critical status, use the module configuration to verify that the received string matches what is expected. 警告または障害状態のしきい値を設定するには、モジュールの設定を使用して、受信した文字列が期待どおりのものであることを確認します。 ==== WEB リクエストの動作 ==== 拡張プロパティのフィールドは他のタイプのモジュールのフィールドと似ていますが、WEB チェックではいくつかの異なるフィールドがあります。 **タイムアウト(Timeout)** これはリクエストのタイムアウトです。この時間を超えるとリクエストは破棄されます。 **エージェントブラウザID(Agent browser id)** これは、特定のページが一部の Web ブラウザのみを受け入れる場合に使用する Web ブラウザの識別子です。(詳細は、https://www.zytrax.com/tech/web/browser_ids.htm を参照してください) **リクエスト(Requests)** Pandora FMS は、このパラメータで示された回数だけチェックを繰り返します。 チェックの 1つが失敗した場合、障害とみなされます。モジュール内のチェックの数に応じて、一定数のページが取得されます。 つまり、モジュールが 3つのチェックで構成されている場合は、3ページがダウンロードされ、リクエストフィールドに値が設定されている場合は、ダウンロード数はその数を掛け合わせた数になります。 モジュールが処理を完了するのにかかる合計時間を把握するには、これを覚えておくことが重要です。 **リトライ(Retries)** 成功するまで **リクエスト(Request)** を実行する数です。例: * リトライ = 2、リクエスト = 1: 最初のテストに失敗すると、もう一度実行し、2回目で成功すると、正常と判断します。 * リトライ = 1、リクエスト = 2: 2回のチェックを実行します。しかし一方の失敗で、障害と判断します。 ==== HTTPS モニタリング ==== Goliat は HTTP と HTTPS の両方をチェックできます。 HTTPS を利用しているセキュリティで保護されたウェブサイトのチェックを行うには、その URL にプロトコルを組み込むだけです。 <code> task_begin get https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=zpwhtygjntrz&ss=1&scc=1<mpl=default<mplcache=2 cookie 1 resource 0 check_string Google task_end </code> CKG Edit ja/documentation/pandorafms/monitoring/06_web_monitoring.txt 最終更新: 2025/11/02 04:41by junichi