From 23619829de3bf25c07342be6c27b6c304998090b Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Thu, 5 May 2016 18:06:38 +0200 Subject: [PATCH] (dashboard, widgets) work in progress sys info widget backend --- src/www/widgets/api/plugins/system.inc | 97 ++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/www/widgets/api/plugins/system.inc diff --git a/src/www/widgets/api/plugins/system.inc b/src/www/widgets/api/plugins/system.inc new file mode 100644 index 000000000..1011cbfdf --- /dev/null +++ b/src/www/widgets/api/plugins/system.inc @@ -0,0 +1,97 @@ + array()); + $result['pf']['maxstates'] = !empty($config['system']['maximumstates']) ? $config['system']['maximumstates'] : default_state_size(); + exec('/sbin/pfctl -si |grep "current entries" 2>/dev/null', $states); + $result['pf']['states'] = count($states) > 0 ? filter_var($states[0], FILTER_SANITIZE_NUMBER_INT) : 0; + return $result; +} + +/** + * widget system data + */ +function system_api() +{ + $result = array(); + + $result['cpu'] = system_api_cpu_stats(); + preg_match("/sec = (\d+)/", get_single_sysctl("kern.boottime"), $matches); + $result['uptime'] = time() - $matches[1]; + $result['date_frmt'] = date("D M j G:i:s T Y"); + $result['config'] = system_api_config(); + $result['kernel'] = system_api_kernel(); + + return $result; +}