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
This commit is contained in:
ShevAbam
2015-01-16 18:14:07 +01:00
parent c3ec82dd6f
commit 3ed4c1d633
6 changed files with 42 additions and 26 deletions
+11 -14
View File
@@ -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;