Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/serverinfo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-01-04 01:54:21 +0300
committerGitHub <noreply@github.com>2018-01-04 01:54:21 +0300
commit203e90df095ed70a0a9cbbe498e8e601f893d4b5 (patch)
treece115e5cfd2c382224d6e512894ea4e2e2a8c93a
parent29d86722b27ae09643233163c8c166838fd1ec7b (diff)
parent6089e0a15db604987acf0efd0e5640e980fe4cec (diff)
Merge pull request #109 from nextcloud/fix108
Show swap usage in FreeBSD systems
-rw-r--r--lib/SystemStatistics.php16
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'
];
}
}