Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
centreon
centreon
Commits
21be215b
Commit
21be215b
authored
Apr 12, 2021
by
Adrien Morais
Browse files
enh(resource): handle AD service shortcuts
parent
af229379
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/Centreon/Application/Controller/MonitoringResourceController.php
View file @
21be215b
...
...
@@ -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
))
{
...
...
src/Centreon/Domain/Contact/Contact.php
View file @
21be215b
...
...
@@ -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'
;
...
...
src/Centreon/Domain/Monitoring/Resource.php
View file @
21be215b
...
...
@@ -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
;
}
}
src/Centreon/Infrastructure/Monitoring/Resource/Provider/HostProvider.php
View file @
21be215b
...
...
@@ -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
...
...
src/Centreon/Infrastructure/Monitoring/Resource/Provider/MetaServiceProvider.php
View file @
21be215b
...
...
@@ -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
...
...
src/Centreon/Infrastructure/Monitoring/Resource/Provider/ServiceProvider.php
View file @
21be215b
...
...
@@ -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"
;
...
...
src/Centreon/Infrastructure/Monitoring/Resource/ResourceRepositoryRDB.php
View file @
21be215b
...
...
@@ -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
=
[];
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment