From 89b402d2497f12f78210b9a328006a079c4b39b4 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Thu, 7 Feb 2008 14:57:37 +0000 Subject: [PATCH] MemcacheStore: Added getStats() function. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@262 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/MemcacheStore.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/SimpleSAML/MemcacheStore.php b/lib/SimpleSAML/MemcacheStore.php index f84020861..c8b3dd841 100644 --- a/lib/SimpleSAML/MemcacheStore.php +++ b/lib/SimpleSAML/MemcacheStore.php @@ -3,6 +3,9 @@ /* We need access to the configuration from config/config.php. */ require_once('SimpleSAML/Configuration.php'); +/* For access to SimpleSAML_Utilities::transposeArray. */ +require_once('SimpleSAML/Utilities.php'); + /* * This file is part of SimpleSAMLphp. See the file COPYING in the * root of the distribution for licence information. @@ -629,5 +632,30 @@ class SimpleSAML_MemcacheStore { return $expireTime; } + + + /** + * This function retrieves statistics about all memcache server groups. + * + * @return Array with the names of each stat and an array with the value for each + * server group. + */ + public static function getStats() + { + $ret = array(); + + foreach(self::getMemcacheServers() as $sg) { + $stats = $sg->getExtendedStats(); + if($stats === FALSE) { + throw new Exception('Failed to get memcache server status.'); + } + + $stats = SimpleSAML_Utilities::transposeArray($stats); + + $ret = array_merge_recursive($ret, $stats); + } + + return $ret; + } } ?> -- GitLab