diff --git a/lib/SimpleSAML/MemcacheStore.php b/lib/SimpleSAML/MemcacheStore.php index f8402086132dbfc5d2bad60f38ff173139aeb213..c8b3dd841fa8f2b00e8917ce355bec05345f376b 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; + } } ?>