-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show root problem list for objects that have problem and are part of …
…dependency
- Loading branch information
Showing
11 changed files
with
525 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
library/Icingadb/Model/RedundancyGroupParentStateSummary.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<?php | ||
|
||
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */ | ||
|
||
namespace Icinga\Module\Icingadb\Model; | ||
|
||
use ipl\Sql\Connection; | ||
use ipl\Sql\Expression; | ||
|
||
/** | ||
* @property int $parents_acknowledged | ||
* @property int $parents_down_critical_handled | ||
* @property int $parents_down_critical_unhandled | ||
* @property int $parents_pending | ||
* @property int $parents_problems_unacknowledged | ||
* @property int $parents_total | ||
* @property int $parents_up_ok | ||
* @property int $parents_unknown_handled | ||
* @property int $parents_unknown_unhandled | ||
* @property int $parents_warning_handled | ||
* @property int $parents_warning_unhandled | ||
*/ | ||
class RedundancyGroupParentStateSummary extends RedundancyGroup | ||
{ | ||
public function getSummaryColumns() | ||
{ | ||
return [ | ||
'parents_acknowledged' => new Expression( | ||
'SUM(CASE WHEN redundancy_group_from_to_host_state.is_acknowledged = \'y\' THEN 1 ELSE 0 END' | ||
. ' + CASE WHEN redundancy_group_from_to_service_state.is_acknowledged = \'y\' THEN 1 ELSE 0 END)' | ||
), | ||
'parents_down_handled' => new Expression( | ||
'SUM(CASE WHEN redundancy_group_from_to_host_state.soft_state = 1' | ||
. ' AND (redundancy_group_from_to_host_state.is_handled = \'y\'' | ||
. ' OR redundancy_group_from_to_host_state.is_reachable = \'n\') THEN 1 ELSE 0 END' | ||
. '+ CASE WHEN redundancy_group_from_to_service_state.soft_state = 2' | ||
. ' AND (redundancy_group_from_to_service_state.is_handled = \'y\'' | ||
. ' OR redundancy_group_from_to_service_state.is_reachable = \'n\') THEN 1 ELSE 0 END)' | ||
), | ||
'parents_down_unhandled' => new Expression( | ||
'SUM(CASE WHEN redundancy_group_from_to_host_state.soft_state = 1' | ||
. ' AND redundancy_group_from_to_host_state.is_handled = \'n\'' | ||
. ' AND redundancy_group_from_to_host_state.is_reachable = \'y\' THEN 1 ELSE 0 END' | ||
. ' + CASE WHEN redundancy_group_from_to_service_state.soft_state = 2' | ||
. ' AND redundancy_group_from_to_service_state.is_handled = \'n\'' | ||
. ' AND redundancy_group_from_to_service_state.is_reachable = \'y\' THEN 1 ELSE 0 END)' | ||
), | ||
'parents_pending' => new Expression( | ||
'SUM(CASE WHEN redundancy_group_from_to_host_state.soft_state = 99 THEN 1 ELSE 0 END' | ||
. '+ CASE WHEN redundancy_group_from_to_service_state.soft_state = 99 THEN 1 ELSE 0 END)' | ||
), | ||
'parents_problems_unacknowledged' => new Expression( | ||
'SUM(CASE WHEN redundancy_group_from_to_host_state.is_problem = \'y\'' | ||
. ' AND redundancy_group_from_to_host_state.is_acknowledged = \'n\' THEN 1 ELSE 0 END' | ||
. '+ CASE WHEN redundancy_group_from_to_service_state.is_problem = \'y\'' | ||
. ' AND redundancy_group_from_to_service_state.is_acknowledged = \'n\' THEN 1 ELSE 0 END)' | ||
), | ||
'parents_total' => new Expression( | ||
'SUM(CASE WHEN redundancy_group_from_to_host.id IS NOT NULL THEN 1 ELSE 0 END)' | ||
. '+ SUM(CASE WHEN redundancy_group_from_to_service.id IS NOT NULL THEN 1 ELSE 0 END)' | ||
), | ||
'parents_ok' => new Expression( | ||
'SUM(CASE WHEN redundancy_group_from_to_host_state.soft_state = 0 THEN 1 ELSE 0 END' | ||
. '+ CASE WHEN redundancy_group_from_to_service_state.soft_state = 0 THEN 1 ELSE 0 END)' | ||
), | ||
'parents_unknown_handled' => new Expression( | ||
'SUM(CASE WHEN redundancy_group_from_to_service_state.soft_state = 3' | ||
. ' AND (redundancy_group_from_to_service_state.is_handled = \'y\'' | ||
. ' OR redundancy_group_from_to_service_state.is_reachable = \'n\') THEN 1 ELSE 0 END)' | ||
), | ||
'parents_unknown_unhandled' => new Expression( | ||
'SUM(CASE WHEN redundancy_group_from_to_service_state.soft_state = 3' | ||
. ' AND redundancy_group_from_to_service_state.is_handled = \'n\'' | ||
. ' AND redundancy_group_from_to_service_state.is_reachable = \'y\' THEN 1 ELSE 0 END)' | ||
), | ||
'parents_warning_handled' => new Expression( | ||
'SUM(CASE WHEN redundancy_group_from_to_service_state.soft_state = 1' | ||
. ' AND (redundancy_group_from_to_service_state.is_handled = \'y\'' | ||
. ' OR redundancy_group_from_to_service_state.is_reachable = \'n\') THEN 1 ELSE 0 END)' | ||
), | ||
'parents_warning_unhandled' => new Expression( | ||
'SUM(CASE WHEN redundancy_group_from_to_service_state.soft_state = 1' | ||
. ' AND redundancy_group_from_to_service_state.is_handled = \'n\'' | ||
. ' AND redundancy_group_from_to_service_state.is_reachable = \'y\' THEN 1 ELSE 0 END)' | ||
) | ||
]; | ||
} | ||
|
||
public static function on(Connection $db) | ||
{ | ||
$q = parent::on($db)->with([ | ||
'from', | ||
'from.to.host', | ||
'from.to.host.state', | ||
'from.to.service', | ||
'from.to.service.state' | ||
]); | ||
|
||
/** @var static $m */ | ||
$m = $q->getModel(); | ||
$q->columns($m->getSummaryColumns()); | ||
|
||
return $q; | ||
} | ||
|
||
public function getColumns(): array | ||
{ | ||
return array_merge(parent::getColumns(), $this->getSummaryColumns()); | ||
} | ||
|
||
public function getDefaultSort() | ||
{ | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.