Skip to content
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

Merged
merged 1 commit into from
Sep 7, 2020
Merged

Conversation

kesselb
Copy link
Collaborator

@kesselb kesselb commented Sep 5, 2020

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).

@@ -195,7 +191,7 @@ public function getDiskInfo(): array {
$data = [];

try {
$disks = $this->executeCommand('df -TP');
$disks = $this->executeCommand('df -TPk');
Copy link
Collaborator Author

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.

@kesselb kesselb changed the title Normalize memory to MB Normalize memory and disk values to MB Sep 5, 2020
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
@@ -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));
Copy link
Collaborator Author

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.

@kesselb kesselb added this to the Nextcloud 20 milestone Sep 5, 2020
@rullzer rullzer mentioned this pull request Sep 6, 2020
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception when trying to display System information in R20.0.0 B3
2 participants