Monitoring And Debugging Memcached Server Using phpMemCachedAdmin | KutuKupret » KutuKupret
Jun 132011
 

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. :D

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

Share

  6 Responses to “Monitoring And Debugging Memcached Server Using phpMemCachedAdmin”

Comments (5) Pingbacks (1)
  1. 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. Thanks. I just managed by hiding the errors on the interface and puting them to the log.

    Waiting for an update.

    Thanks.

  3. 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

 Leave a Reply

(required)

(required)


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>