github.com/mackerelio/mackerel-agent-plugins@v0.89.3/mackerel-plugin-php-opcache/lib/php-opcache.php (about)

     1  <?php
     2  
     3  header("Content-Type: text/plain");
     4  
     5  $status = opcache_get_status();
     6  $config = opcache_get_configuration();
     7  
     8  $stats = array(
     9      // memory_usage
    10      'used_memory'   =>   $status['memory_usage']['used_memory'],
    11      'free_memory'   => $status['memory_usage']['free_memory'],
    12      'wasted_memory' => $status['memory_usage']['wasted_memory'],
    13      'current_wasted_percentage' => $status['memory_usage']['current_wasted_percentage'],
    14  
    15      // opcache_statistics
    16      'num_cached_scripts'   => $status['opcache_statistics']['num_cached_scripts'],
    17      'num_cached_keys'      => $status['opcache_statistics']['num_cached_keys'],
    18      'max_cached_keys'      => $status['opcache_statistics']['max_cached_keys'],
    19      'hits'                 => $status['opcache_statistics']['hits'],
    20      'oom_restarts'         => $status['opcache_statistics']['oom_restarts'],
    21      'hash_restarts'        => $status['opcache_statistics']['hash_restarts'],
    22      'manual_restarts'      => $status['opcache_statistics']['manual_restarts'],
    23      'misses'               => $status['opcache_statistics']['misses'],
    24      'blacklist_misses'     => $status['opcache_statistics']['blacklist_misses'],
    25      'blacklist_miss_ratio' => $status['opcache_statistics']['blacklist_miss_ratio'],
    26      'opcache_hit_rate'     => $status['opcache_statistics']['opcache_hit_rate'],
    27  );
    28  
    29  foreach( $stats as $name => $value ){
    30      echo sprintf( "%s:%d\n", $name,  $value );
    31  }