Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add Support for Swap Output on TrueNas Core
Signed-off-by: Matthew Wener <[email protected]>
  • Loading branch information
ConstrictM committed Feb 24, 2023
commit 19aed8657320fb9607f5d71b4b1c8b3568f07e36
8 changes: 4 additions & 4 deletions lib/OperatingSystems/FreeBSD.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ public function getMemory(): Memory {
}

$matches = [];
$pattern = '/(?>\/dev\/\w+)\s+(?>\d+)\s+(?<Used>\d+)\s+(?<Avail>\d+)\s+(?<Capacity>\d+)/';
$pattern = '/(?>\/dev\/\S+)\s+(?>\d+)\s+(?<Used>\d+)\s+(?<Avail>\d+)\s+(?<Capacity>\d+)/';

$result = preg_match_all($pattern, $swapinfo, $matches);
if ($result === 1) {
$data->setSwapTotal((int)((int)$matches['Avail'][0] / 1024));
$data->setSwapFree(($data->getSwapTotal() - (int)((int)$matches['Used'][0] / 1024)));
if ($result !== 0) {
$data->setSwapTotal((int)((int)array_sum($matches['Avail']) / 1024));
$data->setSwapFree(($data->getSwapTotal() - (int)((int)array_sum($matches['Used']) / 1024)));
}

unset($matches, $result);
Expand Down