|
- <?php
- /**
- * 请将$host和$port替换成您的Memcached服务器的ip和端口
- */
-
- $host = '127.0.0.1';
- $port = 11211;
- $keys = array (
- 'version',
- 'pointer_size',
- 'uptime',
- 'bytes_read',
- 'bytes_written',
- 'cmd_get',
- 'cmd_set',
- 'get_hits',
- 'get_misses',
- 'curr_connections',
- 'total_connections',
- 'curr_items',
- 'total_items',
- 'evictions',
- 'bytes',
- 'limit_maxbytes',
- 'rusage_user',
- 'rusage_system',
- );
-
- $memcache_obj = new Memcache;
- $retval = $memcache_obj->connect($host, $port);
- if (!$retval) die('Could not connect memcached.');
- $stats = $memcache_obj->getExtendedStats();
-
- header('Content-Type: text/plain; charset=UTF-8');
- echo "<pre>\n";
-
- $stat = $stats["$host:$port"];
- foreach ($keys as $key)
- {
- if (isset($stat[$key]))
- {
- $value = $stat[$key];
- echo "$key:$value\n";
- }
- }
-
- echo "</pre>\n";
复制代码 |
|