Display acknowledgement action for all unacknowledged objects

Instead of displaying the ack for all unhandled problem host, make acknowledgement possible for all monitored objects in multi views.

fixes #7931
This commit is contained in:
Matthias Jentsch 2015-06-01 12:22:53 +02:00
parent 068bfc0c71
commit 29cc92a3f3
7 changed files with 82 additions and 35 deletions

View File

@ -133,13 +133,14 @@ class Monitoring_HostsController extends Controller
$this->view->objects = $this->hostList; $this->view->objects = $this->hostList;
$this->view->unhandledObjects = $this->hostList->getUnhandledObjects(); $this->view->unhandledObjects = $this->hostList->getUnhandledObjects();
$this->view->problemObjects = $this->hostList->getProblemObjects(); $this->view->problemObjects = $this->hostList->getProblemObjects();
$this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/hosts/acknowledge-problem')
->setQueryString($this->hostList->getUnhandledObjects()->objectsFilter()->toQueryString());
$this->view->downtimeUnhandledLink = Url::fromPath('monitoring/hosts/schedule-downtime') $this->view->downtimeUnhandledLink = Url::fromPath('monitoring/hosts/schedule-downtime')
->setQueryString($this->hostList->getUnhandledObjects()->objectsFilter()->toQueryString()); ->setQueryString($this->hostList->getUnhandledObjects()->objectsFilter()->toQueryString());
$this->view->downtimeLink = Url::fromPath('monitoring/hosts/schedule-downtime') $this->view->downtimeLink = Url::fromPath('monitoring/hosts/schedule-downtime')
->setQueryString($this->hostList->getProblemObjects()->objectsFilter()->toQueryString()); ->setQueryString($this->hostList->getProblemObjects()->objectsFilter()->toQueryString());
$this->view->acknowledgedObjects = $this->hostList->getAcknowledgedObjects(); $this->view->acknowledgedObjects = $this->hostList->getAcknowledgedObjects();
$this->view->acknowledgeLink = Url::fromPath('monitoring/hosts/acknowledge-problem')
->setQueryString($this->hostList->getUnacknowledgedObjects()->objectsFilter()->toQueryString());
$this->view->unacknowledgedObjects = $this->hostList->getUnacknowledgedObjects();
$this->view->objectsInDowntime = $this->hostList->getObjectsInDowntime(); $this->view->objectsInDowntime = $this->hostList->getObjectsInDowntime();
$this->view->inDowntimeLink = Url::fromPath('monitoring/list/hosts') $this->view->inDowntimeLink = Url::fromPath('monitoring/list/hosts')
->setQueryString( ->setQueryString(

View File

@ -149,13 +149,14 @@ class Monitoring_ServicesController extends Controller
$this->view->objects = $this->serviceList; $this->view->objects = $this->serviceList;
$this->view->unhandledObjects = $this->serviceList->getUnhandledObjects(); $this->view->unhandledObjects = $this->serviceList->getUnhandledObjects();
$this->view->problemObjects = $this->serviceList->getProblemObjects(); $this->view->problemObjects = $this->serviceList->getProblemObjects();
$this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/services/acknowledge-problem')
->setQueryString($this->serviceList->getUnhandledObjects()->objectsFilter()->toQueryString());
$this->view->downtimeUnhandledLink = Url::fromPath('monitoring/services/schedule-downtime') $this->view->downtimeUnhandledLink = Url::fromPath('monitoring/services/schedule-downtime')
->setQueryString($this->serviceList->getUnhandledObjects()->objectsFilter()->toQueryString()); ->setQueryString($this->serviceList->getUnhandledObjects()->objectsFilter()->toQueryString());
$this->view->downtimeLink = Url::fromPath('monitoring/services/schedule-downtime') $this->view->downtimeLink = Url::fromPath('monitoring/services/schedule-downtime')
->setQueryString($this->serviceList->getProblemObjects()->objectsFilter()->toQueryString()); ->setQueryString($this->serviceList->getProblemObjects()->objectsFilter()->toQueryString());
$this->view->acknowledgedObjects = $acknowledgedObjects; $this->view->acknowledgedObjects = $acknowledgedObjects;
$this->view->acknowledgeLink = Url::fromPath('monitoring/services/acknowledge-problem')
->setQueryString($this->serviceList->getUnacknowledgedObjects()->objectsFilter()->toQueryString());
$this->view->unacknowledgedObjects = $this->serviceList->getUnacknowledgedObjects();
$this->view->objectsInDowntime = $this->serviceList->getObjectsInDowntime(); $this->view->objectsInDowntime = $this->serviceList->getObjectsInDowntime();
$this->view->inDowntimeLink = Url::fromPath('monitoring/list/services') $this->view->inDowntimeLink = Url::fromPath('monitoring/list/services')
->setQueryString($this->serviceList->getObjectsInDowntime() ->setQueryString($this->serviceList->getObjectsInDowntime()

View File

@ -72,9 +72,10 @@
<?php <?php
$unhandledCount = count($unhandledObjects); $unhandledCount = count($unhandledObjects);
$problemCount = count($problemObjects); $problemCount = count($problemObjects);
$unackCount = count($unacknowledgedObjects);
?> ?>
<?php if ($problemCount || $unhandledCount): ?> <?php if ($problemCount || $unhandledCount || $unackCount): ?>
<h3> <h3>
<?= $this->icon('attention-alt') ?> <?= $this->icon('attention-alt') ?>
<?= $this->translatePlural( <?= $this->translatePlural(
@ -110,6 +111,24 @@
); ?> ); ?>
<?php endif; ?> <?php endif; ?>
<?php
if ($unackCount > 0): ?>
<br>
<?= $this->qlink(
sprintf(
$this->translatePlural(
'Acknowledge %u unacknowledged problem hosts',
'Acknowledge %u unacknowledged problem hosts',
$unackCount
),
$unackCount
),
$acknowledgeLink,
null,
array('icon' => 'ok')
); ?>
<?php endif; ?>
<?php if ($unhandledCount): ?> <?php if ($unhandledCount): ?>
<p> <p>
<?= sprintf( <?= sprintf(
@ -136,21 +155,6 @@
array('icon' => 'plug') array('icon' => 'plug')
); ?> ); ?>
<br>
<?= $this->qlink(
sprintf(
$this->translatePlural(
'Acknowledge %u unhandled problem host',
'Acknowledge %u unhandled problem hosts',
$unhandledCount
),
$unhandledCount
),
$acknowledgeUnhandledLink,
null,
array('icon' => 'ok')
); ?>
<?php endif; ?> <?php endif; ?>
<?php endif;?> <?php endif;?>

View File

@ -70,9 +70,10 @@
<?php <?php
$unhandledCount = count($unhandledObjects); $unhandledCount = count($unhandledObjects);
$problemCount = count($problemObjects); $problemCount = count($problemObjects);
$unackCount = count($unacknowledgedObjects);
?> ?>
<?php if ($problemCount || $unhandledCount): ?> <?php if ($problemCount || $unhandledCount || $unackCount): ?>
<div> <div>
<h3> <h3>
<?= $this->icon('attention-alt') ?> <?= $this->icon('attention-alt') ?>
@ -105,6 +106,25 @@
); ?> ); ?>
<?php endif ?> <?php endif ?>
<?php
?>
<?php if ($unackCount > 0): ?>
<br>
<?= $this->qlink(
sprintf(
$this->translatePlural(
'Acknowledge %u unacknowledged problem service',
'Acknowledge %u unacknowledged problem services',
$unackCount
),
$unackCount
),
$acknowledgeLink,
null,
array('icon' => 'ok')
); ?>
<?php endif; ?>
<?php if ($unhandledCount): ?> <?php if ($unhandledCount): ?>
<p> <p>
<?= sprintf($this->translate('There are %s unhandled problem services. ' . <?= sprintf($this->translate('There are %s unhandled problem services. ' .
@ -126,20 +146,6 @@
array('icon' => 'plug') array('icon' => 'plug')
); ?> ); ?>
<br>
<?= $this->qlink(
sprintf(
$this->translatePlural(
'Acknowledge %u unhandled problem service',
'Acknowledge %u unhandled problem services',
$unhandledCount
),
$unhandledCount
),
$acknowledgeUnhandledLink,
null,
array('icon' => 'ok')
); ?>
<?php endif ?> <?php endif ?>
</div> </div>

View File

@ -99,4 +99,19 @@ class HostList extends ObjectList
->applyFilter(clone $this->filter) ->applyFilter(clone $this->filter)
->where('downtime_objecttype', 'host'); ->where('downtime_objecttype', 'host');
} }
/**
* @return ObjectList
*/
public function getUnacknowledgedObjects()
{
$unhandledObjects = array();
foreach ($this as $object) {
if (! in_array((int) $object->state, array(0, 99)) &&
(bool) $object->host_acknowledged === false) {
$unhandledObjects[] = $object;
}
}
return $this->newFromArray($unhandledObjects);
}
} }

View File

@ -193,6 +193,11 @@ abstract class ObjectList implements Countable, IteratorAggregate
return $this->newFromArray($handledObjects); return $this->newFromArray($handledObjects);
} }
/**
* @return ObjectList
*/
public abstract function getUnacknowledgedObjects();
/** /**
* Create a ObjectList from an array of hosts without querying a backend * Create a ObjectList from an array of hosts without querying a backend
* *

View File

@ -147,4 +147,19 @@ class ServiceList extends ObjectList
->applyFilter(clone $this->filter) ->applyFilter(clone $this->filter)
->where('downtime_objecttype', 'service'); ->where('downtime_objecttype', 'service');
} }
/**
* @return ObjectList
*/
public function getUnacknowledgedObjects()
{
$unhandledObjects = array();
foreach ($this as $object) {
if (! in_array((int) $object->state, array(0, 99)) &&
(bool) $object->service_acknowledged === false) {
$unhandledObjects[] = $object;
}
}
return $this->newFromArray($unhandledObjects);
}
} }