summaryrefslogtreecommitdiff
path: root/libs/cpu.php
diff options
context:
space:
mode:
authorShevAbam <shevabam@gmail.com>2015-01-16 18:14:07 +0100
committerShevAbam <shevabam@gmail.com>2015-01-16 18:14:07 +0100
commit3ed4c1d633f3ddfc50d921c5d5c19ebf7cf640c4 (patch)
treefe135c5868a41cecfae98294facb61accea76912 /libs/cpu.php
parentc3ec82dd6f60ac8057cc50d9bf6274738db9c02e (diff)
CPU : changes on retrieving CPU information
Load Average and CPU : fix on recovery the number of CPU cores Last login : the datas are retrieved differently
Diffstat (limited to 'libs/cpu.php')
-rw-r--r--libs/cpu.php25
1 files changed, 11 insertions, 14 deletions
diff --git a/libs/cpu.php b/libs/cpu.php
index e2743f9..73a5409 100644
--- a/libs/cpu.php
+++ b/libs/cpu.php
@@ -1,21 +1,17 @@
<?php
+require 'Utils/Misc.class.php';
// Number of cores
-if (!($num_cores = shell_exec('/bin/grep -c ^processor /proc/cpuinfo')))
-{
- $num_cores = 'N.A';
-}
+$num_cores = Misc::getCpuCoresNumber();
// CPU info
-if (!($cpuinfo = shell_exec('cat /proc/cpuinfo')))
-{
- $model = 'N.A';
- $frequency = 'N.A';
- $cache = 'N.A';
- $bogomips = 'N.A';
-}
-else
+$model = 'N.A';
+$frequency = 'N.A';
+$cache = 'N.A';
+$bogomips = 'N.A';
+
+if ($cpuinfo = shell_exec('cat /proc/cpuinfo'))
{
$processors = preg_split('/\s?\n\s?\n/', trim($cpuinfo));
@@ -27,15 +23,16 @@ else
{
list($key, $value) = preg_split('/\s*:\s*/', trim($detail));
- switch ($key)
+ switch (strtolower($key))
{
case 'model name':
case 'cpu model':
case 'cpu':
+ case 'processor':
$model = $value;
break;
- case 'cpu MHz':
+ case 'cpu mhz':
case 'clock':
$frequency = $value.' MHz';
break;