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