Commit 21be215b authored by Adrien Morais's avatar Adrien Morais
Browse files

enh(resource): handle AD service shortcuts

parent af229379
......@@ -83,6 +83,8 @@ class MonitoringResourceController extends AbstractController
private const HOST_CONFIGURATION_URI = '/main.php?p=60101&o=c&host_id={resource_id}';
private const SERVICE_CONFIGURATION_URI = '/main.php?p=60201&o=c&service_id={resource_id}';
// Anomaly detection configuration uri
private const AD_SERVICE_CONFIGURATION_URI = '/main.php?p=60220&o=c&service_id={resource_id}';
private const HOST_LOGS_URI = '/main.php?p=20301&h={resource_id}';
private const SERVICE_LOGS_URI = '/main.php?p=20301&svc={parent_resource_id}_{resource_id}';
private const META_SERVICE_LOGS_URI = '/main.php?p=20301&svc={host_id}_{service_id}';
......@@ -708,13 +710,21 @@ class MonitoringResourceController extends AbstractController
*/
private function provideServiceInternalUris(ResourceEntity $resource, Contact $contact): void
{
if (
$contact->hasTopologyRole(Contact::ROLE_CONFIGURATION_SERVICES_WRITE)
|| $contact->hasTopologyRole(Contact::ROLE_CONFIGURATION_SERVICES_READ)
) {
$resource->getLinks()->getUris()->setConfiguration(
$this->generateResourceUri($resource, static::SERVICE_CONFIGURATION_URI)
);
if ($resource->getRegister() === 3) {
if ($contact->hasTopologyRole(Contact::ROLE_CONFIGURATION_SERVICES_ANOMALY_DETECTION)) {
$resource->getLinks()->getUris()->setConfiguration(
$this->generateResourceUri($resource, static::AD_SERVICE_CONFIGURATION_URI)
);
}
} else {
if (
$contact->hasTopologyRole(Contact::ROLE_CONFIGURATION_SERVICES_WRITE)
|| $contact->hasTopologyRole(Contact::ROLE_CONFIGURATION_SERVICES_READ)
) {
$resource->getLinks()->getUris()->setConfiguration(
$this->generateResourceUri($resource, static::SERVICE_CONFIGURATION_URI)
);
}
}
if ($contact->hasTopologyRole(Contact::ROLE_MONITORING_EVENT_LOGS)) {
......
......@@ -55,6 +55,7 @@ class Contact implements UserInterface, ContactInterface
public const ROLE_CONFIGURATION_SERVICES_READ = 'ROLE_CONFIGURATION_SERVICES_SERVICES_BY_HOST_R';
public const ROLE_CONFIGURATION_META_SERVICES_WRITE = 'ROLE_CONFIGURATION_SERVICES_META_SERVICES_RW';
public const ROLE_CONFIGURATION_META_SERVICES_READ = 'ROLE_CONFIGURATION_SERVICES_META_SERVICES_R';
public const ROLE_CONFIGURATION_SERVICES_ANOMALY_DETECTION = 'ROLE_CONFIGURATION_SERVICES_ANOMALY_DETECTION_RW';
public const ROLE_MONITORING_EVENT_LOGS = 'ROLE_MONITORING_EVENT_LOGS_EVENT_LOGS_RW';
public const ROLE_REPORTING_DASHBOARD_HOSTS = 'ROLE_REPORTING_DASHBOARD_HOSTS_RW';
public const ROLE_REPORTING_DASHBOARD_SERVICES = 'ROLE_REPORTING_DASHBOARD_SERVICES_RW';
......
......@@ -253,6 +253,13 @@ class Resource
*/
private $notificationEnabled = false;
/**
* Indicates the register type in DB for the resource
*
* @var int|null
*/
private $register;
/**
* Resource constructor.
*/
......@@ -1040,4 +1047,23 @@ class Resource
return $this;
}
/**
* @return integer|null
*/
public function getRegister(): ?int
{
return $this->register;
}
/**
* @param integer|null $register
* @return self
*/
public function setRegister(?int $register): self
{
$this->register = $register;
return $this;
}
}
......@@ -149,7 +149,8 @@ final class HostProvider extends Provider
h.perfdata AS `performance_data`,
h.execution_time AS `execution_time`,
h.latency AS `latency`,
h.notify AS `notification_enabled`
h.notify AS `notification_enabled`,
NULL AS `register`
FROM `:dbstg`.`hosts` AS h";
// get monitoring server information
......
......@@ -151,7 +151,8 @@ final class MetaServiceProvider extends Provider
s.perfdata AS `performance_data`,
s.execution_time AS `execution_time`,
s.latency AS `latency`,
s.notify AS `notification_enabled`
s.notify AS `notification_enabled`,
NULL AS `register`
FROM `:dbstg`.`services` AS s
INNER JOIN `:dbstg`.`hosts` sh
ON sh.host_id = s.host_id
......
......@@ -163,13 +163,18 @@ final class ServiceProvider extends Provider
s.perfdata AS `performance_data`,
s.execution_time AS `execution_time`,
s.latency AS `latency`,
s.notify AS `notification_enabled`
s.notify AS `notification_enabled`,
s_configuration.service_register AS `register`
FROM `:dbstg`.`services` AS s
INNER JOIN `:dbstg`.`hosts` sh
ON sh.host_id = s.host_id
AND sh.name NOT LIKE '_Module_%'
AND sh.enabled = 1";
// JOIN the configuration table to get the service_register entry
$sql .= ' LEFT JOIN `:db`.`service` AS s_configuration
ON s_configuration.service_id = s.service_id';
// get monitoring server information
$sql .= " INNER JOIN `:dbstg`.`instances` AS i ON i.instance_id = sh.instance_id";
......
......@@ -184,7 +184,8 @@ final class ResourceRepositoryRDB extends AbstractRepositoryDRB implements Resou
. 'resource.tries, resource.last_check, resource.next_check, '
. 'resource.information, resource.performance_data, '
. 'resource.execution_time, resource.latency, '
. 'resource.notification_enabled '
. 'resource.notification_enabled, '
. 'resource.register '
. 'FROM (';
$subRequests = [];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment