Docs » Configure application receivers » Configure application receivers for caches and memory » OPcache

OPcache 🔗

Description 🔗

The Splunk Distribution of OpenTelemetry Collector provides this integration as the collectd/opcache monitor via the Smart Agent Receiver. This monitor uses opcache_get_status() to monitor OPcache, which improves PHP performance by storing precompiled script bytecode in shared memory.

Setup 🔗

You must install the following PHP script on your PHP web server:

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

Here is an example using NGINX:

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;
}

Put the script named opcache_stat.php into /srv/http/monitoring then:

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
},
#...

Installation 🔗

This monitor is available in the SignalFx Smart Agent Receiver, which is part of the Splunk Distribution of OpenTelemetry Collector.

To install this integration:

  1. Deploy the Splunk Distribution of OpenTelemetry Collector to your host or container platform.

  2. Configure the monitor, as described in the next section.

Configuration 🔗

This Splunk Distribution of OpenTelemetry Collector allows embedding a Smart Agent monitor configuration in an associated Smart Agent Receiver instance.

Note: Providing an OPcache monitor entry in your Smart Agent or Collector configuration is required for its use. Use the appropriate form for your agent type.

Smart Agent 🔗

To activate this monitor in the Smart Agent, add the following to your agent configuration:

monitors:  # All monitor config goes under this key
 - type: collectd/opcache
   ...  # Additional config

See Smart Agent example configuration for an autogenerated example of a YAML configuration file, with default values where applicable.

Splunk Distribution of OpenTelemetry Collector 🔗

To activate this monitor in the Splunk Distribution of OpenTelemetry Collector, add the following to your agent configuration:

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

See configuration examples for specific use cases that show how the collector can integrate and complement existing environments.

Configuration examples 🔗

If the status script is exposed on an endpoint other than /opcache_stat.php, then you can use the path configuration option, as shown in the following example:

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

You can also define the entire URL using the url configuration option, as shown in the following example, but useHTTPS is ignored if you use this option.

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

Configuration settings 🔗

The following table shows the configuration options for this monitor:

Option Required Type Description
host no string The host name of the web server (for example, 127.0.0.1).
port no integer The port number of the web server (for example, 80). (default: 0)
useHTTPS no bool If true, the monitor uses an HTTPS connection. (default: false)
path no string The URL path to use for the scrape URL for the OPcache script. (default: /opcache_stat.php)
url no string The URL, either a final URL or a Go template, that is populated with the host, port, and path values.
name no string This is sent as the plugin_instance dimension and can be any name you like.

Metrics 🔗

Dimensions 🔗

The following dimensions might occur on metrics emitted by this monitor. Some dimensions may be specific to certain metrics.

Name Description
plugin_instance Set to whatever you set in the name configuration option.