Implement ::getState()

refs #8205
This commit is contained in:
Alexander A. Klimov 2015-05-29 17:26:56 +02:00
parent 068bfc0c71
commit 1f36e545d9
1 changed files with 27 additions and 0 deletions

View File

@ -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,30 @@ 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;
}
}