ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilHttpMetricsCollectedObjective.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2020 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6
8{
9 public function getTentativePreconditions(Setup\Environment $environment) : array
10 {
11 return [
13 new \ilSettingsFactoryExistsObjective()
14 ];
15 }
16
17 public function collectFrom(Setup\Environment $environment, Setup\Metrics\Storage $storage) : void
18 {
19 $ilias_ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
20
21 if ($ilias_ini) {
22 $storage->storeConfigText(
23 "http_path",
24 $ilias_ini->readVariable("server", "http_path"),
25 "URL of the server."
26 );
27
28 if ($ilias_ini->readVariable("https", "auto_https_detect_enabled")) {
29 $header_name = new Setup\Metrics\Metric(
30 Setup\Metrics\Metric::STABILITY_CONFIG,
31 Setup\Metrics\Metric::TYPE_TEXT,
32 $ilias_ini->readVariable("https", "auto_https_detect_header_name"),
33 "The name of the header used for https detection in requests."
34 );
35 $header_value = new Setup\Metrics\Metric(
36 Setup\Metrics\Metric::STABILITY_CONFIG,
37 Setup\Metrics\Metric::TYPE_TEXT,
38 $ilias_ini->readVariable("https", "auto_https_detect_header_value"),
39 "The value in the named header that indicates usage of https in requests."
40 );
41 $https_metrics = new Setup\Metrics\Metric(
42 Setup\Metrics\Metric::STABILITY_CONFIG,
43 Setup\Metrics\Metric::TYPE_COLLECTION,
44 [
45 "header_name" => $header_name,
46 "header_value" => $header_value
47 ],
48 "The properties of a request used for https detection."
49 );
50 $storage->store("https_autodetection", $https_metrics);
51 } else {
52 $storage->storeConfigBool(
53 "https_autodetection",
54 false,
55 "Does the server attempt to detect https in incoming requests?"
56 );
57 }
58 }
59
60 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
61 if (!$factory) {
62 return;
63 }
64 $settings = $factory->settingsFor("common");
65
66 if ($settings->get("proxy_status")) {
67 $host = new Setup\Metrics\Metric(
68 Setup\Metrics\Metric::STABILITY_CONFIG,
69 Setup\Metrics\Metric::TYPE_TEXT,
70 $settings->get("proxy_host"),
71 "The host of the proxy."
72 );
73 $port = new Setup\Metrics\Metric(
74 Setup\Metrics\Metric::STABILITY_CONFIG,
75 Setup\Metrics\Metric::TYPE_TEXT,
76 $settings->get("proxy_port"),
77 "The port of the proxy."
78 );
79 $proxy = new Setup\Metrics\Metric(
80 Setup\Metrics\Metric::STABILITY_CONFIG,
81 Setup\Metrics\Metric::TYPE_COLLECTION,
82 [
83 "host" => $host,
84 "port" => $port
85 ],
86 "The proxy that is used for outgoing connections."
87 );
88 $storage->store("proxy", $proxy);
89 } else {
90 $storage->storeConfigBool(
91 "proxy",
92 false,
93 "Does the server use a proxy for outgoing connections?"
94 );
95 }
96 }
97}
An exception for terminatinating execution or to throw for unit testing.
A metric is something we can measure about the system.
Definition: Metric.php:18
getTentativePreconditions(Setup\Environment $environment)
collectFrom(Setup\Environment $environment, Setup\Metrics\Storage $storage)
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
$factory
Definition: metadata.php:58
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...