ArchivedTools/PHP_Scripts/check number of cpu/num_processors.php

21 lines
366 B
PHP
Raw Permalink Normal View History

2023-12-21 00:31:35 +00:00
<?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)));
}
?>