-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Normalize memory and disk values to MB #231
Conversation
b37e65e
to
da649ab
Compare
@@ -195,7 +191,7 @@ public function getDiskInfo(): array { | |||
$data = []; | |||
|
|||
try { | |||
$disks = $this->executeCommand('df -TP'); | |||
$disks = $this->executeCommand('df -TPk'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-k
= --block-size=1K
which is the default on most linux systems.
Signed-off-by: Daniel Kesselberg <[email protected]>
0974082
to
dcdafc1
Compare
@@ -53,8 +53,8 @@ public function getMemory(): Memory { | |||
|
|||
$result = preg_match_all($pattern, $swapinfo, $matches); | |||
if ($result === 1) { | |||
$data->setSwapTotal((int)$matches['Avail'][0]); | |||
$data->setSwapFree($data->getSwapTotal() - (int)$matches['Used'][0]); | |||
$data->setSwapTotal((int)($matches['Avail'][0] / 1024)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
swapinfo -k returns the values as KB. The conversion to bytes was missing here. Now they are correct.
Close #230
Argument 1 passed to OCA\\ServerInfo\\Resources\\Disk::setUsed() must be of the type int, float given
Disk and Memory objects are strictly typed. That's a problem if you are using more than 2147483647 bytes on a 32 bit system. To workaround this issue I changed the units to MB and normalize the values before. As hardening the last call is always
(int)
.