From e8a82150fe19115fa62dacf32c6734f4f93f113f Mon Sep 17 00:00:00 2001 From: Thomas Plorin Date: Mon, 12 Feb 2018 13:55:04 +0100 Subject: [PATCH] Add runningProcesses and totalProcesses to CPU-Info. --- index.php | 8 ++++++++ libs/cpu.php | 18 +++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index fbf0c09..fae9439 100644 --- a/index.php +++ b/index.php @@ -174,6 +174,14 @@ Bogomips + + Running Processes + + + + Total Processes + + get('cpu:enable_temperature')): ?> Temperature diff --git a/libs/cpu.php b/libs/cpu.php index 9665c87..b789d38 100644 --- a/libs/cpu.php +++ b/libs/cpu.php @@ -12,6 +12,8 @@ $cache = 'N.A'; $bogomips = 'N.A'; $temp = 'N.A'; +$runningproc= 'N.A'; +$totalproc = 'N.A'; if ($cpuinfo = shell_exec('cat /proc/cpuinfo')) { @@ -78,6 +80,18 @@ } } +//Process running / total +if (!($processestmp=shell_exec('cat /proc/loadavg | awk \'{print $4}\''))) +{ + $processes=0; +} +else +{ + $procsplit=explode("/",$processestmp); + $runningproc=(int)$procsplit[0]; + $totalproc=(int)$procsplit[1]; +} + $datas = array( 'model' => $model, @@ -86,6 +100,8 @@ 'cache' => $cache, 'bogomips' => $bogomips, 'temp' => $temp, + 'runningproc'=> $runningproc, + 'totalproc' => $totalproc, ); -echo json_encode($datas); \ No newline at end of file +echo json_encode($datas);