Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Mon 4790 add missing fields #8312

Merged
merged 16 commits into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions doc/API/centreon-api-v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ paths:
* poller.id
* service.display_name
* host_group.id
* host.is_acknowledged
* host.downtime
* host.criticality
parameters:
- $ref: '#/components/parameters/ShowService'
- $ref: '#/components/parameters/Search'
Expand Down Expand Up @@ -259,6 +262,8 @@ paths:
* service.state
* service_group.id
* poller.id
* service.downtime
* service.criticality
parameters:
- $ref: '#/components/parameters/Search'
- $ref: '#/components/parameters/Limit'
Expand Down Expand Up @@ -1630,6 +1635,14 @@ components:
type: string
description: Timezone used for dates
example: ':Europe/Paris'
scheduled_downtime_depth:
type: integer
description: "Is there scheduled downtime for host or not (1 or 0)"
example: 0
criticality:
type: integer
description: "Host criticality level (for display purposes)"
example: 10
Monitoring.HostWithService:
type: object
properties:
Expand Down Expand Up @@ -1720,6 +1733,10 @@ components:
* `0` - SOFT
* `1` - HARD
example: 1
criticality:
type: integer
description: "Service criticality level (for display purposes)"
example: 10
Monitoring.ServiceFull:
allOf:
- $ref: '#/components/schemas/Monitoring.ServiceMain'
Expand Down
48 changes: 48 additions & 0 deletions src/Centreon/Domain/Monitoring/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,18 @@ class Host
*/
private $timezone;

/**
* @Serializer\Groups({"host_main","host_full"})
* @var int|null
*/
private $scheduledDowntimeDepth;

/**
* @Serializer\Groups({"host_main", "host_full"})
* @var int|null
*/
private $criticality;

/**
* @return int
*/
Expand Down Expand Up @@ -1146,4 +1158,40 @@ public function setTimezone(?string $timezone): Host
$this->timezone = $timezone;
return $this;
}

/**
* @return int|null
*/
public function getScheduledDowntimeDepth(): ?int
{
return $this->scheduledDowntimeDepth;
}

/**
* @param int|null $scheduledDowntimeDepth
* @return Host
*/
public function setScheduledDowntimeDepth(?int $scheduledDowntimeDepth): Host
{
$this->scheduledDowntimeDepth = $scheduledDowntimeDepth;
return $this;
}

/**
* @return int|null
*/
public function getCriticality(): ?int
{
return $this->criticality;
}

/**
* @param int|null $criticality
* @return Host
*/
public function setCriticality(?int $criticality): Host
{
$this->criticality = $criticality;
return $this;
}
}
28 changes: 26 additions & 2 deletions src/Centreon/Domain/Monitoring/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Service
private $iconImageAlt;

/**
* @Serializer\Groups({"service_full"})
* @Serializer\Groups({"service_main","service_full"})
* @Desc(column="acknowledged", modifier="setAcknowledged")
* @var bool
*/
Expand All @@ -132,7 +132,7 @@ class Service
private $isChecked;

/**
* @Serializer\Groups({"service_full"})
* @Serializer\Groups({"service_main","service_full"})
* @var int|null
*/
private $scheduledDowntimeDepth;
Expand Down Expand Up @@ -234,6 +234,12 @@ class Service
*/
private $stateType;

/**
* @Serializer\Groups({"service_main", "service_full"})
* @var int
*/
private $criticality;

/**
* @return int
*/
Expand Down Expand Up @@ -825,4 +831,22 @@ public function setStateType(int $stateType): Service
$this->stateType = $stateType;
return $this;
}

/**
* @return int|null
*/
public function getCriticality(): ?int
{
return $this->criticality;
}

/**
* @param int|null $criticality
* @return Service
*/
public function setCriticality(?int $criticality): Service
{
$this->criticality = $criticality;
return $this;
}
}
19 changes: 16 additions & 3 deletions src/Centreon/Infrastructure/Monitoring/MonitoringRepositoryRDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ public function findHosts(): array
'host.state' => 'h.state',
'poller.id' => 'h.instance_id',
'service.display_name' => 'srv.display_name',
'host_group.id' => 'hg.hostgroup_id']);
'host_group.id' => 'hg.hostgroup_id',
'host.is_acknowledged' => 'h.acknowledged',
'host.downtime' => 'h.scheduled_downtime_depth',
'host.criticality' => 'cv.value'
]);

$accessGroupFilter = $this->isAdmin()
? ''
Expand All @@ -136,6 +140,7 @@ public function findHosts(): array
$request =
'SELECT SQL_CALC_FOUND_ROWS DISTINCT
h.*,
cv.value AS criticality,
i.name AS instance_name,
IF (h.display_name LIKE \'_Module_Meta%\', \'Meta\', h.display_name) AS display_name,
IF (h.display_name LIKE \'_Module_Meta%\', \'0\', h.state) AS state
Expand All @@ -149,7 +154,9 @@ public function findHosts(): array
ON srv.host_id = h.host_id
AND srv.enabled = \'1\'
LEFT JOIN `:dbstg`.`hosts_hostgroups` hg
ON hg.host_id = h.host_id';
ON hg.host_id = h.host_id
LEFT JOIN `:dbstg`.`customvariables` cv
ON (cv.host_id = h.host_id AND cv.service_id IS NULL AND cv.name = \'CRITICALITY_LEVEL\')';

$request = $this->translateDbName($request);

Expand Down Expand Up @@ -572,6 +579,8 @@ public function findServices(): array
'service.output' => 'srv.output',
'service.state' => 'srv.state',
'service_group.id' => 'ssg.servicegroup_id',
'service.downtime' => 'srv.scheduled_downtime_depth',
'service.criticality' => 'cv.value'
]);

$accessGroupFilter = $this->isAdmin()
Expand All @@ -588,6 +597,7 @@ public function findServices(): array
'SELECT SQL_CALC_FOUND_ROWS DISTINCT
srv.*,
h.host_id, h.alias AS host_alias, h.name AS host_name,
cv.value as criticality,
IF (h.display_name LIKE \'_Module_Meta%\', \'Meta\', h.display_name) AS host_display_name,
IF (h.display_name LIKE \'_Module_Meta%\', \'0\', h.state) AS host_state
FROM `:dbstg`.services srv'
Expand All @@ -605,7 +615,10 @@ public function findServices(): array
ON hg.hostgroup_id = hhg.hostgroup_id
LEFT JOIN :dbstg.services_servicegroups ssg
ON ssg.service_id = srv.service_id
AND ssg.host_id = h.host_id';
AND ssg.host_id = h.host_id
LEFT JOIN :dbstg.customvariables cv
ON (cv.service_id = srv.service_id
AND cv.host_id IS NULL AND cv.name = \'CRITICALITY_LEVEL\')';

$request = $this->translateDbName($request);

Expand Down