parent
c28dcab2ca
commit
ad9087316a
|
|
@ -27,18 +27,22 @@
|
|||
$row_style["1"] = "row_style1";
|
||||
|
||||
//get the CPU details
|
||||
if (PHP_OS == 'FreeBSD' || PHP_OS == 'Linux') {
|
||||
if (stristr(PHP_OS, 'BSD') || stristr(PHP_OS, 'Linux')) {
|
||||
|
||||
$result = shell_exec('ps -A -o pcpu');
|
||||
$percent_cpu = 0;
|
||||
foreach (explode("\n", $result) as $value) {
|
||||
if (is_numeric($value)) { $percent_cpu = $percent_cpu + $value; }
|
||||
}
|
||||
if (stristr(PHP_OS, 'BSD')) {
|
||||
$result = trim(shell_exec("dmesg | grep -i --max-count 1 CPUs | sed 's/[^0-9]*//g'"));
|
||||
$cpu_cores = trim($result);
|
||||
}
|
||||
if (stristr(PHP_OS, 'Linux')) {
|
||||
$result = trim(shell_exec("grep -P '^processor' /proc/cpuinfo"));
|
||||
$cpu_cores = count(explode("\n", $result));
|
||||
}
|
||||
if ($percent_cpu > 1) { $percent_cpu = $percent_cpu / $cpu_cores; }
|
||||
if ($cpu_cores > 1) { $percent_cpu = $percent_cpu / $cpu_cores; }
|
||||
$percent_cpu = round($percent_cpu, 2);
|
||||
|
||||
//uptime
|
||||
|
|
|
|||
Loading…
Reference in New Issue