ArchivedTools/PHP_Scripts/check number of cpu/num_processors.php
2023-12-21 01:31:35 +01:00

21 lines
366 B
PHP

<?php
$cmd = "uname";
$OS = strtolower(trim(shell_exec($cmd)));
switch($OS){
case('linux'):
$cmd = "cat /proc/cpuinfo | grep processor | wc -l";
break;
case('freebsd'):
$cmd = "sysctl -a | grep 'hw.ncpu' | cut -d ':' -f2";
break;
default:
unset($cmd);
}
if ($cmd != ''){
$cpuCoreNo = intval(trim(shell_exec($cmd)));
}
?>