Monitoring Memcached servers

By jbayer - Last updated: Wednesday, August 15, 2012 - Save & Share - Leave a Comment

If you are using memcached, you may want to know if it is running or not, and if it isn’t, to get it started.

The attached script will do that.  Run it as on the server which is running the memcached instance(s), as root, from cron, once a minute, and it will check.

In our case, we run multiple memcached instances on a single server.  We run memcached on ports 11211 and 11212.  The 11212 is used by PHP for session management.  The 11211 is used by our application to cache commonly used information.

An example cron entry for this would be:


* * * * * /usr/local/bin/

You need to set a few parameters at the top to customize it for your configuration.

The script can monitor memcached instances on both the local and remote systems.

The script was written and tested on Redhat and CentOS systems.  For any others, the only line you might have to change is the service restart line, around line 78.

Updated 10/25/2012

Added internal loop & sleep, so that multiple checks can be done in a single minute

  memcached_server_status.tar.gz (1.7 KiB, 0 hits)

Posted in Bash, Open Source • • Top Of Page

Write a comment