Merge branch 'master' into bugfix/Take-display_name-into-account-when-searching-for-host-and-service-names-8241

Conflicts:
	modules/monitoring/application/controllers/ListController.php
This commit is contained in:
Eric Lippmann 2015-05-20 17:02:49 +02:00
commit b9a6e1042d
9 changed files with 238 additions and 6 deletions

View File

@ -11,11 +11,11 @@ use Icinga\Web\Form;
class ConfirmRemovalForm extends Form class ConfirmRemovalForm extends Form
{ {
/** /**
* Initalize this form * Initialize this form
*/ */
public function init() public function init()
{ {
$this->setName('form_confirm_removal'); $this->setName('form_confirm_removal');
$this->setSubmitLabel($this->translate('Confirm Removal')); $this->getSubmitLabel() ?: $this->setSubmitLabel($this->translate('Confirm Removal'));
} }
} }

View File

@ -167,7 +167,7 @@ class Params
* *
* @throws MissingParameterException If the parameter was not given * @throws MissingParameterException If the parameter was not given
*/ */
public function req($name, $strict = true) public function getRequired($name, $strict = true)
{ {
if ($this->has($name)) { if ($this->has($name)) {
$value = $this->get($name); $value = $this->get($name);
@ -258,6 +258,30 @@ class Params
return $result; return $result;
} }
/**
* Require and remove a parameter
*
* @param string $name Name of the parameter
* @param bool $strict Whether the parameter's value must not be the empty string
*
* @return mixed
*
* @throws MissingParameterException If the parameter was not given
*/
public function shiftRequired($name, $strict = true)
{
if ($this->has($name)) {
$value = $this->get($name);
if (! $strict || strlen($value) > 0) {
$this->shift($name);
return $value;
}
}
$e = new MissingParameterException(t('Required parameter \'%s\' missing'), $name);
$e->setParameter($name);
throw $e;
}
/** /**
* Put the given value onto the argument stack * Put the given value onto the argument stack
* *

View File

@ -3,6 +3,7 @@
namespace Icinga\Web; namespace Icinga\Web;
use Zend_Controller_Action_Exception;
use Icinga\Data\Sortable; use Icinga\Data\Sortable;
use Icinga\Data\QueryInterface; use Icinga\Data\QueryInterface;
use Icinga\Web\Controller\ModuleActionController; use Icinga\Web\Controller\ModuleActionController;
@ -49,6 +50,18 @@ class Controller extends ModuleActionController
} }
} }
/**
* Immediately respond w/ HTTP 404
*
* @param $message
*
* @throws Zend_Controller_Action_Exception
*/
public function httpNotFound($message)
{
throw new Zend_Controller_Action_Exception($message, 404);
}
/** /**
* Create a SortBox widget and apply its sort rules on the given query * Create a SortBox widget and apply its sort rules on the given query
* *

View File

@ -54,7 +54,7 @@ class UrlParams
* *
* @throws MissingParameterException If the parameter was not given * @throws MissingParameterException If the parameter was not given
*/ */
public function req($name, $strict = true) public function getRequired($name, $strict = true)
{ {
if ($this->has($name)) { if ($this->has($name)) {
$value = $this->get($name); $value = $this->get($name);
@ -138,6 +138,30 @@ class UrlParams
return $ret; return $ret;
} }
/**
* Require and remove a parameter
*
* @param string $name Name of the parameter
* @param bool $strict Whether the parameter's value must not be the empty string
*
* @return mixed
*
* @throws MissingParameterException If the parameter was not given
*/
public function shiftRequired($name, $strict = true)
{
if ($this->has($name)) {
$value = $this->get($name);
if (! $strict || strlen($value) > 0) {
$this->shift($name);
return $value;
}
}
$e = new MissingParameterException(t('Required parameter \'%s\' missing'), $name);
$e->setParameter($name);
throw $e;
}
public function addEncoded($param, $value = true) public function addEncoded($param, $value = true)
{ {
$this->params[] = array($param, $this->cleanupValue($value)); $this->params[] = array($param, $this->cleanupValue($value));

View File

@ -12,7 +12,6 @@ use Icinga\Web\Widget\Tabs;
use Icinga\Data\Filter\Filter; use Icinga\Data\Filter\Filter;
use Icinga\Web\Widget; use Icinga\Web\Widget;
use Icinga\Module\Monitoring\Forms\StatehistoryForm; use Icinga\Module\Monitoring\Forms\StatehistoryForm;
use Icinga\Data\Filterable;
use Icinga\Module\Monitoring\DataView\DataView; use Icinga\Module\Monitoring\DataView\DataView;
class Monitoring_ListController extends Controller class Monitoring_ListController extends Controller
@ -530,6 +529,7 @@ class Monitoring_ListController extends Controller
'hosts_down_unhandled', 'hosts_down_unhandled',
'hosts_pending', 'hosts_pending',
'hosts_pending_last_state_change', 'hosts_pending_last_state_change',
'hosts_total',
'hosts_unreachable_handled', 'hosts_unreachable_handled',
'hosts_unreachable_last_state_change_handled', 'hosts_unreachable_last_state_change_handled',
'hosts_unreachable_last_state_change_unhandled', 'hosts_unreachable_last_state_change_unhandled',

View File

@ -22,6 +22,8 @@ if (count($hostgroups) === 0) {
<thead> <thead>
<th><?= $this->translate('Last Problem'); ?></th> <th><?= $this->translate('Last Problem'); ?></th>
<th><?= $this->translate('Host Group'); ?></th> <th><?= $this->translate('Host Group'); ?></th>
<th><?= $this->translate('Total Hosts'); ?></th>
<th><?= $this->translate('Host States'); ?></th>
<th><?= $this->translate('Total Services'); ?></th> <th><?= $this->translate('Total Services'); ?></th>
<th><?= $this->translate('Service States'); ?></th> <th><?= $this->translate('Service States'); ?></th>
</thead> </thead>
@ -68,6 +70,173 @@ if (count($hostgroups) === 0) {
array('title' => sprintf($this->translate('List all hosts in the group "%s"'), $h->hostgroup_alias)) array('title' => sprintf($this->translate('List all hosts in the group "%s"'), $h->hostgroup_alias))
); ?> ); ?>
</td> </td>
<td class="total">
<?= $this->qlink(
$h->hosts_total,
'monitoring/list/hosts',
array('hostgroup_name' => $h->hostgroup_name),
array('title' => sprintf(
$this->translate('List all hosts in host group "%s"'),
$h->hostgroup_alias
))
); ?>
</td>
<td>
<?php if ($h->hosts_up): ?>
<span class="state ok">
<?= $this->qlink(
$h->hosts_up,
'monitoring/list/hosts',
array(
'host_state' => 0,
'hostgroup_name' => $h->hostgroup_name,
'sort' => 'host_severity'
),
array(
'title' => sprintf(
$this->translatePlural(
'List %u host that is currently in state UP in the host group "%s"',
'List %u hosts which are currently in state UP in the host group "%s"',
$h->hosts_up
),
$h->hosts_up,
$h->hostgroup_alias
)
)
); ?>
</span>
<?php endif ?>
<?php if ($h->hosts_down_unhandled): ?>
<span class="state critical">
<?= $this->qlink(
$h->hosts_down_unhandled,
'monitoring/list/hosts',
array(
'host_state' => 1,
'host_acknowledged' => 0,
'host_in_downtime' => 0,
'hostgroup_name' => $h->hostgroup_name,
'sort' => 'host_severity'
),
array(
'title' => sprintf(
$this->translatePlural(
'List %u host that is currently in state DOWN in the host group "%s"',
'List %u hosts which are currently in state DOWN in the host group "%s"',
$h->hosts_down_unhandled
),
$h->hosts_down_unhandled,
$h->hostgroup_alias
)
)
); ?>
<?php endif ?>
<?php if ($h->hosts_down_handled): ?>
<span class="state critical handled">
<?= $this->qlink(
$h->hosts_down_handled,
'monitoring/list/hosts',
array(
'host_state' => 1,
'host_handled' => 1,
'hostgroup_name' => $h->hostgroup_name,
'sort' => 'host_severity'
),
array(
'title' => sprintf(
$this->translatePlural(
'List %u host that is currently in state DOWN (Acknowledged) in the host group "%s"',
'List %u hosts which are currently in state DOWN (Acknowledged) in the host group "%s"',
$h->hosts_down_handled
),
$h->hosts_down_handled,
$h->hostgroup_alias
)
)
); ?>
</span>
<?php endif ?>
<?php if ($h->hosts_down_unhandled): ?>
</span>
<?php endif ?>
<?php if ($h->hosts_unreachable_unhandled): ?>
<span class="state unknown">
<?= $this->qlink(
$h->hosts_unreachable_unhandled,
'monitoring/list/hosts',
array(
'host_state' => 2,
'host_acknowledged' => 0,
'host_in_downtime' => 0,
'hostgroup_name' => $h->hostgroup_name,
'sort' => 'host_severity'
),
array(
'title' => sprintf(
$this->translatePlural(
'List %u host that is currently in state UNREACHABLE in the host group "%s"',
'List %u hosts which are currently in state UNREACHABLE in the host group "%s"',
$h->hosts_unreachable_unhandled
),
$h->hosts_unreachable_unhandled,
$h->hostgroup_alias
)
)
); ?>
<?php endif ?>
<?php if ($h->hosts_unreachable_handled): ?>
<span class="state unknown handled">
<?= $this->qlink(
$h->hosts_unreachable_handled,
'monitoring/list/hosts',
array(
'host_state' => 2,
'host_handled' => 1,
'hostgroup_name' => $h->hostgroup_name,
'sort' => 'host_severity'
),
array(
'title' => sprintf(
$this->translatePlural(
'List %u host that is currently in state UNREACHABLE (Acknowledged) in the host group "%s"',
'List %u hosts which are currently in state UNREACHABLE (Acknowledged) in the host group "%s"',
$h->hosts_unreachable_handled
),
$h->hosts_unreachable_handled,
$h->hostgroup_alias
)
)
); ?>
</span>
<?php endif ?>
<?php if ($h->hosts_unreachable_unhandled): ?>
</span>
<?php endif ?>
<?php if ($h->hosts_pending): ?>
<span class="state pending">
<?= $this->qlink(
$h->hosts_pending,
'monitoring/list/hosts',
array(
'host_state' => 99,
'hostgroup_name' => $h->hostgroup_name,
'sort' => 'host_severity'
),
array(
'title' => sprintf(
$this->translatePlural(
'List %u host that is currently in state PENDING in the host group "%s"',
'List %u hosts which are currently in state PENDING in the host group "%s"',
$h->hosts_pending
),
$h->hosts_pending,
$h->hostgroup_alias
)
)
); ?>
</span>
<?php endif ?>
</td>
<td class="total"> <td class="total">
<?= $this->qlink( <?= $this->qlink(
$h->services_total, $h->services_total,

View File

@ -11,6 +11,7 @@ class GroupSummaryQuery extends IdoQuery
protected $columnMap = array( protected $columnMap = array(
'hoststatussummary' => array( 'hoststatussummary' => array(
'hosts_total' => 'SUM(CASE WHEN object_type = \'host\' THEN 1 ELSE 0 END)',
'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)', 'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)',
'hosts_unreachable' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 THEN 1 ELSE 0 END)', 'hosts_unreachable' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 THEN 1 ELSE 0 END)',
'hosts_unreachable_handled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime != 0 THEN 1 ELSE 0 END)', 'hosts_unreachable_handled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime != 0 THEN 1 ELSE 0 END)',

View File

@ -17,6 +17,7 @@ class Groupsummary extends DataView
'servicegroup_alias', 'servicegroup_alias',
'hostgroup_name', 'hostgroup_name',
'hostgroup_alias', 'hostgroup_alias',
'hosts_total',
'hosts_up', 'hosts_up',
'hosts_unreachable', 'hosts_unreachable',
'hosts_unreachable_handled', 'hosts_unreachable_handled',

View File

@ -23,7 +23,7 @@ table.action {
border-collapse: separate; border-collapse: separate;
border-spacing: 1px; border-spacing: 1px;
width: 100%; width: 100%;
table-layout: fixed; table-layout: fixed !important;
margin: 0; margin: 0;
color: @colorTextDefault; color: @colorTextDefault;
} }