2014-06-18 04:11:11 -04:00
|
|
|
<?php
|
2015-07-07 09:57:41 -04:00
|
|
|
require '../autoload.php';
|
|
|
|
$Config = new Config();
|
2014-06-18 04:11:11 -04:00
|
|
|
|
|
|
|
// Number of cores
|
2015-01-16 12:14:07 -05:00
|
|
|
$num_cores = Misc::getCpuCoresNumber();
|
2014-06-18 04:11:11 -04:00
|
|
|
|
|
|
|
|
|
|
|
// CPU info
|
2015-01-16 12:14:07 -05:00
|
|
|
$model = 'N.A';
|
|
|
|
$frequency = 'N.A';
|
|
|
|
$cache = 'N.A';
|
|
|
|
$bogomips = 'N.A';
|
2015-07-07 09:57:41 -04:00
|
|
|
$temp = 'N.A';
|
2015-01-16 12:14:07 -05:00
|
|
|
|
|
|
|
if ($cpuinfo = shell_exec('cat /proc/cpuinfo'))
|
2014-06-18 04:11:11 -04:00
|
|
|
{
|
|
|
|
$processors = preg_split('/\s?\n\s?\n/', trim($cpuinfo));
|
|
|
|
|
|
|
|
foreach ($processors as $processor)
|
|
|
|
{
|
|
|
|
$details = preg_split('/\n/', $processor, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
|
|
|
|
|
foreach ($details as $detail)
|
|
|
|
{
|
|
|
|
list($key, $value) = preg_split('/\s*:\s*/', trim($detail));
|
|
|
|
|
2015-01-16 12:14:07 -05:00
|
|
|
switch (strtolower($key))
|
2014-06-18 04:11:11 -04:00
|
|
|
{
|
|
|
|
case 'model name':
|
|
|
|
case 'cpu model':
|
|
|
|
case 'cpu':
|
2015-01-16 12:14:07 -05:00
|
|
|
case 'processor':
|
2014-06-18 04:11:11 -04:00
|
|
|
$model = $value;
|
|
|
|
break;
|
|
|
|
|
2015-01-16 12:14:07 -05:00
|
|
|
case 'cpu mhz':
|
2014-06-18 04:11:11 -04:00
|
|
|
case 'clock':
|
|
|
|
$frequency = $value.' MHz';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'cache size':
|
|
|
|
case 'l2 cache':
|
|
|
|
$cache = $value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'bogomips':
|
|
|
|
$bogomips = $value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-07 09:57:41 -04:00
|
|
|
if ($frequency == 'N.A')
|
|
|
|
{
|
|
|
|
if ($f = shell_exec('cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq'))
|
|
|
|
{
|
|
|
|
$f = $f / 1000;
|
|
|
|
$frequency = $f.' MHz';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// CPU Temp
|
|
|
|
if ($Config->get('cpu:enable_temperature'))
|
|
|
|
{
|
2017-03-20 12:35:14 -04:00
|
|
|
if (file_exists('/usr/bin/sensors') && exec('/usr/bin/sensors | grep -E "^(CPU Temp|Core 0)" | cut -d \'+\' -f2 | cut -d \'.\' -f1', $t))
|
2015-07-07 09:57:41 -04:00
|
|
|
{
|
|
|
|
if (isset($t[0]))
|
|
|
|
$temp = $t[0].' °C';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (exec('cat /sys/class/thermal/thermal_zone0/temp', $t))
|
|
|
|
{
|
|
|
|
$temp = round($t[0] / 1000).' °C';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-18 04:11:11 -04:00
|
|
|
|
|
|
|
$datas = array(
|
|
|
|
'model' => $model,
|
|
|
|
'num_cores' => $num_cores,
|
|
|
|
'frequency' => $frequency,
|
|
|
|
'cache' => $cache,
|
|
|
|
'bogomips' => $bogomips,
|
2015-07-07 09:57:41 -04:00
|
|
|
'temp' => $temp,
|
2014-06-18 04:11:11 -04:00
|
|
|
);
|
|
|
|
|
2017-03-20 12:35:14 -04:00
|
|
|
echo json_encode($datas);
|