summaryrefslogtreecommitdiffstats
path: root/memcache_admin/memcache_admin.module
diff options
context:
space:
mode:
Diffstat (limited to 'memcache_admin/memcache_admin.module')
-rw-r--r--memcache_admin/memcache_admin.module76
1 files changed, 38 insertions, 38 deletions
diff --git a/memcache_admin/memcache_admin.module b/memcache_admin/memcache_admin.module
index 5ac5bc8..b4c12ac 100644
--- a/memcache_admin/memcache_admin.module
+++ b/memcache_admin/memcache_admin.module
@@ -59,9 +59,11 @@ function memcache_admin_menu() {
);
$memcache_servers = variable_get('memcache_servers', array('127.0.0.1:11211' => 'default'));
$clusters = array();
- foreach ($memcache_servers as $server => $cluster) {
- $clusters[$cluster]['servers'][] = $server;
- $clusters[$cluster]['bin'] = _memcache_admin_get_bin_for_cluster($cluster);
+ foreach ($memcache_servers as $server => $bin) {
+ if ($cluster = dmemcache_object_cluster($bin)) {
+ $clusters[$cluster]['servers'][] = $server;
+ $clusters[$cluster]['bin'] = _memcache_admin_get_bin_for_cluster($cluster['cluster']);
+ }
}
$count = 0;
@@ -272,47 +274,45 @@ function memcache_admin_stats($bin = 'default') {
$output = '';
$server = array();
$stats = dmemcache_stats($bin, 'default', TRUE);
- if (empty($stats)) {
+ if (empty($stats[$bin])) {
// Failed to load statistics. Provide a useful error about where to get
// more information and help.
- drupal_set_message(t('There may be a problem with your Memcache configuration. Please review %readme and !more for more information.', array('%readme' => 'README.txt', 'admin/reports/status', '!more' => module_exists('memcache') ? t('visit the Drupal admin !status page', array('!status' => l(t('status report'), 'admin/reports/status'))) : t('!enable the memcache module', array('!enable' => l(t('enable'), 'admin/modules', array('fragment' => 'edit-modules-performance-and-scalability')))))), 'error');
+ drupal_set_message(t('Failed to retreive statistics. There may be a problem with your Memcache configuration. Please review %readme and !more for more information.', array('%readme' => 'README.txt', 'admin/reports/status', '!more' => module_exists('memcache') ? t('visit the Drupal admin !status page', array('!status' => l(t('status report'), 'admin/reports/status'))) : t('!enable the memcache module', array('!enable' => l(t('enable'), 'admin/modules', array('fragment' => 'edit-modules-performance-and-scalability')))))), 'error');
}
else {
- if (count($stats[$bin])) {
- $stats = $stats[$bin];
- $aggregate = array_pop($stats);
- $mc = dmemcache_object($bin);
- if ($mc instanceof Memcached) {
- $version = t('Memcached v!version', array('!version' => phpversion('Memcached')));
- }
- elseif ($mc instanceof Memcache) {
- $version = t('Memcache v!version', array('!version' => phpversion('Memcache')));
+ $stats = $stats[$bin];
+ $aggregate = array_pop($stats);
+ $mc = dmemcache_object($bin);
+ if ($mc instanceof Memcached) {
+ $version = t('Memcached v!version', array('!version' => phpversion('Memcached')));
+ }
+ elseif ($mc instanceof Memcache) {
+ $version = t('Memcache v!version', array('!version' => phpversion('Memcache')));
+ }
+ else {
+ $version = t('Unknown');
+ drupal_set_message(t('Failed to detect the memcache PECL extension.'), 'error');
+ }
+ $memcache_servers = variable_get('memcache_servers', array('127.0.0.1:11211' => 'default'));
+
+ foreach ($stats as $server => $statistics) {
+ if (empty($statistics['uptime'])) {
+ drupal_set_message(t('Failed to connect to server at %address.', array('%address' => $server)), 'error');
}
else {
- $version = t('Unknown');
- drupal_set_message(t('Failed to detect the memcache PECL extension.'), 'error');
- }
- $memcache_servers = variable_get('memcache_servers', array('127.0.0.1:11211' => 'default'));
-
- foreach ($stats as $server => $statistics) {
- if (empty($statistics['uptime'])) {
- drupal_set_message(t('Failed to connect to server at %address.', array('%address' => $server)), 'error');
- }
- else {
- $servers[] = $server;
- $data['server_overview'][$server] = t('v!version running !uptime', array('!version' => check_plain($statistics['version']), '!uptime' => format_interval($statistics['uptime'])));
- $data['server_pecl'][$server] = t('n/a');
- $data['server_serialize'][$server] = t('n/a');
- $data['server_time'][$server] = format_date($statistics['time']);
- $data['server_connections'][$server] = _memcache_admin_stats_connections($statistics);
- $data['cache_sets'][$server] = _memcache_admin_stats_sets($statistics);
- $data['cache_gets'][$server] = _memcache_admin_stats_gets($statistics);
- $data['cache_counters'][$server] = _memcache_admin_stats_counters($statistics);
- $data['cache_transfer'][$server] = _memcache_admin_stats_transfer($statistics);
- $data['cache_average'][$server] = _memcache_admin_stats_average($statistics);
- $data['memory_available'][$server] = _memcache_admin_stats_memory($statistics);
- $data['memory_evictions'][$server] = number_format($statistics['evictions']);
- }
+ $servers[] = $server;
+ $data['server_overview'][$server] = t('v!version running !uptime', array('!version' => check_plain($statistics['version']), '!uptime' => format_interval($statistics['uptime'])));
+ $data['server_pecl'][$server] = t('n/a');
+ $data['server_serialize'][$server] = t('n/a');
+ $data['server_time'][$server] = format_date($statistics['time']);
+ $data['server_connections'][$server] = _memcache_admin_stats_connections($statistics);
+ $data['cache_sets'][$server] = _memcache_admin_stats_sets($statistics);
+ $data['cache_gets'][$server] = _memcache_admin_stats_gets($statistics);
+ $data['cache_counters'][$server] = _memcache_admin_stats_counters($statistics);
+ $data['cache_transfer'][$server] = _memcache_admin_stats_transfer($statistics);
+ $data['cache_average'][$server] = _memcache_admin_stats_average($statistics);
+ $data['memory_available'][$server] = _memcache_admin_stats_memory($statistics);
+ $data['memory_evictions'][$server] = number_format($statistics['evictions']);
}
}