Hi

here is a memcache statistics script
http://livebookmark.net/journal/2008/08/28/memcachephp-flushes-servers/

Is under the gpl.

Comments

vacilando’s picture

Subscribing

fizk’s picture

Thanks bennos, I hope someone using memcache will help us out here. I'm only running APC.

bennos’s picture

Have Memcache on some servers installed. How can I help?

fizk’s picture

Can you convert http://livebookmark.net/memcachephp/memcachephp.zip into something usable by this module?

I'll add /admin/cacherouter_stats/memcache to the menu, like so:

  $items['admin/cacherouter_stats/memcache'] = array(
    'title' => 'Memcache',
    'page callback' => 'cacherouter_stats_memcache_admin',
    'page arguments' => array(),
    'access callback' => 'cacherouter_stats_access_callback',
    'access arguments' => array('administer cacherouter stats'),
    'type' => MENU_LOCAL_TASK,
    'file' => './memcache/cacherouter_stats.memcache.inc',
    'weight'           => -10,
  );

All you have to do is make a directory called "memcache" and implement the function cacherouter_stats_memcache_admin in the file cacherouter_stats.memcache.inc.

The function cacherouter_stats_memcache_admin will display memcache statistics.

fizk’s picture

Memcache was surpisingly easy to setup... :) I'll start working on this task tonight.

fizk’s picture

Status: Active » Fixed

ok, this is done! Will be available in the next release.

bennos’s picture

wow you are fast.

vacilando’s picture

Does this visualize stats for Memcache API as well?

fizk’s picture

The function that sends commands looks like this:

public static function sendMemcacheCommand($server,$port,$command){

        $s = @fsockopen($server,$port);
        if (!$s){
            die("Cant connect to:".$server.':'.$port);
        }

        fwrite($s, $command."\r\n");

        $buf='';
        while ((!feof($s))) {
            $buf .= fgets($s, 256);
            if (strpos($buf,"END\r\n")!==false){ // stat says end
                break;
            }
            if (strpos($buf,"DELETED\r\n")!==false || strpos($buf,"NOT_FOUND\r\n")!==false){ // delete says these
                break;
            }
            if (strpos($buf,"OK\r\n")!==false){ // flush_all says ok
                break;
            }
        }
        fclose($s);
        return memcache_gui::parseMemcacheResults($buf);
    }

where command will be a string, like "stats".

fizk’s picture

bennos, thanks :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.