/** * get the cpu information * * @return array */ protected function _cpuinfo() { if (CommonFunctions::executeProgram('pidin', 'info', $buf) && preg_match('/^Processor\\d+: (.*)/m', $buf)) { $lines = preg_split("/\n/", $buf, -1, PREG_SPLIT_NO_EMPTY); foreach ($lines as $line) { if (preg_match('/^Processor\\d+: (.+)/', $line, $proc)) { $dev = new CpuDevice(); $dev->SetModel(trim($proc[1])); if (preg_match('/(\\d+)MHz/', $proc[1], $mhz)) { $dev->setCpuSpeed($mhz[1]); } $this->sys->setCpus($dev); } } } }
/** * get the cpu information * * @return array */ protected function _cpuinfo() { if (CommonFunctions::rfts('/proc/cpuinfo', $bufr, 0, 4096, false)) { $processors = preg_split('/\\s?\\n\\s?\\n/', trim($bufr)); foreach ($processors as $processor) { $_n = ""; $_f = ""; $_m = ""; $_s = ""; $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 'model name': $_n = $arrBuff[1]; break; case 'cpu mhz': $dev->setCpuSpeed($arrBuff[1]); break; case 'cpu family': $_f = $arrBuff[1]; break; case 'model': $_m = $arrBuff[1]; break; case 'stepping': $_s = $arrBuff[1]; break; case 'flags': if (preg_match("/ vmx/", $arrBuff[1])) { $dev->setVirt("vmx"); } else { if (preg_match("/ svm/", $arrBuff[1])) { $dev->setVirt("svm"); } } break; } } } if ($_n == "") { $_n = "CPU"; } if ($_f != "") { $_n .= " Family " . $_f; } if ($_m != "") { $_n .= " Model " . $_m; } if ($_s != "") { $_n .= " Stepping " . $_s; } $dev->SetModel($_n); $this->sys->setCpus($dev); } } else { foreach ($this->readdmesg() as $line) { if (preg_match('/kernel: (CPU .*) freq (.*) MHz/', $line, $ar_buf)) { $dev = new CpuDevice(); $dev->setModel($ar_buf[1]); $dev->setCpuSpeed($ar_buf[2]); $this->sys->setCpus($dev); } } } }