ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilGlobalCacheMetricsCollectedObjective.php
Go to the documentation of this file.
1 <?php
2 
24 
26 {
27  protected function getTentativePreconditions(Environment $environment): array
28  {
29  return [
31  new \ilDatabaseInitializedObjective()
32  ];
33  }
34 
35  protected function collectFrom(Environment $environment, Storage $storage): void
36  {
37  $db = $environment->getResource(Environment::RESOURCE_DATABASE);
38  $client_ini = $environment->getResource(Environment::RESOURCE_CLIENT_INI);
39 
40  if (!$client_ini) {
41  return;
42  }
43 
44  $config = (new ilGlobalCacheSettingsAdapter($client_ini, $db))->getConfig();
45 
46  $service = $config->getAdaptorName();
47  $storage->storeConfigText(
48  "service",
49  $service,
50  "The backend that is used for the ILIAS cache."
51  );
52  $storage->storeConfigBool(
53  "active",
54  $config->isActivated()
55  );
56 
57  $servers = $config->getNodes();
58  if (
59  $service === Config::MEMCACHED &&
60  $servers !== []
61  ) {
62  $server_collection = [];
63  foreach ($servers as $server) {
64  $host = new Metric(
65  Metric::STABILITY_CONFIG,
66  Metric::TYPE_TEXT,
67  $server->getHost()
68  );
69  $port = new Metric(
70  Metric::STABILITY_CONFIG,
71  Metric::TYPE_GAUGE,
72  $server->getPort()
73  );
74  $weight = new Metric(
75  Metric::STABILITY_CONFIG,
76  Metric::TYPE_GAUGE,
77  $server->getWeight()
78  );
79 
80  $server_collection[] = new Metric(
81  Metric::STABILITY_CONFIG,
82  Metric::TYPE_COLLECTION,
83  [
84  "host" => $host,
85  "port" => $port,
86  "weight" => $weight
87  ],
88  "Configured memcached node."
89  );
90  }
91 
92  $nodes = new Metric(
93  Metric::STABILITY_CONFIG,
94  Metric::TYPE_COLLECTION,
95  $server_collection,
96  "Collection of configured memcached nodes."
97  );
98  $storage->store("memcached_nodes", $nodes);
99  }
100 
101  $component_activation = [];
102  foreach (ilGlobalCache::getAvailableComponents() as $component) {
103  $component_activation[$component] = new Metric(
104  Metric::STABILITY_CONFIG,
105  Metric::TYPE_BOOL,
106  $config->isComponentActivated($component)
107  );
108  }
109  $component_activation = new Metric(
110  Metric::STABILITY_CONFIG,
111  Metric::TYPE_COLLECTION,
112  $component_activation,
113  "Which components are activated to use caching?"
114  );
115  $storage->store(
116  "components",
117  $component_activation
118  );
119  }
120 }
storeConfigBool(string $key, bool $value, ?string $description=null)
store(string $key, Metric $metric)
Store some metric in the storage.
storeConfigText(string $key, string $value, ?string $description=null)
A metric is something we can measure about the system.
Definition: Metric.php:33
Base class to simplify collection of metrics.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
An environment holds resources to be used in the setup process.
Definition: Environment.php:27
$server
Definition: shib_login.php:24
$service
Definition: ltiservices.php:40