Thanks. That is helpful. I did modify a script I found on the horde site that cleans the lock files made by horde. Using the session id as a key you can tell if the session is still available in the memcached server. If you consider each session id to be a user then you can get an approximate count of the number of valid sessions in the memcached server and the total number of sessions (users) in a given period of time. I only clean the lock files once per day so it would be a 24 hour period. Below is a copy of the modified script.


<?php

# Connect to memcache
$memcache = new Memcache;
$memcache->connect('yourmemcacheserver', 11211);

# Walk through lock files
$dir = "/dir/containing/lock/files";
$total = 0;
$removed = 0;
$dh = opendir($dir) or die("Unable to open '$dir'");
while(($filename = readdir($dh)) !== false) {
    if (preg_match('/^lock_([a-z0-9]+)$/', $filename, $matches)) {
        $key = $matches[1];
        $total++;
        if ($memcache->get($key) === false) {
            $removed++;
        }
    }
}

closedir($dh);

$memcache->close();

echo "Number of daily users = $total\n";
$current = $total-$removed;
echo "Number of current users = $current\n";
?>


Graeme Wood wrote:
On Tue, 24 Mar 2009, robert sand wrote:


I was wondering if anyone out there has a php script I could use to get data from the memcached server?

What I'm looking for us total number concurrent users, and if possible number of stale sessions.

Thanks for your consideration.

memcached has no concept of users. However, the memcached website links to this PHP-based control panel developed by someone:

<http://livebookmark.net/journal/2008/05/21/memcachephp-stats-like-apcphp/>

No idea if it works.


--
Robert Sand.
mailto:[email protected]
1028 Kirby Drive
366 K Plz
Duluth, MN 55812-3095
218-726-6122        fax 218-726-7674

"Walk behind me I may not lead, Walk in front of me I may not follow,
Walk beside me and we walk together"  UTE Tribal proverb.
--
IMP mailing list - Join the hunt: http://horde.org/bounties/#imp
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: [email protected]

Reply via email to