diff options
author | Joachim Boerner <tflidd@aspekte.net> | 2017-12-24 16:03:21 +0300 |
---|---|---|
committer | Joachim Boerner <tflidd@aspekte.net> | 2017-12-24 16:03:21 +0300 |
commit | 6089e0a15db604987acf0efd0e5640e980fe4cec (patch) | |
tree | ce115e5cfd2c382224d6e512894ea4e2e2a8c93a | |
parent | 29d86722b27ae09643233163c8c166838fd1ec7b (diff) |
Show swap usage in FreeBSD systems
Signed-off-by: Joachim Boerner <tflidd@aspekte.net>
-rw-r--r-- | lib/SystemStatistics.php | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/SystemStatistics.php b/lib/SystemStatistics.php index d9cd669..81d85a9 100644 --- a/lib/SystemStatistics.php +++ b/lib/SystemStatistics.php @@ -77,13 +77,27 @@ class SystemStatistics { } //If FreeBSD is used and exec()-usage is allowed if (PHP_OS === 'FreeBSD' && \OC_Helper::is_function_enabled('exec')) { + //Read Swap usage: + exec("/usr/sbin/swapinfo",$return,$status); + if ($status===0 && count($return) > 1) { + $line = preg_split("/[\s]+/", $return[1]); + if(count($line) > 3) { + $swapTotal = (int) $line[3]; + $swapFree = $swapTotal- (int) $line[2]; + } + } + unset($status); + unset($return); + //Read Memory Usage exec("/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",$return,$status); if ($status===0) { $return=array_map('intval',$return); if ($return === array_filter($return, 'is_int')) { return [ 'mem_total' => (int) $return[0]/1024, - 'mem_free' => (int) $return[1]*($return[2]+$return[3]+$return[4])/1024 + 'mem_free' => (int) $return[1]*($return[2]+$return[3]+$return[4])/1024, + 'swap_free' => (isset($swapFree)) ? $swapFree : 'N/A', + 'swap_total' => (isset($swapTotal)) ? $swapTotal : 'N/A' ]; } } |