OPcache

Collectd OPcache モニターには、この Splunk Observability Cloud インテグレーションを使用してください。メリット、インストール、設定、メトリクスを参照してください

Splunk Distribution of OpenTelemetry Collectorは、Smart Agentレシーバーと collectd/opcache モニタータイプを使用し、opcache_get_status() 関数を使用してOPcacheからメトリクスを取得します。これは、コンパイル済みのスクリプトバイトコードを共有メモリに格納することでPHPのパフォーマンスを向上させます。

このインテグレーションはKubernetesとLinuxで利用できます。

メリット

インテグレーションを設定すると、これらの機能にアクセスできるようになります:

インストール

PHPセットアップ

以下のPHPスクリプトをPHPウェブサーバーにインストールしてください:

PHP
<?php
header('Content-Type: application/json');
$status=opcache_get_status();
echo json_encode($status,JSON_PRETTY_PRINT);

以下はNGINXを使用した例です:

YAML
location ~ /monitoring/.*\.php$ {
    #access_log off;
    allow 127.0.0.1;
    allow ::1;
    deny all;
    include fastcgi_params;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    fastcgi_param  PHP_ADMIN_VALUE "open_basedir=/var/log:/usr/bin:/srv/http/monitoring";
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass php-handler;
}

opcache_stat.php スクリプトを /srv/http/monitoring に入れ、以下のコマンドを実行します:

BASH
curl http://localhost/monitoring/opcache_stat.php
{
"opcache_enabled": true,
"cache_full": false,
"restart_pending": false,
"restart_in_progress": false,
"memory_usage": {
    "used_memory": 82614848,
    "free_memory": 183437232,
    "wasted_memory": 2383376,
    "current_wasted_percentage": 0.88787674903869629
},
#...

設定

このインテグレーションを有効にするには、Collector構成に以下を追加します:

YAML
receivers:
  smartagent/opcache:
    type: collectd/opcache
    ...  # Additional config

次に、設定ファイルの service.pipelines.metrics.receivers セクションにモニターを追加します:

YAML
service:
  pipelines:
    metrics:
      receivers: [smartagent/opcache]

例:エンドポイントを設定する

ステータススクリプトの結果が /opcache_stat.php 以外のエンドポイントになる場合は、次の例のように path 設定オプションを使用します:

YAML
monitors:
 - type: collectd/opcache
   host: localhost
   port: 80
   path: "/opcache"

次の例に示すように、url 設定オプションを使って完全な URL を定義することもできます:

YAML
monitors:
 - type: collectd/opcache
   host: localhost
   port: 80
   useHTTPS: true
   url: "http://{{.host}}:{{.port}}/opcache"
   # useHTTPS is ignored.

コンフィギュレーション設定

次の表に、このモニターの設定オプションを示します:

オプション

必須

タイプ

説明

host

いいえ

string

Web サーバーのホスト名。たとえば、127.0.0.1 のようになります。

port

いいえ

integer

Web サーバーのポート番号。たとえば、80 のようになります。デフォルトの

値は 0 です。

useHTTPS

いいえ

bool

true の場合、モニターは HTTPS 接続を使用します。デフォルト値

false です。

path

いいえ

string

OPcache スクリプトのスクレイプ URL のパス。デフォルト値

/opcache_stat.php です。

url

いいえ

string

最終的なURLか、Goテンプレート( host

port、および path の値 を入力)。

name

いいえ

string

モニターの名前。 plugin_instanceディメンションとして送信されます。

メトリクス

https://raw.githubusercontent.com/signalfx/splunk-otel-collector/main/internal/signalfx-agent/pkg/monitors/collectd/opcache/metadata.yaml

備考

トラブルシューティング

If you are a Splunk Observability Cloud customer and are not able to see your data in Splunk Observability Cloud, you can get help in the following ways.

Available to Splunk Observability Cloud customers

Available to prospective customers and free trial users

  • Ask a question and get answers through community support at Splunk Answers.

  • Join the Splunk community #observability Slack channel to communicate with customers, partners, and Splunk employees worldwide.