Merge branch 'feature/servicegroup-summary-4185'

resolves #4185
resolves #4183
resolves #4186
resolves #4184
This commit is contained in:
Eric Lippmann 2013-10-15 15:36:35 +02:00
commit caf4554023
10 changed files with 520 additions and 9 deletions

View File

@ -2,6 +2,30 @@
<div class="navbar-header">
<a href="<?= $this->baseUrl('/') ?>" class="navbar-brand icinga-logo">Icinga</a>
</div>
<div class="pull-left icinga-navbar icinga-navbar-hosts-container">
<span class="icinga-navbar-pills icinga-navbar-pills-up">999/999</span>
<span class="icinga-navbar-pills icinga-navbar-pills-unreachable">999/999</span>
<span class="icinga-navbar-pills icinga-navbar-pills-down">999/999</span>
</div>
<div class="pull-left icinga-navbar icinga-navbar-services-container">
<span class="icinga-navbar-pills icinga-navbar-pills-ok">999/999</span>
<span class="icinga-navbar-pills icinga-navbar-pills-critical">999/999</span>
<span class="icinga-navbar-pills icinga-navbar-pills-warning">999/999</span>
<span class="icinga-navbar-pills icinga-navbar-pills-unknown">999/999</span>
</div>
<div class="pull-left icinga-navbar icinga-navbar-reload">
<a class="button btn-common btn-small" href="#">
<span class="icon-refresh icon-btn-small"></span>
</a>
</div>
<div class="pull-left icinga-navbar icinga-navbar-search-container">
<input type="text" class="form-control input-sm icinga-navbar-search" />
</div>
<?php if ($this->auth()->isAuthenticated()): ?>
<ul class="nav navbar-nav pull-right" >
<!-- Remove component as of #4583 since it's not working-->

View File

@ -23,5 +23,8 @@ Comments = "/monitoring/list/comments"
Contacts = "/monitoring/list/contacts"
Contact Groups = "/monitoring/list/contactgroups"
;Remove component as of #4583 since it's not working
;Summaries = "/monitoring/summary/group/by/hostgroup"
Servicegroups.title = "Servicegroups"
Servicegroups.route = "/monitoring/list/servicegroups"
Hostgroups.title = "Hostgroups"
Hostgroups.route = "/monitoring/list/hostgroups"

View File

@ -46,6 +46,7 @@ use Icinga\Module\Monitoring\DataView\Contact as ContactView;
use Icinga\Module\Monitoring\DataView\Contactgroup as ContactgroupView;
use Icinga\Module\Monitoring\DataView\HostAndServiceStatus as HostAndServiceStatusView;
use Icinga\Module\Monitoring\DataView\Comment as CommentView;
use Icinga\Module\Monitoring\DataView\Groupsummary as GroupsummaryView;
class Monitoring_ListController extends MonitoringController
{
@ -307,6 +308,64 @@ class Monitoring_ListController extends MonitoringController
$this->handleFormatRequest($query);
}
public function servicegroupsAction()
{
$query = GroupsummaryView::fromRequest(
$this->_request,
array(
'servicegroup_name',
'cnt_hosts_up',
'cnt_hosts_unreachable',
'cnt_hosts_unreachable_unhandled',
'cnt_hosts_down',
'cnt_hosts_down_unhandled',
'cnt_hosts_pending',
'cnt_services_ok',
'cnt_services_unknown',
'cnt_services_unknown_unhandled',
'cnt_services_critical',
'cnt_services_critical_unhandled',
'cnt_services_warning',
'cnt_services_warning_unhandled',
'cnt_services_pending'
)
)->getQuery();
$this->handleFormatRequest($query);
$this->view->servicegroups = $query->paginate();
$this->setupSortControl(array(
'servicegroup_name' => 'Servicegroup Name'
));
}
public function hostgroupsAction()
{
$query = GroupsummaryView::fromRequest(
$this->_request,
array(
'hostgroup_name',
'cnt_hosts_up',
'cnt_hosts_unreachable',
'cnt_hosts_unreachable_unhandled',
'cnt_hosts_down',
'cnt_hosts_down_unhandled',
'cnt_hosts_pending',
'cnt_services_ok',
'cnt_services_unknown',
'cnt_services_unknown_unhandled',
'cnt_services_critical',
'cnt_services_critical_unhandled',
'cnt_services_warning',
'cnt_services_warning_unhandled',
'cnt_services_pending'
)
)->getQuery();
$this->handleFormatRequest($query);
$this->view->hostgroups = $query->paginate();
$this->setupSortControl(array(
'hostgroup_name' => 'Hostgroup Name'
));
}
/**
* Handle the 'format' and 'view' parameter
*

View File

@ -0,0 +1,35 @@
<div data-icinga-component="app/mainDetailGrid">
<?= $this->sortControl->render($this); ?>
<?= $this->paginationControl($hostgroups, null, null, array('preserve' => $this->preserve)); ?>
<table class="table table-condensed">
<tbody>
<?php foreach($hostgroups as $hostgroup): ?>
<tr>
<td>
<a href="<?= $this->href('monitoring/list/services', array('hostgroups' => $hostgroup->hostgroup_name)); ?>">
<?= $hostgroup->hostgroup_name; ?>
</a>
</td>
<td>
<div>
<span><?= $hostgroup->cnt_hosts_up; ?></span>
<span><?= $hostgroup->cnt_hosts_unreachable; ?>/<?= $hostgroup->cnt_hosts_unreachable_unhandled; ?></span>
<span><?= $hostgroup->cnt_hosts_down; ?>/<?= $hostgroup->cnt_hosts_down_unhandled; ?></span>
<span><?= $hostgroup->cnt_hosts_pending; ?></span>
</div>
</td>
<td>
<div>
<span><?= $hostgroup->cnt_services_ok; ?></span>
<span><?= $hostgroup->cnt_services_unknown; ?>/<?= $hostgroup->cnt_services_unknown_unhandled; ?></span>
<span><?= $hostgroup->cnt_services_critical; ?>/<?= $hostgroup->cnt_services_critical_unhandled; ?></span>
<span><?= $hostgroup->cnt_services_warning; ?>/<?= $hostgroup->cnt_services_warning_unhandled; ?></span>
<span><?= $hostgroup->cnt_services_pending; ?></span>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?= $this->paginationControl($hostgroups, null, null, array('preserve' => $this->preserve)); ?>
</div>

View File

@ -0,0 +1,35 @@
<div data-icinga-component="app/mainDetailGrid">
<?= $this->sortControl->render($this); ?>
<?= $this->paginationControl($servicegroups, null, null, array('preserve' => $this->preserve)); ?>
<table>
<tbody>
<?php foreach($servicegroups as $servicegroup): ?>
<tr>
<td>
<a href="<?= $this->href('monitoring/list/services', array('servicegroups' => $servicegroup->servicegroup_name)); ?>">
<?= $servicegroup->servicegroup_name; ?>
</a>
</td>
<td>
<div>
<span><?= $servicegroup->cnt_hosts_up; ?></span>
<span><?= $servicegroup->cnt_hosts_unreachable; ?>/<?= $servicegroup->cnt_hosts_unreachable_unhandled; ?></span>
<span><?= $servicegroup->cnt_hosts_down; ?>/<?= $servicegroup->cnt_hosts_down_unhandled; ?></span>
<span><?= $servicegroup->cnt_hosts_pending; ?></span>
</div>
</td>
<td>
<div>
<span><?= $servicegroup->cnt_services_ok; ?></span>
<span><?= $servicegroup->cnt_services_unknown; ?>/<?= $servicegroup->cnt_services_unknown_unhandled; ?></span>
<span><?= $servicegroup->cnt_services_critical; ?>/<?= $servicegroup->cnt_services_critical_unhandled; ?></span>
<span><?= $servicegroup->cnt_services_warning; ?>/<?= $servicegroup->cnt_services_warning_unhandled; ?></span>
<span><?= $servicegroup->cnt_services_pending; ?></span>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?= $this->paginationControl($servicegroups, null, null, array('preserve' => $this->preserve)); ?>
</div>

View File

@ -0,0 +1,144 @@
<?php
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
class GroupsummaryQuery extends AbstractQuery
{
protected $columnMap = array(
'hoststatus' => array(
'host_state' => 'CASE WHEN hs.has_been_checked = 0 OR hs.has_been_checked IS NULL THEN 99 ELSE hs.current_state END',
'cnt_hosts_up' => 'SUM(CASE WHEN hs.has_been_checked != 0 AND hs.has_been_checked IS NOT NULL AND hs.current_state = 0 THEN 1 ELSE 0 END)',
'cnt_hosts_unreachable' => 'SUM(CASE WHEN hs.has_been_checked != 0 AND hs.has_been_checked IS NOT NULL AND hs.current_state = 2 AND hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth = 0 THEN 1 ELSE 0 END)',
'cnt_hosts_unreachable_unhandled' => 'SUM(CASE WHEN hs.has_been_checked != 0 AND hs.has_been_checked IS NOT NULL AND hs.current_state = 2 AND hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth != 0 THEN 1 ELSE 0 END)',
'cnt_hosts_down' => 'SUM(CASE WHEN hs.has_been_checked != 0 AND hs.has_been_checked IS NOT NULL AND hs.current_state = 1 AND hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth = 0 THEN 1 ELSE 0 END)',
'cnt_hosts_down_unhandled' => 'SUM(CASE WHEN hs.has_been_checked != 0 AND hs.has_been_checked IS NOT NULL AND hs.current_state = 1 AND hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth != 0 THEN 1 ELSE 0 END)',
'cnt_hosts_pending' => 'SUM(CASE WHEN hs.has_been_checked = 0 OR hs.has_been_checked IS NULL THEN 1 ELSE 0 END)'
),
'servicestatus' => array(
'service_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END',
'cnt_services_ok' => 'SUM(CASE WHEN ss.has_been_checked != 0 AND ss.has_been_checked IS NOT NULL AND ss.current_state = 0 THEN 1 ELSE 0 END)',
'cnt_services_unknown' => 'SUM(CASE WHEN ss.has_been_checked != 0 AND ss.has_been_checked IS NOT NULL AND ss.current_state = 3 AND ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth = 0 THEN 1 ELSE 0 END)',
'cnt_services_unknown_unhandled' => 'SUM(CASE WHEN ss.has_been_checked != 0 AND ss.has_been_checked IS NOT NULL AND ss.current_state = 3 AND ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth != 0 THEN 1 ELSE 0 END)',
'cnt_services_critical' => 'SUM(CASE WHEN ss.has_been_checked != 0 AND ss.has_been_checked IS NOT NULL AND ss.current_state = 2 AND ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth = 0 THEN 1 ELSE 0 END)',
'cnt_services_critical_unhandled' => 'SUM(CASE WHEN ss.has_been_checked != 0 AND ss.has_been_checked IS NOT NULL AND ss.current_state = 2 AND ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth != 0 THEN 1 ELSE 0 END)',
'cnt_services_warning' => 'SUM(CASE WHEN ss.has_been_checked != 0 AND ss.has_been_checked IS NOT NULL AND ss.current_state = 1 AND ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth = 0 THEN 1 ELSE 0 END)',
'cnt_services_warning_unhandled' => 'SUM(CASE WHEN ss.has_been_checked != 0 AND ss.has_been_checked IS NOT NULL AND ss.current_state = 1 AND ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth != 0 THEN 1 ELSE 0 END)',
'cnt_services_pending' => 'SUM(CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 1 ELSE 0 END)'
),
'hostgroups' => array(
'hostgroup_name' => 'hgo.name1 COLLATE latin1_general_ci'
),
'servicegroups' => array(
'servicegroup_name' => 'sgo.name1 COLLATE latin1_general_ci'
)
);
protected function joinBaseTables()
{
$this->baseQuery = $this->db->select()->from(
array('ho' => $this->prefix . 'objects'),
array()
)->join(
array('hs' => $this->prefix . 'hoststatus'),
'ho.object_id = hs.host_object_id AND ho.is_active = 1 AND ho.objecttype_id = 1',
array()
)->join(
array('h' => $this->prefix . 'hosts'),
'hs.host_object_id = h.host_object_id',
array()
);
$this->joinedVirtualTables = array(
'hosts' => true,
'hoststatus' => true
);
}
protected function joinServiceStatus()
{
$this->requireVirtualTable('services');
}
protected function joinServices()
{
$this->baseQuery->join(
array('s' => $this->prefix . 'services'),
's.host_object_id = h.host_object_id',
array()
)->join(
array('so' => $this->prefix . 'objects'),
'so.' . $this->object_id . ' = s.service_object_id AND so.is_active = 1',
array()
)->joinLeft(
array('ss' => $this->prefix . 'servicestatus'),
'so.' . $this->object_id . ' = ss.service_object_id',
array()
);
}
protected function joinHostgroups()
{
if (in_array('servicegroup_name', $this->getColumns())) {
return $this->joinServiceHostgroups();
} else {
return $this->joinHostHostgroups();
}
}
protected function joinHostHostgroups()
{
$this->baseQuery->join(
array('hgm' => $this->prefix . 'hostgroup_members'),
'hgm.host_object_id = h.host_object_id',
array()
)->join(
array('hg' => $this->prefix . 'hostgroups'),
'hgm.hostgroup_id = hg.' . $this->hostgroup_id,
array()
)->join(
array('hgo' => $this->prefix . 'objects'),
'hgo.' . $this->object_id . ' = hg.hostgroup_object_id AND hgo.is_active = 1',
array()
);
$this->baseQuery->group('hgo.name1');
return $this;
}
protected function joinServiceHostgroups()
{
$this->baseQuery->join(
array('hgm' => $this->prefix . 'hostgroup_members'),
'hgm.host_object_id = s.host_object_id',
array()
)->join(
array('hg' => $this->prefix . 'hostgroups'),
'hgm.hostgroup_id = hg.' . $this->hostgroup_id,
array()
)->join(
array('hgo' => $this->prefix . 'objects'),
'hgo.' . $this->object_id . ' = hg.hostgroup_object_id AND hgo.is_active = 1',
array()
);
return $this;
}
protected function joinServicegroups()
{
$this->requireVirtualTable('services');
$this->baseQuery->join(
array('sgm' => $this->prefix . 'servicegroup_members'),
'sgm.service_object_id = s.service_object_id',
array()
)->join(
array('sg' => $this->prefix . 'servicegroups'),
'sgm.servicegroup_id = sg.' . $this->servicegroup_id,
array()
)->join(
array('sgo' => $this->prefix . 'objects'),
'sgo.' . $this->object_id. ' = sg.servicegroup_object_id AND sgo.is_active = 1',
array()
);
$this->baseQuery->group('sgo.name1');
return $this;
}
}

View File

@ -43,7 +43,7 @@ class ServicestatusQuery extends AbstractQuery
),
'servicegroups' => array(
'servicegroups' => 'sgo.name1',
),
)
);
protected function getDefaultColumns()

View File

@ -286,9 +286,13 @@ class StatusQuery extends AbstractQuery
array()
)->join(
array('hg' => $this->prefix . 'hostgroups'),
'hgm.hostgroup_id = hg' . $this->hostgroup_id,
'hgm.hostgroup_id = hg.' . $this->hostgroup_id,
array()
);
)->join(
array('hgo' => $this->prefix . 'objects'),
'hgo.' . $this->object_id . ' = hg.hostgroup_object_id AND hgo.is_active = 1',
array()
);
return $this;
}

View File

@ -0,0 +1,51 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\DataView;
class Groupsummary extends DataView
{
/**
* Retrieve columns provided by this view
*
* @return array
*/
public function getColumns()
{
return array(
'servicegroup_name',
'hostgroup_name',
'cnt_hosts_up',
'cnt_hosts_unreachable',
'cnt_hosts_unreachable_unhandled',
'cnt_hosts_down',
'cnt_hosts_down_unhandled',
'cnt_hosts_pending',
'cnt_services_ok',
'cnt_services_unknown',
'cnt_services_unknown_unhandled',
'cnt_services_critical',
'cnt_services_critical_unhandled',
'cnt_services_warning',
'cnt_services_warning_unhandled',
'cnt_services_pending'
);
}
public function getSortRules()
{
if (in_array('servicegroup_name', $this->getQuery()->getColumns())) {
return array(
'servicegroup_name' => array(
'order' => self::SORT_ASC
)
);
}
return array(
'hostgroup_name' => array(
'order' => self::SORT_ASC
)
);
}
}

View File

@ -627,7 +627,7 @@ select.input-sm {
.nav-stacked {
#background-color: #f8f8f8;
background-color: #f8f8f8;
}
.icinga-subnavigation {
@ -641,11 +641,11 @@ select.input-sm {
padding-top: 1px;
padding-bottom: 1px;
border-bottom: 1px dotted #049baf;
#border-right: 1px dotted #049baf;
border-right: 1px dotted #049baf;
}
.nav-stacked > li:first-child {
#border-top: 1px dotted #049baf;
border-top: 1px dotted #049baf;
}
@ -654,7 +654,7 @@ select.input-sm {
padding-top: 8px;
padding-bottom: 8px;
border-bottom: 1px dotted #049baf;
#border-right: 1px dotted #049baf;
border-right: 1px dotted #049baf;
}
ul.icinga-subnavigation {
@ -809,3 +809,159 @@ ul.icinga-subnavigation {
border: 1px solid #ff3300;
}
.state-tile {
border-style: solid;
border-width: 1px;
padding: 3px 5px 3px 5px;
border-radius: 3px;
font-size: 13px;
}
.state-tile-up {
/* less */
border-style: solid;
border-width: 1px;
padding: 3px 5px 3px 5px;
border-radius: 3px;
font-size: 13px;
/* less */
border-color: #00CC33;
color: #00CC33;
}
.state-tile-unreachable {
/* less */
border-style: solid;
border-width: 1px;
padding: 3px 5px 3px 5px;
border-radius: 3px;
font-size: 13px;
/* less */
border-color: #E066FF;
color: #E066FF;
}
.state-tile-down {
/* less */
border-style: solid;
border-width: 1px;
padding: 3px 5px 3px 5px;
border-radius: 3px;
font-size: 13px;
/* less */
border-color: #FF3300;
color: #FF3300;
}
.state-tile-pending {
/* less */
border-style: solid;
border-width: 1px;
padding: 3px 5px 3px 5px;
border-radius: 3px;
font-size: 13px;
/* less */
border-color: #c0c0c0;
color: #c0c0c0;
}
.icinga-icon-user {
background-attachment: scroll;
background-clip: border-box;
background-color: rgba(0, 0, 0, 0);
background-image: url("../img/icons/user.png");
background-origin: padding-box;
background-position: center center;
background-repeat: no-repeat;
background-size: auto auto;
display: inline-block;
height: 16px;
width: 16px;
}
.icinga-navbar {
margin-right: 15px;
}
.icinga-navbar-reload {
margin-top: 13px;
margin-right: 40px;
}
.icinga-navbar-search {
background-image: url('../img/icons/search.png');
background-repeat: no-repeat;
background-position: 5px 50%;
padding-left: 25px !important;
}
.icinga-navbar-search-container {
border-left: 1px solid #ddd;
padding-left: 15px;
margin-top: 12px;
}
.icinga-navbar-hosts-container {
background-image: url('../img/icons/host.png');
background-repeat: no-repeat;
background-position: 5px 50%;
padding-left: 30px !important;
margin-top: 15px;
}
.icinga-navbar-services-container {
background-image: url('../img/icons/service.png');
background-repeat: no-repeat;
background-position: 5px 50%;
padding-left: 25px !important;
margin-top: 15px;
}
.icinga-navbar-pills {
border-style: solid;
border-width: 1px;
padding: 3px 5px 3px 5px;
border-radius: 3px;
font-size: 13px;
}
/** Service status **/
.icinga-navbar-pills-critical {
border-color: #FF3300;
color: #FF3300;
}
.icinga-navbar-pills-ok {
border-color: #00CC33;
color: #00CC33;
}
.icinga-navbar-pills-warning {
border-color: #FFA500;
color: #FFA500;
}
.icinga-navbar-pills-unknown {
border-color: #E066FF;
color: #E066FF;
}
/** Host status **/
.icinga-navbar-pills-unreachable {
border-color: #E066FF;
color: #E066FF;
}
.icinga-navbar-pills-down {
border-color: #FF3300;
color: #FF3300;
}
.icinga-navbar-pills-up {
border-color: #00CC33;
color: #00CC33;
}