Atom Feed
Comments Atom Feed


Similar Articles

14/05/2015 22:35
PHP APC on Cacti via SNMP
08/01/2015 22:58
Nginx on Cacti via SNMP
08/01/2015 22:59
php-fpm on Cacti via SNMP
14/11/2009 13:46
Apache stats on Cacti (via SNMP)
31/10/2009 14:46
SMART stats on Cacti (via SNMP)
13/02/2015 22:51
opendkim on Cacti via SNMP

Recent Articles

23/04/2017 14:21
Raspberry Pi SD Card Test
07/04/2017 10:54
DNS Firewall (blackhole malicious, like Pi-hole) with bind9
28/03/2017 13:07
Kubernetes to learn Part 4
23/03/2017 16:09
Kubernetes to learn Part 3
21/03/2017 15:18
Kubernetes to learn Part 2

Glen Pitt-Pladdy :: Blog

PHP Zend opcache on Cacti via SNMP

Previously I wrote up Cacti for PHP APC cache. While APC is widely used, Zend opcache has rapidly become the default PHP opcode cache for many. Monitoring the opcode cache is very important for PHP since if it is not working efficiently (eg. many evictions due to lack of memory) then PHP is going to be burning a lot of resource on continually recompiling code.

This is essentially the same tricks for a new cache. Before attempting this, look at my previous article on SNMP basics takes look at general setup of snmpd and how basic extensions work.

Extracting the statistics

To extract stats from opcache we use the opcache_get_status() function and format the key fields as plain text to make it easy for snmpd to ingest.

Download: PHP opcache monitoring scripts and Cacti Templates on GitHub

The monitoring script opcachestat.php can be put somewhere it can be served by the webserver you are using with PHP. For example the configuration for Nginx with php-fpm for this placed in the root of a web site would be:

        location /opcachestat.php {
                access_log off;
                allow ::1;
                deny all;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                root /path/to/root/of/site/;
                include fastcgi_params;

Then to pick the data up via snmpd, add the following lines to /etc/snmp/snmpd.conf to call the script for appropriate SNMP requests:

# php opcache
extend phpopcache /usr/bin/curl --silent http://localhost/opcachestat.php

Restart snmpd and you should be able to get basic stats via SNMP.

Cacti Templates

I have generated some basic Cacti Templates for opcache.

Simply import the template cacti_host_template_php_opcache.xml, and add the graphs you want to the appropriate device graphs in Cacti. It should just work if your SNMP is working correctly for that device (ensure other SNMP parameters are working for that device).

Graph Screen Shots

From an extremely lightweight site...

Cacti PHP opache Efficiency

Cacti PHP opache Cache Usage

Cacti PHP opache Cached Scripts

Cacti PHP opache Cached Keys



Are you human? (reduces spam)
Note: Identity details will be stored in a cookie. Posts may not appear immediately