Monitoring And Debugging Memcached Server Using phpMemCachedAdmin

I have found a very cool program for monitoring and debugging Memcached server, it’s called  phpMemcachedAdmin. This program allows to see in real-time (top-like) or from the start of the server, stats for get, set, delete, increment, decrement, evictions, reclaimed, cas command, as well as server stats (network, items, server version) with googlecharts and server internal configuration You can go further to see each server slabs, occupation, memory wasted and items (key & value).

Another part can execute commands to any memcached server : get, set, delete, flush_all, as well as execute any commands (like stats) with telnet To extract these informations, phpMemCacheAdmin uses, as you wish, direct communication with server, PECL Memcache or PECL Memcached API.

Explanation above is an excerpt from the website. This is a simple guide how do I install phpMemCachedAdmin.

Download phpMemCachedAdmin tarball

# wget http://phpmemcacheadmin.googlecode.com/files/phpMemcachedAdmin-1.2.1-r233.tar.gz

Since we will install in /var/www/html/memcached/ directory, run this command:

# mkdir -p /var/www/html/memcached
# tar -xvzf phpMemcachedAdmin-1.2.1-r233.tar.gz -C /var/www/html/memcached/
# chmod 0777 /var/www/html/memcached/Config/Memcache.php

Apache Configuration

( i’m using apache as reverse proxy backend )

# cd /etc/httpd/conf.d
# vi memcached.conf


memcached.conf

<VirtualHost *:80>
	ServerName   memcached.example.com
	UseCanonicalName Off
	ServerAdmin  "webmaster@example.com"
	DocumentRoot "/var/www/html/memcached"
	CustomLog  /var/log//httpd/memcached.example.com-access_log common
	ErrorLog   /var/log/httpd/memcached.example.com-error_log
</VirtualHost>

In the actual configuration, Apache only listens on ip address 127.0.0.1
Restart apache:

# service httpd restart

Nginx Configuration

( reverse proxy front end )

# cd /etc/nginx/conf.d
# vi memcached.conf

Because phpMemCachedAdmin not protected with user / pass or other protection mechanisms by default, we will restrict access based on ip address. This is the easiest way. 😀

memcached.conf

server {
	listen 80;
		server_name  memcached.example.com;
		access_log   /var/log/nginx/memcached.example.com-access.log  main;

		location  / {
			allow my.private.ip.address/32;
			deny all;
			proxy_set_header Host $host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header X-Forwarded-Host $host;
			proxy_set_header X-Forwarded-Server $host;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_pass http://127.0.0.1:80;
		}
}

Restart nginx

#service nginx restart

These are examples of phpMemCachedAdmin screenshots

9 Comments

  1. Lengronne

    Hello,

    I have 300 lines of:

    Notice: Undefined index: get_hits in /var/www/cachemonitor/memcache/Library/Data/Analysis.php on line 246 Notice: Undefined index: cmd_set in /var/www/cachemonitor/memcache/Library/Data/Analysis.php on line 246 Notice: Undefined index: delete_hits in /var/www/cachemonitor/memcache/Library/Data/Analysis.php on line 246 Notice: Undefined index: cas_hits in /var/www/cachemonitor/memcache/Library/Data/Analysis.php on line 246 Notice: Undefined index: cas_badval in /var/www/cachemonitor/memcache/Library/Data/Analysis.php on line 246 Notice: Undefined index: incr_hits in /var/www/cachemonitor/memcache/Library/Data/Analysis.php on line 246 Notice: Undefined index: decr_hits in /var/www/cachemonitor/memcache/Library/Data/Analysis.php on line 246 Notice: Undefined index: mem_requested in /var/www/cachemonitor/memcache/Library/Data/Analysis.php on line 247 Notice: Undefined index: mem_requested in /var/www/cachemonitor/memcache/Library/Data/Analysis.php on line 247 Notice: Undefined index: get_hits in /var/www/cachemonitor/memcache/Library/Data/Analysis.php on line 246 Notice: Undefined index: cmd_set in /var/www/cachemonitor/memcache/Library/Data/Analysis.php on line 246 Notice: Undefined index: delete_hits in /var/www/cachemonitor/memcache/Library/Data/Analysis.php on line 246 Notice: Undefined index: cas_hits in /var/www/cachemonitor/memcache/Library/Data/Analysis.php on line 246 Notice: Undefined index: cas_badval in /var/www/cachemonitor/memcache/Library/Data/Analysis.php on line 246 Notice: Undefined index: incr_hits in /var/www/cachemonitor/memcache/Library/Data/Analysis.php on line 246 Notice: Undefined index: decr

    on the actually seeing page.

    Can you help me to fix that ?

    Thanks.

    • i think that’s because some variables in scripts doesn’t have any values(unset) / NULL. we can just ignore it by hiding the notices like this. error_reporting(E_ALL ^ E_NOTICE); . You can also turn off error reporting in your php.ini file or .htaccess file, but it is not considered as a good solution, better look if there’s any phpMemcachedAmin update. see if new version fixed these warnings.

  2. Lengronne

    Thanks. I just managed by hiding the errors on the interface and puting them to the log.

    Waiting for an update.

    Thanks.

  3. George Lee

    Dear,

    I just installed as described above.

    I got the following error message on my memcached server when access the admin web http://127.0.0.1:11211

    <28 new auto-negotiating client connection
    28: Client using the ascii protocol
    28 ERROR
    28 ERROR
    28 ERROR
    28 ERROR
    28 ERROR
    28 ERROR
    28 ERROR
    28 ERROR
    28 ERROR

    What is going wrong ?

    Thanks,
    George

  4. kosfar

    Hello,
    I want to use just nginx that is installed in a system to view PhpMemcachedAdmin dashboard.
    I extracted all files under /var/www/html/memcached, gave the appropriate permissions to folders and files and I had setup the following vhost:
    server {
    listen 8032;
    server_name memcachedadmin.charazay.com;
    access_log /var/log/nginx/phpMemCachedAdmin-access.log;
    index index.php;

    location / {
    root /var/www/html/memcached;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    include /etc/nginx/php.conf;
    default_type text/html;
    }
    }

    However, when I access memcachedadmin.charazay.com:8032 I get an “Access denied” message. What am I doing wrong? Thank in advance!

    • check your files pwrmission. are they belong to nginx?at least when you’re using php-cgi, php-cgi shloud be has read pesmission to the files.

  5. kosfar

    All files have read permissions from anybody.

  6. ersidam

    I use Memcache API and phpMemcachedAdmin 1.2.2
    if I want to add a string with length 110 my script read it well but admin GUI read like “x�+,,WH,NIL`��
    ��└�D
    �”+OT����!��a�a�&”

    but if string length is 3 GUI read well what is problem?

Leave a Reply

Your email address will not be published. Required fields are marked *