|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SimpleSAML\Module\monitor\TestSuite\Store; |
|
4
|
|
|
|
|
5
|
|
|
use \SimpleSAML\Module\monitor\TestCase as TestCase; |
|
6
|
|
|
|
|
7
|
|
|
final class Memcache extends \SimpleSAML\Module\monitor\TestSuite |
|
|
|
|
|
|
8
|
|
|
{ |
|
9
|
|
|
/* |
|
10
|
|
|
* @return void |
|
11
|
|
|
*/ |
|
12
|
|
|
protected function initialize() {} |
|
13
|
|
|
|
|
14
|
|
|
/* |
|
15
|
|
|
* @return void |
|
16
|
|
|
*/ |
|
17
|
|
|
protected function invokeTestSuite() |
|
18
|
|
|
{ |
|
19
|
|
|
$monitor = $this->getMonitor(); |
|
20
|
|
|
$globalConfig = $monitor->getGlobalConfig(); |
|
21
|
|
|
|
|
22
|
|
|
// Check Memcache-servers |
|
23
|
|
|
$class = class_exists('Memcache') ? 'Memcache' : (class_exists('Memcached') ? 'Memcached' : false); |
|
24
|
|
|
if ($class === false) { |
|
25
|
|
|
$serverGroups = $globalConfig->getValue('memcache_store.servers'); |
|
26
|
|
|
$serverGroupName = array_map(function($i) { |
|
27
|
|
|
$tmp = array_keys($i); |
|
28
|
|
|
return 'Server Group #' . ++$tmp[0]; |
|
29
|
|
|
}, $serverGroups); |
|
30
|
|
|
|
|
31
|
|
|
$this->setState(State::FATAL); |
|
32
|
|
|
$this->addMessage(State::FATAL, 'Memcache health', implode(PHP_EOL, $serverGroupName), 'Missing PHP module'); |
|
33
|
|
|
|
|
34
|
|
|
} else { |
|
35
|
|
|
$stats = SimpleSAML_Memcache::getRawStats(); |
|
36
|
|
|
|
|
37
|
|
|
foreach ($stats as $key => $serverGroup) { |
|
38
|
|
|
$groupName = is_numeric($key) ? '#' . ++$key : "`$key'"; |
|
39
|
|
|
$groupTests = array(); |
|
40
|
|
|
|
|
41
|
|
|
foreach ($serverGroup as $host => $serverStats) { |
|
42
|
|
|
$groupTests[] = new TestCase\Store\Memcache\Server($this, array('server_stats' => $serverStats, 'host' => $host)); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
$test = new TestCase\Store\Memcache\ServerGroup($this, array('tests' => $groupTests, 'group' => $groupName)); |
|
46
|
|
|
$this->addTest($test); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
$tests = $this->getTests(); |
|
50
|
|
|
foreach ($tests as $serverGroup) { |
|
51
|
|
|
$this->addMessages($serverGroup->getMessages()); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
$this->calculateState(); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.