Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 18 additions & 6 deletions lib/OperatingSystems/FreeBSD.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ public function getMemory(): array {
$data = ['MemTotal' => -1, 'MemFree' => -1, 'MemAvailable' => -1, 'SwapTotal' => -1, 'SwapFree' => -1];

try {
$swapinfo = $this->executeCommand('/usr/sbin/swapinfo');
$swapinfo = $this->executeCommand('/usr/sbin/swapinfo -k');
$line = preg_split("/[\s]+/", $swapinfo);

if (count($line) > 3) {
$data['SwapTotal'] = (int)$line[3];
$data['SwapFree'] = $data['SwapTotal'] - (int)$line[2];
}

$meminfo = $this->executeCommand('/sbin/sysctl -n hw.physmem hw.pagesize vm.stats.vm.v_inactive_count vm.stats.vm.v_cache_count vm.stats.vm.v_free_count');
$meminfo = $this->executeCommand('/sbin/sysctl -n hw.realmem hw.pagesize vm.stats.vm.v_inactive_count vm.stats.vm.v_cache_count vm.stats.vm.v_free_count');

$line = preg_split('/\s+/', trim($meminfo));
if (count($line) > 4) {
Expand All @@ -77,7 +77,14 @@ public function getCPUName(): string {
$data = 'Unknown Processor';

try {
$data = $this->executeCommand('/sbin/sysctl -n hw.model');
$model = $this->executeCommand('/sbin/sysctl -n hw.model');
$cores = $this->executeCommand('/sbin/sysctl -n kern.smp.cpus');

if ($cores === 1) {
$data = $model . ' (1 core)';
} else {
$data = $model . ' (' . $cores . ' cores)';
}
} catch (\RuntimeException $e) {
return $data;
}
Expand Down Expand Up @@ -175,15 +182,20 @@ public function getNetworkInterfaces() {
if ($iface['interface'] !== 'lo0') {
preg_match_all("/(?<=ether ).*/m", $intface, $mac);
preg_match("/(?<=status: ).*/m", $intface, $status);
preg_match("/(?<=\().*(?=b)/m", $intface, $speed);
preg_match("/\b[0-9].*?(?=base)/m", $intface, $speed);
preg_match("/(?<=\<).*(?=-)/m", $intface, $duplex);

$iface['mac'] = implode(' ', $mac[0]);
$iface['status'] = $status[0];
$iface['speed'] = $speed[0];

if ($iface['speed'] !== '') {
$iface['speed'] = $iface['speed'];
if (strpos($iface['speed'], 'G')) {
$iface['speed'] = rtrim($iface['speed'], 'G');
$iface['speed'] = $iface['speed'] . ' Gbps';
} else {
$iface['speed'] = $iface['speed'] . ' Mbps';
}
} else {
$iface['speed'] = 'unknown';
}
Expand Down Expand Up @@ -217,7 +229,7 @@ public function getDiskInfo(): array {
$data = [];

try {
$disks = $this->executeCommand('df -TP');
$disks = $this->executeCommand('df -TPk');
} catch (\RuntimeException $e) {
return $data;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/SystemStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected function getMemoryUsage() {
//If FreeBSD is used and exec()-usage is allowed
if (PHP_OS === 'FreeBSD' && $this->is_function_enabled('exec')) {
//Read Swap usage:
exec("/usr/sbin/swapinfo", $return, $status);
exec("/usr/sbin/swapinfo -k", $return, $status);
if ($status === 0 && count($return) > 1) {
$line = preg_split("/[\s]+/", $return[1]);
if (count($line) > 3) {
Expand Down