diff --git a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php index b1c71cb72..ef91f7f93 100644 --- a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php +++ b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php @@ -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; + } }