Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monitoring Memcached with PHP script

I've written a PHP script that I've scheduled with CRON to run every minute. The goal of the script is to verify that the memcached server is online. My strategy is simply to attempt to connect to the memcached server. If I connect successfully, I close the connection. If I do not successfully connect, I send an email alerting that memcached is offline.

My question: is this a sufficient test that memcached is up and running, or is it common practice to do more than just connect to memcached? Should I also test that I can set and retrieve a key/value pair?

Also, in the future, we may want to do more extensive monitoring of memcached so we can track memory usage, connections, number of requests, etc. Are there open source libraries for doing this from PHP? If so, which ones have performed nicely in your experience?

like image 510
TheBobalos Avatar asked May 30 '12 16:05

TheBobalos


People also ask

How do I monitor memcache?

Using memcstat. Installing the libmemcached-tools package will give you access to the memcstat command, which displays the operating status of a single or group of memcached servers. Usage is very simple.

What does Memcached do in PHP?

Memcached is an object caching framework. It is essentially used to cache the database queries, making a difference in dynamic websites like Drupal and WordPress to serve pages quicker. It can moreover significantly decrease resource use on an active web server by reducing calls to the database.

What is the difference between Memcache and Memcached?

They both have very basic difference while storing value. Memcache mostly considers every value as string whereas Memcached stores it value's original type.


1 Answers

You don't need to build anything. There are a number of PHP scripts intended for monitoring, debugging and displaying stats for a Memchached server.

There are two that I know of and work well:

  • phpmemcacheadmin full monitoring and debugging suite
  • memcache.php simple script sort of like apc.php (bundled in the archive file for a release)
like image 184
redslazer Avatar answered Sep 27 '22 17:09

redslazer