mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
PerfDataFormat: Support small and high units at the same time
This commit is contained in:
parent
edd425b120
commit
7dbfc1a80b
1 changed files with 11 additions and 1 deletions
|
|
@ -142,6 +142,16 @@ class PerfDataFormat
|
|||
$pow = $result = 0;
|
||||
} else {
|
||||
$pow = floor(log($value, $base));
|
||||
|
||||
// Identify nearest unit if unknown
|
||||
while (! isset($units[$pow])) {
|
||||
if ($pow < 0) {
|
||||
$pow++;
|
||||
} else {
|
||||
$pow--;
|
||||
}
|
||||
}
|
||||
|
||||
$result = $value / pow($base, $pow);
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +164,7 @@ class PerfDataFormat
|
|||
'%s%0.2f %s',
|
||||
$sign,
|
||||
$result,
|
||||
$units[abs($pow)]
|
||||
$units[$pow]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue