/** * Sanity check for memcache servers. * * This function verifies that all memcache servers work. * * @param array &$hookinfo hookinfo */ function memcacheMonitor_hook_sanitycheck(&$hookinfo) { assert('is_array($hookinfo)'); assert('array_key_exists("errors", $hookinfo)'); assert('array_key_exists("info", $hookinfo)'); try { $servers = SimpleSAML_Memcache::getRawStats(); } catch (Exception $e) { $hookinfo['errors'][] = '[memcacheMonitor] Error parsing memcache configuration: ' . $e->getMessage(); return; } $allOK = TRUE; foreach ($servers as $group) { foreach ($group as $server => $status) { if ($status === FALSE) { $hookinfo['errors'][] = '[memcacheMonitor] No response from server: ' . $server; $allOK = FALSE; } } } if ($allOK) { $hookinfo['info'][] = '[memcacheMonitor] All servers responding.'; } }
echo " echo 'extension=memcache.so' >/etc/php5/cli/conf.d/memcache.ini\n"; } exit(1); } /* This is the base directory of the simpleSAMLphp installation. */ $baseDir = dirname(dirname(__FILE__)); /* Add library autoloader. */ require_once $baseDir . '/lib/_autoload.php'; /* Initialize the configuration. */ $configdir = $baseDir . '/config'; SimpleSAML_Configuration::setConfigDir($configdir); /* Things we should warn the user about. */ $warnServerDown = 0; $warnBigSlab = 0; /* We use the stats interface to determine which servers exists. */ $stats = SimpleSAML_Memcache::getRawStats(); $keys = array(); foreach ($stats as $group) { foreach ($group as $server => $state) { if ($state === FALSE) { echo "WARNING: Server " . $server . " is down.\n"; $warnServerDown++; continue; } $items = $state['curr_items']; echo "Server " . $server . " has " . $items . " items.\n"; $serverKeys = getServerKeys($server); $keys = array_merge($keys, $serverKeys); } } echo "Total number of keys: " . count($keys) . "\n";