Merge branch 'bugfix/don-t-show-more-than-the-five-worst-pies-in-list-views-8205'
fixes #8205
This commit is contained in:
commit
3caa5b428a
|
@ -20,6 +20,12 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
|
|||
public function perfdata($perfdataStr, $compact = false, $limit = 0, $color = Perfdata::PERFDATA_OK)
|
||||
{
|
||||
$pieChartData = PerfdataSet::fromString($perfdataStr)->asArray();
|
||||
uasort(
|
||||
$pieChartData,
|
||||
function($a, $b) {
|
||||
return $a->worseThan($b) ? -1 : ($b->worseThan($a) ? 1 : 0);
|
||||
}
|
||||
);
|
||||
$results = array();
|
||||
$keys = array('', 'label', 'value', 'min', 'max', 'warn', 'crit');
|
||||
$columns = array();
|
||||
|
|
|
@ -60,7 +60,7 @@ if (count($services) === 0) {
|
|||
</td>
|
||||
|
||||
<td>
|
||||
<div class="sparkline-box"><?= $this->perfdata($service->service_perfdata, true, 8) ?> </div>
|
||||
<div class="sparkline-box"><?= $this->perfdata($service->service_perfdata, true, 5) ?> </div>
|
||||
<?= $this->iconImage()->service($service) ?>
|
||||
<?= implode(' ', $this->serviceFlags($service)); ?>
|
||||
<?= $this->qlink(
|
||||
|
|
|
@ -7,6 +7,7 @@ use Icinga\Util\Format;
|
|||
use InvalidArgumentException;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Web\Widget\Chart\InlinePie;
|
||||
use Icinga\Module\Monitoring\Object\Service;
|
||||
use Zend_Controller_Front;
|
||||
|
||||
class Perfdata
|
||||
|
@ -453,4 +454,60 @@ class Perfdata
|
|||
);
|
||||
return $parts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the state indicated by this perfdata
|
||||
*
|
||||
* @see Service
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getState()
|
||||
{
|
||||
if ($this->value === null) {
|
||||
return Service::STATE_UNKNOWN;
|
||||
}
|
||||
|
||||
if (! ($this->criticalThreshold === null
|
||||
|| $this->value < $this->criticalThreshold)) {
|
||||
return Service::STATE_CRITICAL;
|
||||
}
|
||||
|
||||
if (! ($this->warningThreshold === null
|
||||
|| $this->value < $this->warningThreshold)) {
|
||||
return Service::STATE_WARNING;
|
||||
}
|
||||
|
||||
return Service::STATE_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the state indicated by this perfdata is worse than
|
||||
* the state indicated by the other perfdata
|
||||
* CRITICAL > UNKNOWN > WARNING > OK
|
||||
*
|
||||
* @param Perfdata $rhs the other perfdata
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function worseThan(Perfdata $rhs)
|
||||
{
|
||||
if (($state = $this->getState()) === ($rhsState = $rhs->getState())) {
|
||||
return $this->getPercentage() > $rhs->getPercentage();
|
||||
}
|
||||
|
||||
if ($state === Service::STATE_CRITICAL) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($state === Service::STATE_UNKNOWN) {
|
||||
return $rhsState !== Service::STATE_CRITICAL;
|
||||
}
|
||||
|
||||
if ($state === Service::STATE_WARNING) {
|
||||
return $rhsState === Service::STATE_OK;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue