コード例 #1
0
 /**
  * CPU information
  *
  * @return void
  */
 private function _cpuinfo()
 {
     $allCpus = CommonFunctions::getWMI($this->_wmi, 'Win32_Processor', array('Name', 'L2CacheSize', 'CurrentClockSpeed', 'ExtClock', 'NumberOfCores', 'MaxClockSpeed'));
     foreach ($allCpus as $oneCpu) {
         $coreCount = 1;
         if (isset($oneCpu['NumberOfCores'])) {
             $coreCount = $oneCpu['NumberOfCores'];
         }
         for ($i = 0; $i < $coreCount; $i++) {
             $cpu = new CpuDevice();
             $cpu->setModel($oneCpu['Name']);
             $cpu->setCache($oneCpu['L2CacheSize'] * 1024);
             $cpu->setCpuSpeed($oneCpu['CurrentClockSpeed']);
             $cpu->setBusSpeed($oneCpu['ExtClock']);
             if ($oneCpu['CurrentClockSpeed'] < $oneCpu['MaxClockSpeed']) {
                 $cpu->setCpuSpeedMax($oneCpu['MaxClockSpeed']);
             }
             $this->sys->setCpus($cpu);
         }
     }
 }
コード例 #2
0
 /**
  * get CPU information
  *
  * @return void
  */
 protected function cpuinfo()
 {
     $dev = new CpuDevice();
     if (CommonFunctions::executeProgram('hostinfo', '| grep "Processor type"', $buf, PSI_DEBUG)) {
         $dev->setModel(preg_replace('/Processor type: /', '', $buf));
         $buf = $this->grabkey('hw.model');
         if (!is_null($buf) && trim($buf) != "") {
             $this->sys->setMachine(trim($buf));
             if (CommonFunctions::rfts(APP_ROOT . '/data/ModelTranslation.txt', $buffer)) {
                 $buffer = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
                 foreach ($buffer as $line) {
                     $ar_buf = preg_split("/:/", $line, 3);
                     if (trim($buf) === trim($ar_buf[0])) {
                         $dev->setModel(trim($ar_buf[2]));
                         $this->sys->setMachine($this->sys->getMachine() . ' - ' . trim($ar_buf[1]));
                         break;
                     }
                 }
             }
         }
         $buf = $this->grabkey('machdep.cpu.brand_string');
         if (!is_null($buf) && trim($buf) != "" && (trim($buf) != "i486 (Intel 80486)" || $dev->getModel() == "")) {
             $dev->setModel(trim($buf));
         }
         $buf = $this->grabkey('machdep.cpu.features');
         if (!is_null($buf) && trim($buf) != "") {
             if (preg_match("/ VMX/", $buf)) {
                 $dev->setVirt("vmx");
             } elseif (preg_match("/ SVM/", $buf)) {
                 $dev->setVirt("svm");
             }
         }
     }
     $dev->setCpuSpeed(round($this->grabkey('hw.cpufrequency') / 1000000));
     $dev->setBusSpeed(round($this->grabkey('hw.busfrequency') / 1000000));
     $bufn = $this->grabkey('hw.cpufrequency_min');
     $bufx = $this->grabkey('hw.cpufrequency_max');
     if (!is_null($bufn) && trim($bufn) != "" && !is_null($bufx) && trim($bufx) != "" && $bufn != $bufx) {
         $dev->setCpuSpeedMin(round($bufn / 1000000));
         $dev->setCpuSpeedMax(round($bufx / 1000000));
     }
     $buf = $this->grabkey('hw.l2cachesize');
     if (!is_null($buf) && trim($buf) != "") {
         $dev->setCache(round($buf));
     }
     $ncpu = $this->grabkey('hw.ncpu');
     if (is_null($ncpu) || trim($ncpu) == "" || !($ncpu >= 1)) {
         $ncpu = 1;
     }
     for ($ncpu; $ncpu > 0; $ncpu--) {
         $this->sys->setCpus($dev);
     }
 }
コード例 #3
0
 /**
  * CPU information
  *
  * @return void
  */
 private function _cpuinfo()
 {
     if (CommonFunctions::executeProgram('kstat', '-p d cpu_info:*:cpu_info*:core_id', $m, PSI_DEBUG) && !is_null($m) && trim($m) !== "") {
         $cpuc = count(preg_split('/\\n/', trim($m), -1, PREG_SPLIT_NO_EMPTY));
         for ($cpu = 0; $cpu < $cpuc; $cpu++) {
             $dev = new CpuDevice();
             if (($buf = $this->_kstat('cpu_info:' . $cpu . ':cpu_info' . $cpu . ':clock_MHz')) !== "") {
                 $dev->setCpuSpeed($buf);
             }
             if (($buf = $this->_kstat('cpu_info:' . $cpu . ':cpu_info' . $cpu . ':current_clock_Hz')) !== "") {
                 $dev->setCpuSpeedMax($buf / 1000000);
             }
             if (($buf = $this->_kstat('cpu_info:' . $cpu . ':cpu_info' . $cpu . ':brand')) !== "") {
                 $dev->setModel($buf);
             } elseif (($buf = $this->_kstat('cpu_info:' . $cpu . ':cpu_info' . $cpu . ':cpu_type')) !== "") {
                 $dev->setModel($buf);
             } elseif (CommonFunctions::executeProgram('uname', '-p', $buf, PSI_DEBUG) && trim($buf) != "") {
                 $dev->setModel(trim($buf));
             } elseif (CommonFunctions::executeProgram('uname', '-i', $buf, PSI_DEBUG) && trim($buf) != "") {
                 $dev->setModel(trim($buf));
             }
             $this->sys->setCpus($dev);
         }
     }
 }
コード例 #4
0
 /**
  * CPU information
  * All of the tags here are highly architecture dependant.
  *
  * @return void
  */
 protected function _cpuinfo()
 {
     if (CommonFunctions::rfts('/proc/cpuinfo', $bufr)) {
         $processors = preg_split('/\\s?\\n\\s?\\n/', trim($bufr));
         $procname = null;
         foreach ($processors as $processor) {
             $proc = null;
             $arch = null;
             $dev = new CpuDevice();
             $details = preg_split("/\n/", $processor, -1, PREG_SPLIT_NO_EMPTY);
             foreach ($details as $detail) {
                 $arrBuff = preg_split('/\\s*:\\s*/', trim($detail));
                 if (count($arrBuff) == 2) {
                     switch (strtolower($arrBuff[0])) {
                         case 'processor':
                             $proc = trim($arrBuff[1]);
                             if (is_numeric($proc)) {
                                 if (strlen($procname) > 0) {
                                     $dev->setModel($procname);
                                 }
                             } else {
                                 $procname = $proc;
                                 $dev->setModel($procname);
                             }
                             break;
                         case 'model name':
                         case 'cpu model':
                         case 'cpu':
                             $dev->setModel($arrBuff[1]);
                             break;
                         case 'cpu mhz':
                         case 'clock':
                             if ($arrBuff[1] > 0) {
                                 //openSUSE fix
                                 $dev->setCpuSpeed($arrBuff[1]);
                             }
                             break;
                         case 'cycle frequency [hz]':
                             $dev->setCpuSpeed($arrBuff[1] / 1000000);
                             break;
                         case 'cpu0clktck':
                             $dev->setCpuSpeed(hexdec($arrBuff[1]) / 1000000);
                             // Linux sparc64
                             break;
                         case 'l2 cache':
                         case 'cache size':
                             $dev->setCache(preg_replace("/[a-zA-Z]/", "", $arrBuff[1]) * 1024);
                             break;
                         case 'initial bogomips':
                         case 'bogomips':
                         case 'cpu0bogo':
                             $dev->setBogomips($arrBuff[1]);
                             break;
                         case 'flags':
                             if (preg_match("/ vmx/", $arrBuff[1])) {
                                 $dev->setVirt("vmx");
                             } elseif (preg_match("/ svm/", $arrBuff[1])) {
                                 $dev->setVirt("svm");
                             } elseif (preg_match("/ hypervisor/", $arrBuff[1])) {
                                 $dev->setVirt("hypervisor");
                             }
                             break;
                         case 'i size':
                         case 'd size':
                             if ($dev->getCache() === null) {
                                 $dev->setCache($arrBuff[1] * 1024);
                             } else {
                                 $dev->setCache($dev->getCache() + $arrBuff[1] * 1024);
                             }
                             break;
                         case 'cpu architecture':
                             $arch = trim($arrBuff[1]);
                             break;
                     }
                 }
             }
             // sparc64 specific code follows
             // This adds the ability to display the cache that a CPU has
             // Originally made by Sven Blumenstein <*****@*****.**> in 2004
             // Modified by Tom Weustink <*****@*****.**> in 2004
             $sparclist = array('SUNW,UltraSPARC@0,0', 'SUNW,UltraSPARC-II@0,0', 'SUNW,UltraSPARC@1c,0', 'SUNW,UltraSPARC-IIi@1c,0', 'SUNW,UltraSPARC-II@1c,0', 'SUNW,UltraSPARC-IIe@0,0');
             foreach ($sparclist as $name) {
                 if (CommonFunctions::rfts('/proc/openprom/' . $name . '/ecache-size', $buf, 1, 32, false)) {
                     $dev->setCache(base_convert($buf, 16, 10));
                 }
             }
             // sparc64 specific code ends
             // XScale detection code
             if ($arch === "5TE" && $dev->getBogomips() != null) {
                 $dev->setCpuSpeed($dev->getBogomips());
                 //BogoMIPS are not BogoMIPS on this CPU, it's the speed
                 $dev->setBogomips(null);
                 // no BogoMIPS available, unset previously set BogoMIPS
             }
             if ($proc != null) {
                 if (!is_numeric($proc)) {
                     $proc = 0;
                 }
                 // variable speed processors specific code follows
                 if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu' . $proc . '/cpufreq/cpuinfo_cur_freq', $buf, 1, 4096, false)) {
                     $dev->setCpuSpeed($buf / 1000);
                 } elseif (CommonFunctions::rfts('/sys/devices/system/cpu/cpu' . $proc . '/cpufreq/scaling_cur_freq', $buf, 1, 4096, false)) {
                     $dev->setCpuSpeed($buf / 1000);
                 }
                 if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu' . $proc . '/cpufreq/cpuinfo_max_freq', $buf, 1, 4096, false)) {
                     $dev->setCpuSpeedMax($buf / 1000);
                 }
                 if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu' . $proc . '/cpufreq/cpuinfo_min_freq', $buf, 1, 4096, false)) {
                     $dev->setCpuSpeedMin($buf / 1000);
                 }
                 // variable speed processors specific code ends
                 if (PSI_LOAD_BAR) {
                     $dev->setLoad($this->_parseProcStat('cpu' . $proc));
                 }
                 if (CommonFunctions::rfts('/proc/acpi/thermal_zone/THRM/temperature', $buf, 1, 4096, false)) {
                     $dev->setTemp(substr($buf, 25, 2));
                 }
                 if ($dev->getModel() === "") {
                     $dev->setModel("unknown");
                 }
                 $this->sys->setCpus($dev);
             }
         }
     }
 }
コード例 #5
0
 /**
  * CPU information
  * All of the tags here are highly architecture dependant.
  *
  * @return void
  */
 protected function _cpuinfo()
 {
     if (CommonFunctions::rfts('/proc/cpuinfo', $bufr)) {
         $processors = preg_split('/\\s?\\n\\s?\\n/', trim($bufr));
         //first stage
         $_arch = null;
         $_impl = null;
         $_part = null;
         $_hard = null;
         $_revi = null;
         $_cpus = null;
         $_buss = null;
         foreach ($processors as $processor) {
             if (!preg_match('/^\\s*processor\\s*:/mi', $processor)) {
                 $details = preg_split("/\n/", $processor, -1, PREG_SPLIT_NO_EMPTY);
                 foreach ($details as $detail) {
                     $arrBuff = preg_split('/\\s*:\\s*/', trim($detail));
                     if (count($arrBuff) == 2 && ($arrBuff1 = trim($arrBuff[1])) !== '') {
                         switch (strtolower($arrBuff[0])) {
                             case 'cpu architecture':
                                 $_arch = $arrBuff1;
                                 break;
                             case 'cpu implementer':
                                 $_impl = $arrBuff1;
                                 break;
                             case 'cpu part':
                                 $_part = $arrBuff1;
                                 break;
                             case 'hardware':
                                 $_hard = $arrBuff1;
                                 break;
                             case 'revision':
                                 $_revi = $arrBuff1;
                                 break;
                             case 'cpu frequency':
                                 if (preg_match('/^(\\d+)\\s+Hz/i', $arrBuff1, $bufr2)) {
                                     $_cpus = round($bufr2[1] / 1000000);
                                 }
                                 break;
                             case 'system bus frequency':
                                 if (preg_match('/^(\\d+)\\s+Hz/i', $arrBuff1, $bufr2)) {
                                     $_buss = round($bufr2[1] / 1000000);
                                 }
                                 break;
                         }
                     }
                 }
             }
         }
         //second stage
         $procname = null;
         foreach ($processors as $processor) {
             if (preg_match('/^\\s*processor\\s*:/mi', $processor)) {
                 $proc = null;
                 $arch = null;
                 $impl = null;
                 $part = null;
                 $dev = new CpuDevice();
                 $details = preg_split("/\n/", $processor, -1, PREG_SPLIT_NO_EMPTY);
                 foreach ($details as $detail) {
                     $arrBuff = preg_split('/\\s*:\\s*/', trim($detail));
                     if (count($arrBuff) == 2 && ($arrBuff1 = trim($arrBuff[1])) !== '') {
                         switch (strtolower($arrBuff[0])) {
                             case 'processor':
                                 $proc = $arrBuff1;
                                 if (is_numeric($proc)) {
                                     if (strlen($procname) > 0) {
                                         $dev->setModel($procname);
                                     }
                                 } else {
                                     $procname = $proc;
                                     $dev->setModel($procname);
                                 }
                                 break;
                             case 'model name':
                             case 'cpu model':
                             case 'cpu type':
                             case 'cpu':
                                 $dev->setModel($arrBuff1);
                                 break;
                             case 'cpu mhz':
                             case 'clock':
                                 if ($arrBuff1 > 0) {
                                     //openSUSE fix
                                     $dev->setCpuSpeed($arrBuff1);
                                 }
                                 break;
                             case 'cycle frequency [hz]':
                                 $dev->setCpuSpeed($arrBuff1 / 1000000);
                                 break;
                             case 'cpu0clktck':
                                 $dev->setCpuSpeed(hexdec($arrBuff1) / 1000000);
                                 // Linux sparc64
                                 break;
                             case 'l2 cache':
                             case 'cache size':
                                 $dev->setCache(preg_replace("/[a-zA-Z]/", "", $arrBuff1) * 1024);
                                 break;
                             case 'initial bogomips':
                             case 'bogomips':
                             case 'cpu0bogo':
                                 $dev->setBogomips(round($arrBuff1));
                                 break;
                             case 'flags':
                                 if (preg_match("/ vmx/", $arrBuff1)) {
                                     $dev->setVirt("vmx");
                                 } elseif (preg_match("/ svm/", $arrBuff1)) {
                                     $dev->setVirt("svm");
                                 } elseif (preg_match("/ hypervisor/", $arrBuff1)) {
                                     $dev->setVirt("hypervisor");
                                 }
                                 break;
                             case 'i size':
                             case 'd size':
                                 if ($dev->getCache() === null) {
                                     $dev->setCache($arrBuff1 * 1024);
                                 } else {
                                     $dev->setCache($dev->getCache() + $arrBuff1 * 1024);
                                 }
                                 break;
                             case 'cpu architecture':
                                 $arch = $arrBuff1;
                                 break;
                             case 'cpu implementer':
                                 $impl = $arrBuff1;
                                 break;
                             case 'cpu part':
                                 $part = $arrBuff1;
                                 break;
                         }
                     }
                 }
                 if ($arch === null) {
                     $arch = $_arch;
                 }
                 if ($impl === null) {
                     $impl = $_impl;
                 }
                 if ($part === null) {
                     $part = $_part;
                 }
                 // sparc64 specific code follows
                 // This adds the ability to display the cache that a CPU has
                 // Originally made by Sven Blumenstein <*****@*****.**> in 2004
                 // Modified by Tom Weustink <*****@*****.**> in 2004
                 $sparclist = array('SUNW,UltraSPARC@0,0', 'SUNW,UltraSPARC-II@0,0', 'SUNW,UltraSPARC@1c,0', 'SUNW,UltraSPARC-IIi@1c,0', 'SUNW,UltraSPARC-II@1c,0', 'SUNW,UltraSPARC-IIe@0,0');
                 foreach ($sparclist as $name) {
                     if (CommonFunctions::rfts('/proc/openprom/' . $name . '/ecache-size', $buf, 1, 32, false)) {
                         $dev->setCache(base_convert($buf, 16, 10));
                     }
                 }
                 // sparc64 specific code ends
                 // XScale detection code
                 if ($arch === "5TE" && $dev->getBogomips() != null) {
                     $dev->setCpuSpeed($dev->getBogomips());
                     //BogoMIPS are not BogoMIPS on this CPU, it's the speed
                     $dev->setBogomips(null);
                     // no BogoMIPS available, unset previously set BogoMIPS
                 }
                 if ($dev->getBusSpeed() == 0 && $_buss !== null) {
                     $dev->setBusSpeed($_buss);
                 }
                 if ($dev->getCpuSpeed() == 0 && $_cpus !== null) {
                     $dev->setCpuSpeed($_cpus);
                 }
                 if ($proc != null) {
                     if (!is_numeric($proc)) {
                         $proc = 0;
                     }
                     // variable speed processors specific code follows
                     if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu' . $proc . '/cpufreq/cpuinfo_cur_freq', $buf, 1, 4096, false)) {
                         $dev->setCpuSpeed($buf / 1000);
                     } elseif (CommonFunctions::rfts('/sys/devices/system/cpu/cpu' . $proc . '/cpufreq/scaling_cur_freq', $buf, 1, 4096, false)) {
                         $dev->setCpuSpeed($buf / 1000);
                     }
                     if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu' . $proc . '/cpufreq/cpuinfo_max_freq', $buf, 1, 4096, false)) {
                         $dev->setCpuSpeedMax($buf / 1000);
                     }
                     if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu' . $proc . '/cpufreq/cpuinfo_min_freq', $buf, 1, 4096, false)) {
                         $dev->setCpuSpeedMin($buf / 1000);
                     }
                     // variable speed processors specific code ends
                     if (PSI_LOAD_BAR) {
                         $dev->setLoad($this->_parseProcStat('cpu' . $proc));
                     }
                     if (CommonFunctions::rfts('/proc/acpi/thermal_zone/THRM/temperature', $buf, 1, 4096, false)) {
                         $dev->setTemp(substr($buf, 25, 2));
                     }
                     // Raspbery detection
                     if ($arch === '7' && $impl === '0x41' && ($_hard === 'BCM2708' || $_hard === 'BCM2709' || $_hard === 'BCM2710') && $_revi !== null) {
                         if (($cputype = $this->setRaspberry($_revi, $part)) !== "") {
                             if (($cpumodel = $dev->getModel()) !== "") {
                                 $dev->setModel($cpumodel . ' - ' . $cputype);
                             } else {
                                 $dev->setModel($cputype);
                             }
                         }
                     } else {
                         // other hardware
                         if ($_hard !== null && $this->sys->getMachine() === "") {
                             $this->sys->setMachine($_hard);
                         }
                     }
                     if ($dev->getModel() === "") {
                         $dev->setModel("unknown");
                     }
                     $this->sys->setCpus($dev);
                 }
             }
         }
     }
 }