php Code:
// From downloadzonly.blogspot.com$memcache = new Memcache
;foreach ($vbulletin->config['Misc']['memcacheserver'] as $key => $server) { $memcache->addServer($server, $vbulletin->config['Misc']['memcacheport'][$key], 1, 1, 1, 15, true);}$stats = $memcache->getExtendedStats();$memcache->close();$labels = array ( 'host' => 'Host', 'pid' => 'PID', 'uptime' => 'Daemon Uptime', 'time' => 'Server Time', 'version' => 'Version', 'pointer_size' => 'Pointer Bits', 'rusage_user' => 'RUsage User', 'rusage_system' => 'RUsage System', 'curr_items' => 'Current Items', 'total_items' => 'Total Items', 'bytes' => 'Memory Used', 'curr_connections' => 'Current Connections', 'total_connections' => 'Total Connections', 'connection_structures' => 'Connection Structures', 'cmd_flush' => 'Flushes', 'cmd_get' => 'Gets', 'cmd_set' => 'Sets', 'get_hits' => 'Get Hits', 'get_misses' => 'Get Misses', 'delete_hits' => 'Delete Hits', 'delete_misses' => 'Delete Misses', 'incr_hits' => 'Increment Hits', 'incr_misses' => 'Increment Misses', 'decr_hits' => 'Decrement Hits', 'decr_misses' => 'Decrement Misses', 'cas_hits' => 'CAS Hits', 'cas_misses' => 'CAS Misses', 'cas_badval' => 'CAS Bad Value', 'auth_cmds' => 'Auth Commands', 'auth_errors' => 'Auth Errors', 'evictions' => 'Evictions', 'reclaimed' => 'Reclaimed', 'bytes_read' => 'Data Read In', 'bytes_written' => 'Data Written Out', 'limit_maxbytes' => 'Memory Allocated', 'threads' => 'Threads', 'accepting_conns' => 'Accepting Connections', 'conn_yields' => 'Connection Yields', 'listen_disabled_num' => 'Listening Disabled Num', 'latency' => 'Latency Test', );$data = array('Host' => '', 'Latency Test' => '', 'Memory Allocated' => '', 'Memory Used' => '', 'Current Items' => '', 'Total Items' => '');$i=1;foreach($stats as $key => $val) { if (is_array($val)) { $data[$labels['host']][] = $key; foreach($val as $key2 => $val2) { $data[$labels[$key2]][] = (strpos($key2, 'bytes') !== false) ? vb_number_format
($val2, 2, true) . iif
(preg_match("#(bytes_read|bytes_written)#si", $key2), ' (' . vb_number_format
(intval($val2/$val['uptime']), 2, true) . '/sec)') : ($key2 == 'time' ?
date("M j, Y, G:i:s", $val2) : (preg_match("#(curr_items|total_items|curr_connections|total_connections|connection_structures|cmd_get|cmd_set|get_hits|get_misses)#si", $key2) ?
number_format($val2) : ($key2 == 'uptime' ?
intval($val2 / 86400) . 'd, ' . intval(($val2 % 86400) / 3600) . 'h, ' . intval(($val2 % 3600) / 60) . 'm, ' . intval($val2 % 60) . 's' : $val2))) . iif
(preg_match("#(total_connections|cmd_get|cmd_set|bytes_read|bytes_written|get_hits|get_misses)#si", $key2), ' (' . intval($val2/$val['uptime']) . '/sec)'); } $latency = microtime(); $memcache = new Memcache
; $memcache->addServer($vbulletin->config['Misc']['memcacheserver'][$i]); $set = $memcache->set('latency-test', 'some value', 0, 10); $get = $memcache->get('latency-test'); $memcache->close(); $data[$labels['latency']][] = round ((microtime() - $latency) * 1000, 4) . ' ms'; $i++; }}print_table_start
();print_table_header
('Memcached Servers', count($stats) + 1);foreach($data as $key => $val) { print_cells_row
(array_merge((array)"<strong>$key</strong>", $val), 0, 0, -5, 'top', 0, 1);}print_table_footer
(2, '', '', false);