Conditions | 6 |
Paths | 9 |
Total Lines | 24 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | function memcacheMonitor_hook_sanitycheck(array &$hookinfo): void |
||
13 | { |
||
14 | Assert::keyExists($hookinfo, 'errors'); |
||
15 | Assert::keyExists($hookinfo, 'info'); |
||
16 | |||
17 | try { |
||
18 | $servers = \SimpleSAML\Memcache::getRawStats(); |
||
19 | } catch (\Exception $e) { |
||
20 | $hookinfo['errors'][] = '[memcacheMonitor] Error parsing memcache configuration: ' . $e->getMessage(); |
||
21 | return; |
||
22 | } |
||
23 | |||
24 | $allOK = true; |
||
25 | foreach ($servers as $group) { |
||
26 | foreach ($group as $server => $status) { |
||
27 | if ($status === false) { |
||
28 | $hookinfo['errors'][] = '[memcacheMonitor] No response from server: ' . $server; |
||
29 | $allOK = false; |
||
30 | } |
||
31 | } |
||
32 | } |
||
33 | |||
34 | if ($allOK) { |
||
35 | $hookinfo['info'][] = '[memcacheMonitor] All servers responding.'; |
||
36 | } |
||
38 |