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:
authortflidd <tflidd@aspekte.net>2017-11-01 23:43:23 +0300
committerMorris Jobke <hey@morrisjobke.de>2017-11-06 18:41:48 +0300
commit534fcf7ab50e8905d7bedfa7b0712ec8d765c483 (patch)
treec0c38b7173ec4d56b3ecc0e0d77c73493fc2916b
parent47f43f8e4a49aa62e1cb38f3b66aa4cf7b84df4f (diff)
Add memory readout for FreeBSD
Signed-off-by: Joachim Börner tflidd@aspekte.net
-rw-r--r--lib/SystemStatistics.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/SystemStatistics.php b/lib/SystemStatistics.php
index 28966de..ca0aa07 100644
--- a/lib/SystemStatistics.php
+++ b/lib/SystemStatistics.php
@@ -73,6 +73,19 @@ class SystemStatistics {
// read meminfo from OS
$memoryUsage = file_get_contents('/proc/meminfo');
}
+ //If FreeBSD is used and exec()-usage is allowed
+ if (PHP_OS === 'FreeBSD' && \OC_Helper::is_function_enabled('exec')) {
+ 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
+ ];
+ }
+ }
+ }
// check if determining memoryUsage failed
if ($memoryUsage === false) {
return ['mem_free' => 'N/A', 'mem_total' => 'N/A'];