Small perfdata improvements

This commit is contained in:
Thomas Gelf 2013-10-22 20:35:18 +00:00
parent 5d3fbd1cdf
commit 3ac869981a
2 changed files with 17 additions and 1 deletions

View File

@ -36,6 +36,22 @@ class Perfdata
}
}
public function hasMax()
{
return $this->max !== null && $this->max > 0;
}
public function getPercentage()
{
if ($this->unit === self::PERCENT) {
return $this->val;
}
if ($this->hasMax()) {
return $this->val / $this->max * 100;
}
return false;
}
public function getValue()
{
return $this->val;

View File

@ -30,7 +30,7 @@ class PerfdataSet
public function getAll()
{
return $this->perfdata;
return $this->perfdata === null ? array() : $this->perfdata;
}
protected function readLabel()