Skip to content

Commit

Permalink
Various: Make Metric-Objectives more resilient
Browse files Browse the repository at this point in the history
  • Loading branch information
klees committed Jun 10, 2024
1 parent d418864 commit 2713cb0
Show file tree
Hide file tree
Showing 3 changed files with 328 additions and 319 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,160 +41,163 @@ protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Sto
// fact, that dependency injection is something we want. Currently, every
// component could just service locate the whole world via the global $DIC.
$DIC = $GLOBALS["DIC"];
$GLOBALS["DIC"] = new DI\Container();
$GLOBALS["DIC"]["ilDB"] = $db;
$GLOBALS["DIC"]["ilBench"] = null;

$chatAdministrations = ilObject::_getObjectsByType('chta');
$chatAdministration = current($chatAdministrations);

$chat_admin = new ilChatroomAdmin((int) $chatAdministration['obj_id']);
$settings = $chat_admin->loadGeneralSettings();

if (count($settings) > 0) {
$storage->storeConfigText(
"address",
$settings['address'] ?? "",
"IP-Address/FQN of Chat Server."
);
$storage->storeConfigText(
"port",
(string) ($settings['port'] ?? ""),
"Port of the chat server."
);
$storage->storeConfigText(
"sub_directory",
$settings['sub_directory'] ?? "",
"http(s)://[IP/Domain]/[SUB_DIRECTORY]"
);

$storage->storeConfigText(
"protocol",
$settings['protocol'] ?? "",
"Protocol used for connection (http/https)."
);

if ($settings['protocol'] === 'https') {
$cert = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_TEXT,
$settings['cert'] ?? ""
try {
$GLOBALS["DIC"] = new DI\Container();
$GLOBALS["DIC"]["ilDB"] = $db;
$GLOBALS["DIC"]["ilBench"] = null;

$chatAdministrations = ilObject::_getObjectsByType('chta');
$chatAdministration = current($chatAdministrations);

$chat_admin = new ilChatroomAdmin((int) $chatAdministration['obj_id']);
$settings = $chat_admin->loadGeneralSettings();

if (count($settings) > 0) {
$storage->storeConfigText(
"address",
$settings['address'] ?? "",
"IP-Address/FQN of Chat Server."
);
$key = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_TEXT,
$settings['key'] ?? ""
$storage->storeConfigText(
"port",
(string) ($settings['port'] ?? ""),
"Port of the chat server."
);
$dhparam = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_TEXT,
$settings['dhparam'] ?? ""
$storage->storeConfigText(
"sub_directory",
$settings['sub_directory'] ?? "",
"http(s)://[IP/Domain]/[SUB_DIRECTORY]"
);
$https = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_COLLECTION,
[
"cert" => $cert,
"key" => $key,
"dhparam" => $dhparam,
],
"Holds parameters for https."
);
$storage->store("https", $https);
}

$storage->storeConfigText(
"log",
(string) ($settings['log'] ?? ''),
"Absolute server path to the chat server's log file."
);
$storage->storeConfigText(
"log_level",
$settings['log_level'] ?? "",
"Possible values are emerg, alert, crit error, warning, notice, info, debug, silly."
);
$storage->storeConfigText(
"error_log",
$settings['error_log'] ?? "",
"Absolute server path to the chat server's error log file."
);

if ($settings['ilias_proxy']) {
$ilias_url = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_TEXT,
$settings['ilias_url'] ?? ""
);
$ilias_proxy = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_COLLECTION,
[
"ilias_url" => $ilias_url
],
"Holds proxy url if ILIAS proxy is enabled."
$storage->storeConfigText(
"protocol",
$settings['protocol'] ?? "",
"Protocol used for connection (http/https)."
);
$storage->store("ilias_proxy", $ilias_proxy);
} else {
$storage->storeConfigBool(
"ilias_proxy",
false,
"Holds proxy url if ILIAS proxy is enabled."
);
}

if ($settings['client_proxy']) {
$client_url = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_TEXT,
$settings['client_url'] ?? ""
if ($settings['protocol'] === 'https') {
$cert = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_TEXT,
$settings['cert'] ?? ""
);
$key = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_TEXT,
$settings['key'] ?? ""
);
$dhparam = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_TEXT,
$settings['dhparam'] ?? ""
);
$https = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_COLLECTION,
[
"cert" => $cert,
"key" => $key,
"dhparam" => $dhparam,
],
"Holds parameters for https."
);
$storage->store("https", $https);
}

$storage->storeConfigText(
"log",
(string) ($settings['log'] ?? ''),
"Absolute server path to the chat server's log file."
);
$client_proxy = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_COLLECTION,
[
"client_url" => $client_url
],
"Holds proxy url if client proxy is enabled."
$storage->storeConfigText(
"log_level",
$settings['log_level'] ?? "",
"Possible values are emerg, alert, crit error, warning, notice, info, debug, silly."
);
$storage->store("client_proxy", $client_proxy);
} else {
$storage->storeConfigBool(
"client_proxy",
false,
"Holds proxy url if client proxy is enabled."
$storage->storeConfigText(
"error_log",
$settings['error_log'] ?? "",
"Absolute server path to the chat server's error log file."
);
}

if ($settings['deletion_mode']) {
$deletion_unit = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_TEXT,
$settings['deletion_unit'] ?? ""
);
$deletion_value = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_TEXT,
(string) ($settings['deletion_value'] ?? '')
);
$deletion_time = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_TEXT,
$settings['deletion_time'] ?? ""
);
$deletion_mode = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_COLLECTION,
[
"deletion_unit" => $deletion_unit,
"deletion_value" => $deletion_value,
"deletion_time" => $deletion_time,
],
"Holds information about deletion process."
);
$storage->store("deletion_mode", $deletion_mode);
if ($settings['ilias_proxy']) {
$ilias_url = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_TEXT,
$settings['ilias_url'] ?? ""
);
$ilias_proxy = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_COLLECTION,
[
"ilias_url" => $ilias_url
],
"Holds proxy url if ILIAS proxy is enabled."
);
$storage->store("ilias_proxy", $ilias_proxy);
} else {
$storage->storeConfigBool(
"ilias_proxy",
false,
"Holds proxy url if ILIAS proxy is enabled."
);
}

if ($settings['client_proxy']) {
$client_url = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_TEXT,
$settings['client_url'] ?? ""
);
$client_proxy = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_COLLECTION,
[
"client_url" => $client_url
],
"Holds proxy url if client proxy is enabled."
);
$storage->store("client_proxy", $client_proxy);
} else {
$storage->storeConfigBool(
"client_proxy",
false,
"Holds proxy url if client proxy is enabled."
);
}

if ($settings['deletion_mode']) {
$deletion_unit = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_TEXT,
$settings['deletion_unit'] ?? ""
);
$deletion_value = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_TEXT,
(string) ($settings['deletion_value'] ?? '')
);
$deletion_time = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_TEXT,
$settings['deletion_time'] ?? ""
);
$deletion_mode = new Setup\Metrics\Metric(
Setup\Metrics\Metric::STABILITY_CONFIG,
Setup\Metrics\Metric::TYPE_COLLECTION,
[
"deletion_unit" => $deletion_unit,
"deletion_value" => $deletion_value,
"deletion_time" => $deletion_time,
],
"Holds information about deletion process."
);
$storage->store("deletion_mode", $deletion_mode);
}
}
}

$GLOBALS["DIC"] = $DIC;
finally {
$GLOBALS["DIC"] = $DIC;
}
}
}
Loading

0 comments on commit 2713cb0

Please sign in to comment.