From ec2d1daa6b72b87959af9e66ef7e95820e1dfb38 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 11 Jul 2014 16:31:00 +0200 Subject: [PATCH] Perfdata plugin should also have a knowledge about labels Prior to this change the PerfdataSet only knew the labels of a performance data value which prevented the Perfdata object from being used individually. refs #6515 --- .../application/clicommands/ListCommand.php | 4 +- .../application/views/helpers/Perfdata.php | 12 +- .../library/Monitoring/Plugin/Perfdata.php | 60 +++++--- .../library/Monitoring/Plugin/PerfdataSet.php | 2 +- .../Monitoring/Plugin/PerfdataSetTest.php | 40 +++--- .../Monitoring/Plugin/PerfdataTest.php | 135 ++++++++++++------ 6 files changed, 161 insertions(+), 92 deletions(-) diff --git a/modules/monitoring/application/clicommands/ListCommand.php b/modules/monitoring/application/clicommands/ListCommand.php index 2548c138e..320e144d7 100644 --- a/modules/monitoring/application/clicommands/ListCommand.php +++ b/modules/monitoring/application/clicommands/ListCommand.php @@ -263,13 +263,13 @@ class ListCommand extends Command try { $pset = PerfdataSet::fromString($row->service_perfdata); $perfs = array(); - foreach ($pset as $perfName => $p) { + foreach ($pset as $p) { if ($percent = $p->getPercentage()) { if ($percent < 0 || $percent > 100) { continue; } $perfs[] = ' ' - . $perfName + . $p->getLabel() . ': ' . $this->getPercentageSign($percent) . ' ' diff --git a/modules/monitoring/application/views/helpers/Perfdata.php b/modules/monitoring/application/views/helpers/Perfdata.php index a9ede94fd..68b9b1e9e 100644 --- a/modules/monitoring/application/views/helpers/Perfdata.php +++ b/modules/monitoring/application/views/helpers/Perfdata.php @@ -14,11 +14,11 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract $result = ''; $table = array(); $pset = array_slice(PerfdataSet::fromString($perfdataStr)->asArray(), 0, ($compact ? 5 : null)); - foreach ($pset as $label => $perfdata) { + foreach ($pset as $perfdata) { if (!$perfdata->isPercentage() && $perfdata->getMaximumValue() === null) { continue; } - $pieChart = $this->createInlinePie($perfdata, $label, htmlspecialchars($label)); + $pieChart = $this->createInlinePie($perfdata); if ($compact) { if (! $float) { $result .= $pieChart->render(); @@ -31,7 +31,7 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract } $pieChart->setStyle('margin: 0.2em 0.5em 0.2em 0.5em;'); $table[] = '' . $pieChart->render() - . htmlspecialchars($label) + . htmlspecialchars($perfdata->getLabel()) . ' ' . htmlspecialchars($this->formatPerfdataValue($perfdata)) . ' '; @@ -81,10 +81,10 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract return $perfdata->getValue(); } - protected function createInlinePie(Perfdata $perfdata, $title, $label = '') + protected function createInlinePie(Perfdata $perfdata) { - $pieChart = new InlinePie($this->calculatePieChartData($perfdata), $title); - $pieChart->setLabel($label); + $pieChart = new InlinePie($this->calculatePieChartData($perfdata), $perfdata->getLabel()); + $pieChart->setLabel(htmlspecialchars($perfdata->getLabel())); $pieChart->setHideEmptyLabel(); //$pieChart->setHeight(32)->setWidth(32); diff --git a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php index a23c60392..44d3765b8 100644 --- a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php +++ b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php @@ -4,7 +4,7 @@ namespace Icinga\Module\Monitoring\Plugin; -use Icinga\Exception\ProgrammingError; +use InvalidArgumentException; class Perfdata { @@ -22,6 +22,13 @@ class Perfdata */ protected $unit; + /** + * The label + * + * @var string + */ + protected $label; + /** * The value * @@ -58,13 +65,15 @@ class Perfdata protected $criticalThreshold; /** - * Create a new Perfdata object based on the given performance data value + * Create a new Perfdata object based on the given performance data label and value * - * @param string $perfdataValue The value to parse + * @param string $label The perfdata label + * @param string $value The perfdata value */ - protected function __construct($perfdataValue) + public function __construct($label, $value) { - $this->perfdataValue = $perfdataValue; + $this->perfdataValue = $value; + $this->label = $label; $this->parse(); if ($this->unit === '%') { @@ -78,25 +87,30 @@ class Perfdata } /** - * Return a new Perfdata object based on the given performance data value + * Return a new Perfdata object based on the given performance data key=value pair * - * @param string $perfdataValue The value to parse + * @param string $perfdata The key=value pair to parse * * @return Perfdata * - * @throws ProgrammingError In case the given performance data value has no content + * @throws InvalidArgumentException In case the given performance data has no content or a invalid format */ - public static function fromString($perfdataValue) + public static function fromString($perfdata) { - if (empty($perfdataValue)) { - throw new ProgrammingError('Perfdata::fromString expects a string with content'); + if (empty($perfdata)) { + throw new InvalidArgumentException('Perfdata::fromString expects a string with content'); + } elseif (false === strpos($perfdata, '=')) { + throw new InvalidArgumentException( + 'Perfdata::fromString expects a key=value formatted string. Got "' . $perfdata . '" instead' + ); } - return new static($perfdataValue); + list($label, $value) = explode('=', $perfdata, 2); + return new static(trim($label), trim($value)); } /** - * Return whether this performance data value is a number + * Return whether this performance data's value is a number * * @return bool True in case it's a number, otherwise False */ @@ -106,7 +120,7 @@ class Perfdata } /** - * Return whether this performance data value are seconds + * Return whether this performance data's value are seconds * * @return bool True in case it's seconds, otherwise False */ @@ -116,7 +130,7 @@ class Perfdata } /** - * Return whether this performance data value is in percentage + * Return whether this performance data's value is in percentage * * @return bool True in case it's in percentage, otherwise False */ @@ -126,7 +140,7 @@ class Perfdata } /** - * Return whether this performance data value is in bytes + * Return whether this performance data's value is in bytes * * @return bool True in case it's in bytes, otherwise False */ @@ -136,7 +150,7 @@ class Perfdata } /** - * Return whether this performance data value is a counter + * Return whether this performance data's value is a counter * * @return bool True in case it's a counter, otherwise False */ @@ -145,6 +159,14 @@ class Perfdata return $this->unit === 'c'; } + /** + * Return this perfomance data's label + */ + public function getLabel() + { + return $this->label; + } + /** * Return the value or null if it is unknown (U) * @@ -176,7 +198,7 @@ class Perfdata } /** - * Return this value's warning treshold or null if it is not available + * Return this performance data's warning treshold or null if it is not available * * @return null|string */ @@ -186,7 +208,7 @@ class Perfdata } /** - * Return this value's critical treshold or null if it is not available + * Return this performance data's critical treshold or null if it is not available * * @return null|string */ diff --git a/modules/monitoring/library/Monitoring/Plugin/PerfdataSet.php b/modules/monitoring/library/Monitoring/Plugin/PerfdataSet.php index 8038354a4..c62904bb3 100644 --- a/modules/monitoring/library/Monitoring/Plugin/PerfdataSet.php +++ b/modules/monitoring/library/Monitoring/Plugin/PerfdataSet.php @@ -85,7 +85,7 @@ class PerfdataSet implements IteratorAggregate $value = trim($this->readUntil(' ')); if ($label && $value) { - $this->perfdata[$label] = Perfdata::fromString($value); + $this->perfdata[] = new Perfdata($label, $value); } } } diff --git a/modules/monitoring/test/php/library/Monitoring/Plugin/PerfdataSetTest.php b/modules/monitoring/test/php/library/Monitoring/Plugin/PerfdataSetTest.php index 86c0f71a7..3edd20857 100644 --- a/modules/monitoring/test/php/library/Monitoring/Plugin/PerfdataSetTest.php +++ b/modules/monitoring/test/php/library/Monitoring/Plugin/PerfdataSetTest.php @@ -17,19 +17,19 @@ class PerfdataSetTest extends BaseTestCase public function testWhetherValidSimplePerfdataLabelsAreProperlyParsed() { $pset = PerfdataSetWithPublicData::fromString('key1=val1 key2=val2 key3 =val3'); - $this->assertArrayHasKey( + $this->assertEquals( 'key1', - $pset->perfdata, + $pset->perfdata[0]->getLabel(), 'PerfdataSet does not correctly parse valid simple labels' ); - $this->assertArrayHasKey( + $this->assertEquals( 'key2', - $pset->perfdata, + $pset->perfdata[1]->getLabel(), 'PerfdataSet does not correctly parse valid simple labels' ); - $this->assertArrayHasKey( + $this->assertEquals( 'key3', - $pset->perfdata, + $pset->perfdata[2]->getLabel(), 'PerfdataSet does not correctly parse valid simple labels' ); } @@ -37,14 +37,14 @@ class PerfdataSetTest extends BaseTestCase public function testWhetherNonQuotedPerfdataLablesWithSpacesAreProperlyParsed() { $pset = PerfdataSetWithPublicData::fromString('key 1=val1 key 1 + 1=val2'); - $this->assertArrayHasKey( + $this->assertEquals( 'key 1', - $pset->perfdata, + $pset->perfdata[0]->getLabel(), 'PerfdataSet does not correctly parse non quoted labels with spaces' ); - $this->assertArrayHasKey( + $this->assertEquals( 'key 1 + 1', - $pset->perfdata, + $pset->perfdata[1]->getLabel(), 'PerfdataSet does not correctly parse non quoted labels with spaces' ); } @@ -52,14 +52,14 @@ class PerfdataSetTest extends BaseTestCase public function testWhetherValidQuotedPerfdataLabelsAreProperlyParsed() { $pset = PerfdataSetWithPublicData::fromString('\'key 1\'=val1 "key 2"=val2'); - $this->assertArrayHasKey( + $this->assertEquals( 'key 1', - $pset->perfdata, + $pset->perfdata[0]->getLabel(), 'PerfdataSet does not correctly parse valid quoted labels' ); - $this->assertArrayHasKey( + $this->assertEquals( 'key 2', - $pset->perfdata, + $pset->perfdata[1]->getLabel(), 'PerfdataSet does not correctly parse valid quoted labels' ); } @@ -67,14 +67,14 @@ class PerfdataSetTest extends BaseTestCase public function testWhetherInvalidQuotedPerfdataLabelsAreProperlyParsed() { $pset = PerfdataSetWithPublicData::fromString('\'key 1=val1 key 2"=val2'); - $this->assertArrayHasKey( + $this->assertEquals( 'key 1', - $pset->perfdata, + $pset->perfdata[0]->getLabel(), 'PerfdataSet does not correctly parse invalid quoted labels' ); - $this->assertArrayHasKey( + $this->assertEquals( 'key 2"', - $pset->perfdata, + $pset->perfdata[1]->getLabel(), 'PerfdataSet does not correctly parse invalid quoted labels' ); } @@ -85,8 +85,8 @@ class PerfdataSetTest extends BaseTestCase public function testWhetherAPerfdataSetIsIterable() { $pset = PerfdataSet::fromString('key=value'); - foreach ($pset as $label => $value) { - $this->assertEquals('key', $label); + foreach ($pset as $p) { + $this->assertEquals('key', $p->getLabel()); return; } diff --git a/modules/monitoring/test/php/library/Monitoring/Plugin/PerfdataTest.php b/modules/monitoring/test/php/library/Monitoring/Plugin/PerfdataTest.php index be1de875e..2d8a98b73 100644 --- a/modules/monitoring/test/php/library/Monitoring/Plugin/PerfdataTest.php +++ b/modules/monitoring/test/php/library/Monitoring/Plugin/PerfdataTest.php @@ -10,142 +10,189 @@ use Icinga\Module\Monitoring\Plugin\Perfdata; class PerfdataTest extends BaseTestCase { /** - * @expectedException Icinga\Exception\ProgrammingError + * @expectedException \InvalidArgumentException */ public function testWhetherFromStringThrowsExceptionWhenGivenAnEmptyString() { Perfdata::fromString(''); } + /** + * @expectedException \InvalidArgumentException + */ + public function testWhetherFromStringThrowsExceptionWhenGivenAnInvalidString() + { + Perfdata::fromString('test'); + } + + public function testWhetherFromStringParsesAGivenStringCorrectly() + { + $p = Perfdata::fromString('key=1234'); + $this->assertEquals( + 'key', + $p->getLabel(), + 'Perfdata::fromString does not properly parse performance data labels' + ); + $this->assertEquals( + 1234, + $p->getValue(), + 'Perfdata::fromString does not properly parse performance data values' + ); + } + + /** + * @depends testWhetherFromStringParsesAGivenStringCorrectly + */ public function testWhetherGetValueReturnsValidValues() { $this->assertEquals( 1337.0, - Perfdata::fromString('1337')->getValue(), + Perfdata::fromString('test=1337')->getValue(), 'Perfdata::getValue does not return correct values' ); $this->assertEquals( 1337.0, - Perfdata::fromString('1337;;;;')->getValue(), + Perfdata::fromString('test=1337;;;;')->getValue(), 'Perfdata::getValue does not return correct values' ); } + /** + * @depends testWhetherFromStringParsesAGivenStringCorrectly + */ public function testWhetherDecimalValuesAreCorrectlyParsed() { $this->assertEquals( 1337.5, - Perfdata::fromString('1337.5')->getValue(), + Perfdata::fromString('test=1337.5')->getValue(), 'Perfdata objects do not parse decimal values correctly' ); $this->assertEquals( 1337.5, - Perfdata::fromString('1337.5B')->getValue(), + Perfdata::fromString('test=1337.5B')->getValue(), 'Perfdata objects do not parse decimal values correctly' ); } + /** + * @depends testWhetherFromStringParsesAGivenStringCorrectly + */ public function testWhetherGetValueReturnsNullForInvalidOrUnknownValues() { $this->assertNull( - Perfdata::fromString('U')->getValue(), + Perfdata::fromString('test=U')->getValue(), 'Perfdata::getValue does not return null for unknown values' ); $this->assertNull( - Perfdata::fromString('i am not a value')->getValue(), + Perfdata::fromString('test=i am not a value')->getValue(), 'Perfdata::getValue does not return null for invalid values' ); } + /** + * @depends testWhetherFromStringParsesAGivenStringCorrectly + */ public function testWhetherGetWarningTresholdReturnsCorrectValues() { $this->assertEquals( '10', - Perfdata::fromString('1;10')->getWarningThreshold(), + Perfdata::fromString('test=1;10')->getWarningThreshold(), 'Perfdata::getWarningTreshold does not return correct values' ); $this->assertEquals( '10:', - Perfdata::fromString('1;10:')->getWarningThreshold(), + Perfdata::fromString('test=1;10:')->getWarningThreshold(), 'Perfdata::getWarningTreshold does not return correct values' ); $this->assertEquals( '~:10', - Perfdata::fromString('1;~:10')->getWarningThreshold(), + Perfdata::fromString('test=1;~:10')->getWarningThreshold(), 'Perfdata::getWarningTreshold does not return correct values' ); $this->assertEquals( '10:20', - Perfdata::fromString('1;10:20')->getWarningThreshold(), + Perfdata::fromString('test=1;10:20')->getWarningThreshold(), 'Perfdata::getWarningTreshold does not return correct values' ); $this->assertEquals( '@10:20', - Perfdata::fromString('1;@10:20')->getWarningThreshold(), + Perfdata::fromString('test=1;@10:20')->getWarningThreshold(), 'Perfdata::getWarningTreshold does not return correct values' ); } + /** + * @depends testWhetherFromStringParsesAGivenStringCorrectly + */ public function testWhetherGetCriticalTresholdReturnsCorrectValues() { $this->assertEquals( '10', - Perfdata::fromString('1;;10')->getCriticalThreshold(), + Perfdata::fromString('test=1;;10')->getCriticalThreshold(), 'Perfdata::getCriticalTreshold does not return correct values' ); $this->assertEquals( '10:', - Perfdata::fromString('1;;10:')->getCriticalThreshold(), + Perfdata::fromString('test=1;;10:')->getCriticalThreshold(), 'Perfdata::getCriticalTreshold does not return correct values' ); $this->assertEquals( '~:10', - Perfdata::fromString('1;;~:10')->getCriticalThreshold(), + Perfdata::fromString('test=1;;~:10')->getCriticalThreshold(), 'Perfdata::getCriticalTreshold does not return correct values' ); $this->assertEquals( '10:20', - Perfdata::fromString('1;;10:20')->getCriticalThreshold(), + Perfdata::fromString('test=1;;10:20')->getCriticalThreshold(), 'Perfdata::getCriticalTreshold does not return correct values' ); $this->assertEquals( '@10:20', - Perfdata::fromString('1;;@10:20')->getCriticalThreshold(), + Perfdata::fromString('test=1;;@10:20')->getCriticalThreshold(), 'Perfdata::getCriticalTreshold does not return correct values' ); } + /** + * @depends testWhetherFromStringParsesAGivenStringCorrectly + */ public function testWhetherGetMinimumValueReturnsCorrectValues() { $this->assertEquals( 1337.0, - Perfdata::fromString('1;;;1337')->getMinimumValue(), + Perfdata::fromString('test=1;;;1337')->getMinimumValue(), 'Perfdata::getMinimumValue does not return correct values' ); $this->assertEquals( 1337.5, - Perfdata::fromString('1;;;1337.5')->getMinimumValue(), + Perfdata::fromString('test=1;;;1337.5')->getMinimumValue(), 'Perfdata::getMinimumValue does not return correct values' ); } + /** + * @depends testWhetherFromStringParsesAGivenStringCorrectly + */ public function testWhetherGetMaximumValueReturnsCorrectValues() { $this->assertEquals( 1337.0, - Perfdata::fromString('1;;;;1337')->getMaximumValue(), + Perfdata::fromString('test=1;;;;1337')->getMaximumValue(), 'Perfdata::getMaximumValue does not return correct values' ); $this->assertEquals( 1337.5, - Perfdata::fromString('1;;;;1337.5')->getMaximumValue(), + Perfdata::fromString('test=1;;;;1337.5')->getMaximumValue(), 'Perfdata::getMaximumValue does not return correct values' ); } + /** + * @depends testWhetherFromStringParsesAGivenStringCorrectly + */ public function testWhetherMissingValuesAreReturnedAsNull() { - $perfdata = Perfdata::fromString('1;;3;5'); + $perfdata = Perfdata::fromString('test=1;;3;5'); $this->assertNull( $perfdata->getWarningThreshold(), 'Perfdata objects do not return null for missing warning tresholds' @@ -162,7 +209,7 @@ class PerfdataTest extends BaseTestCase public function testWhetherValuesAreIdentifiedAsNumber() { $this->assertTrue( - Perfdata::fromString('666')->isNumber(), + Perfdata::fromString('test=666')->isNumber(), 'Perfdata objects do not identify ordinary digits as number' ); } @@ -173,15 +220,15 @@ class PerfdataTest extends BaseTestCase public function testWhetherValuesAreIdentifiedAsSeconds() { $this->assertTrue( - Perfdata::fromString('666s')->isSeconds(), + Perfdata::fromString('test=666s')->isSeconds(), 'Perfdata objects do not identify seconds as seconds' ); $this->assertTrue( - Perfdata::fromString('666us')->isSeconds(), + Perfdata::fromString('test=666us')->isSeconds(), 'Perfdata objects do not identify microseconds as seconds' ); $this->assertTrue( - Perfdata::fromString('666ms')->isSeconds(), + Perfdata::fromString('test=666ms')->isSeconds(), 'Perfdata objects do not identify milliseconds as seconds' ); } @@ -192,7 +239,7 @@ class PerfdataTest extends BaseTestCase public function testWhetherValuesAreIdentifiedAsPercentage() { $this->assertTrue( - Perfdata::fromString('66%')->isPercentage(), + Perfdata::fromString('test=66%')->isPercentage(), 'Perfdata objects do not identify percentages as percentages' ); } @@ -202,7 +249,7 @@ class PerfdataTest extends BaseTestCase */ public function testWhetherMinAndMaxAreNotRequiredIfUnitIsInPercent() { - $perfdata = Perfdata::fromString('1%'); + $perfdata = Perfdata::fromString('test=1%'); $this->assertEquals( 0.0, $perfdata->getMinimumValue(), @@ -221,23 +268,23 @@ class PerfdataTest extends BaseTestCase public function testWhetherValuesAreIdentifiedAsBytes() { $this->assertTrue( - Perfdata::fromString('66666B')->isBytes(), + Perfdata::fromString('test=66666B')->isBytes(), 'Perfdata objects do not identify bytes as bytes' ); $this->assertTrue( - Perfdata::fromString('6666KB')->isBytes(), + Perfdata::fromString('test=6666KB')->isBytes(), 'Perfdata objects do not identify kilobytes as bytes' ); $this->assertTrue( - Perfdata::fromString('666MB')->isBytes(), + Perfdata::fromString('test=666MB')->isBytes(), 'Perfdata objects do not identify megabytes as bytes' ); $this->assertTrue( - Perfdata::fromString('66GB')->isBytes(), + Perfdata::fromString('test=66GB')->isBytes(), 'Perfdata objects do not identify gigabytes as bytes' ); $this->assertTrue( - Perfdata::fromString('6TB')->isBytes(), + Perfdata::fromString('test=6TB')->isBytes(), 'Perfdata objects do not identify terabytes as bytes' ); } @@ -248,7 +295,7 @@ class PerfdataTest extends BaseTestCase public function testWhetherValuesAreIdentifiedAsCounter() { $this->assertTrue( - Perfdata::fromString('123c')->isCounter(), + Perfdata::fromString('test=123c')->isCounter(), 'Perfdata objects do not identify counters as counters' ); } @@ -260,7 +307,7 @@ class PerfdataTest extends BaseTestCase { $this->assertEquals( 666 / pow(10, 6), - Perfdata::fromString('666us')->getValue(), + Perfdata::fromString('test=666us')->getValue(), 'Perfdata objects do not correctly convert microseconds to seconds' ); } @@ -272,7 +319,7 @@ class PerfdataTest extends BaseTestCase { $this->assertEquals( 666 / pow(10, 3), - Perfdata::fromString('666ms')->getValue(), + Perfdata::fromString('test=666ms')->getValue(), 'Perfdata objects do not correctly convert microseconds to seconds' ); } @@ -284,20 +331,20 @@ class PerfdataTest extends BaseTestCase { $this->assertEquals( 66.0, - Perfdata::fromString('66%')->getPercentage(), + Perfdata::fromString('test=66%')->getPercentage(), 'Perfdata objects do not correctly handle native percentages' ); $this->assertEquals( 50.0, - Perfdata::fromString('0;;;-250;250')->getPercentage(), + Perfdata::fromString('test=0;;;-250;250')->getPercentage(), 'Perfdata objects do not correctly convert suitable values to percentages' ); $this->assertNull( - Perfdata::fromString('50')->getPercentage(), + Perfdata::fromString('test=50')->getPercentage(), 'Perfdata objects do return a percentage though their unit is not % and no maximum is given' ); $this->assertNull( - Perfdata::fromString('25;;;50;100')->getPercentage(), + Perfdata::fromString('test=25;;;50;100')->getPercentage(), 'Perfdata objects do return a percentage though their value is lower than it\'s allowed minimum' ); } @@ -309,7 +356,7 @@ class PerfdataTest extends BaseTestCase { $this->assertEquals( 6666.0 * pow(2, 10), - Perfdata::fromString('6666KB')->getValue(), + Perfdata::fromString('test=6666KB')->getValue(), 'Perfdata objects do not corretly convert kilobytes to bytes' ); } @@ -321,7 +368,7 @@ class PerfdataTest extends BaseTestCase { $this->assertEquals( 666.0 * pow(2, 20), - Perfdata::fromString('666MB')->getValue(), + Perfdata::fromString('test=666MB')->getValue(), 'Perfdata objects do not corretly convert megabytes to bytes' ); } @@ -333,7 +380,7 @@ class PerfdataTest extends BaseTestCase { $this->assertEquals( 66.0 * pow(2, 30), - Perfdata::fromString('66GB')->getValue(), + Perfdata::fromString('test=66GB')->getValue(), 'Perfdata objects do not corretly convert gigabytes to bytes' ); } @@ -345,7 +392,7 @@ class PerfdataTest extends BaseTestCase { $this->assertEquals( 6.0 * pow(2, 40), - Perfdata::fromString('6TB')->getValue(), + Perfdata::fromString('test=6TB')->getValue(), 'Perfdata objects do not corretly convert terabytes to bytes' ); }