From c10a7a43c27d07a7bafb95c44efb586c2075f9c9 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Fri, 27 Feb 2009 07:20:23 +0000 Subject: [PATCH] memcacheMonitor: sanity check which checks availability of memcache servers git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1334 44740490-163a-0410-bde0-09ae8108e29a --- .../hooks/hook_sanitycheck.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 modules/memcacheMonitor/hooks/hook_sanitycheck.php diff --git a/modules/memcacheMonitor/hooks/hook_sanitycheck.php b/modules/memcacheMonitor/hooks/hook_sanitycheck.php new file mode 100644 index 000000000..88df04646 --- /dev/null +++ b/modules/memcacheMonitor/hooks/hook_sanitycheck.php @@ -0,0 +1,38 @@ +<?php + +/** + * 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.'; + } +} + + +?> \ No newline at end of file -- GitLab