本文整理汇总了PHP中CpuDevice类的典型用法代码示例。如果您正苦于以下问题:PHP CpuDevice类的具体用法?PHP CpuDevice怎么用?PHP CpuDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CpuDevice类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _cpuinfo
/**
* 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);
}
}
}
}
开发者ID:kampee,项目名称:phpsysinfo,代码行数:21,代码来源:class.QNX.inc.php
示例2: _cpuinfo
/**
* CPU information
* All of the tags here are highly architecture dependant.
*
* @return void
*/
private function _cpuinfo()
{
if (CommonFunctions::rfts('/proc/cpuinfo', $bufr)) {
$processors = preg_split('/\\s?\\n\\s?\\n/', trim($bufr));
foreach ($processors as $processor) {
$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':
if (PSI_LOAD_BAR) {
$dev->setLoad($this->_parseProcStat('cpu' . trim($arrBuff[1])));
}
break;
case 'model name':
case 'cpu':
$dev->setModel($arrBuff[1]);
break;
case 'cpu mhz':
case 'clock':
$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 'bogomips':
case 'cpu0bogo':
$dev->setBogomips($arrBuff[1]);
break;
case 'flags':
if (preg_match("/vmx/", $arrBuff[1])) {
$dev->setVirt("vmx");
} else {
if (preg_match("/smv/", $arrBuff[1])) {
$dev->setVirt("smv");
}
}
break;
}
}
}
// sparc64 specific code follows
// This adds the ability to display the cache that a CPU has
// Originally made by Sven Blumenstein <[email protected]> in 2004
// Modified by Tom Weustink <[email protected]> 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 ($dev->getModel() === "") {
foreach ($details as $detail) {
$arrBuff = preg_split('/\\s+:\\s+/', trim($detail));
if (count($arrBuff) == 2) {
switch (strtolower($arrBuff[0])) {
case 'processor':
$dev->setModel($arrBuff[1]);
break;
case 'bogomips':
$dev->setCpuSpeed($arrBuff[1]);
//BogoMIPS are not BogoMIPS on this CPU, it's the speed
$dev->setBogomips(null);
// no BogoMIPS available, unset previously set BogoMIPS
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;
}
}
}
}
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");
//.........这里部分代码省略.........
开发者ID:sorrowchen,项目名称:openfiler-cn,代码行数:101,代码来源:class.Linux.inc.php
示例3: cpuinfo
/**
* 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 (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, 2);
if (trim($buf) === trim($ar_buf[0])) {
$dev->setModel(trim($ar_buf[1]));
}
}
}
}
$dev->setCpuSpeed(round($this->grabkey('hw.cpufrequency') / 1000000));
$dev->setBusSpeed(round($this->grabkey('hw.busfrequency') / 1000000));
$dev->setCache(round($this->grabkey('hw.l2cachesize')));
for ($i = $this->grabkey('hw.ncpu'); $i > 0; $i--) {
$this->sys->setCpus($dev);
}
}
开发者ID:alexborisov,项目名称:foxfire,代码行数:28,代码来源:class.Darwin.inc.php
示例4: _cpuinfo
/**
* 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);
}
}
}
}
开发者ID:sorrowchen,项目名称:openfiler-cn,代码行数:73,代码来源:class.Minix.inc.php
示例5: _cpuinfo
/**
* CPU information
* All of the tags here are highly architecture dependant
*
* @return void
*/
private function _cpuinfo()
{
if (CommonFunctions::rfts('/proc/cpuinfo', $bufr)) {
$processors = preg_split('/\\s?\\n\\s?\\n/', trim($bufr));
foreach ($processors as $processor) {
$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':
case 'cpu':
$dev->setModel($arrBuff[1]);
break;
case 'cpu mhz':
case 'clock':
$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 'bogomips':
case 'cpu0bogo':
$dev->setBogomips($arrBuff[1]);
break;
}
}
}
}
}
}
开发者ID:antirek,项目名称:prestige-pbx,代码行数:46,代码来源:class.HPUX.inc.php
示例6: _cpuinfo
/**
* 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 <[email protected]> in 2004
// Modified by Tom Weustink <[email protected]> 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)) {
//.........这里部分代码省略.........
开发者ID:rhertzog,项目名称:lcs,代码行数:101,代码来源:class.Linux.inc.php
示例7: cpuinfo
/**
* get CPU information
*
* @return void
*/
protected function cpuinfo()
{
$dev = new CpuDevice();
$dev->setModel($this->grabkey('hw.model'));
$dev->setCpuSpeed($this->grabkey('hw.cpuspeed'));
$ncpu = $this->grabkey('hw.ncpu');
if (is_null($ncpu) || trim($ncpu) == "" || !($ncpu >= 1)) {
$ncpu = 1;
}
for ($ncpu; $ncpu > 0; $ncpu--) {
$this->sys->setCpus($dev);
}
}
开发者ID:sorrowchen,项目名称:openfiler-cn,代码行数:18,代码来源:class.OpenBSD.inc.php
示例8: _cpuinfo
/**
* CPU information
*
* @return void
*/
private function _cpuinfo()
{
$dev = new CpuDevice();
if (CommonFunctions::executeProgram('uname', '-i', $buf, PSI_DEBUG)) {
$dev->setModel(trim($buf));
}
$dev->setCpuSpeed($this->_kstat('cpu_info:0:cpu_info0:clock_MHz'));
$dev->setCache($this->_kstat('cpu_info:0:cpu_info0:cpu_type') * 1024);
$this->sys->setCpus($dev);
}
开发者ID:antirek,项目名称:prestige-pbx,代码行数:15,代码来源:class.SunOS.inc.php
示例9: cpuinfo
/**
* get CPU information
*
* @return void
*/
protected function cpuinfo()
{
$dev = new CpuDevice();
$dev->setModel($this->grabkey('hw.model'));
$dev->setCpuSpeed($this->grabkey('hw.cpuspeed'));
$this->sys->setCpus($dev);
}
开发者ID:bogus,项目名称:findik-web-amf,代码行数:12,代码来源:class.OpenBSD.inc.php
示例10: cpuinfo
/**
* CPU information
*
* @return void
*/
protected function cpuinfo()
{
$dev = new CpuDevice();
$dev->setModel($this->grabkey('hw.model'));
$notwas = true;
foreach ($this->readdmesg() as $line) {
if ($notwas) {
if (preg_match("/" . $this->_CPURegExp1 . "/", $line, $ar_buf)) {
$dev->setCpuSpeed(round($ar_buf[2]));
$notwas = false;
}
} else {
if (preg_match("/ Origin| Features/", $line, $ar_buf)) {
if (preg_match("/ Features2[ ]*=.*<(.*)>/", $line, $ar_buf)) {
$feats = preg_split("/,/", strtolower(trim($ar_buf[1])), -1, PREG_SPLIT_NO_EMPTY);
foreach ($feats as $feat) {
if ($feat == "vmx" || $feat == "svm") {
$dev->setVirt($feat);
break 2;
}
}
break;
}
} else {
break;
}
}
}
$ncpu = $this->grabkey('hw.ncpu');
if (is_null($ncpu) || trim($ncpu) == "" || !($ncpu >= 1)) {
$ncpu = 1;
}
for ($ncpu; $ncpu > 0; $ncpu--) {
$this->sys->setCpus($dev);
}
}
开发者ID:rzs840707,项目名称:webapps_repository,代码行数:41,代码来源:class.BSDCommon.inc.php
示例11: _cpuinfo
/**
* CPU information
* All of the tags here are highly architecture dependant
* @return void
*/
private function _cpuinfo()
{
$ncpu = 0;
$tcpu = "";
$vcpu = "";
$ccpu = "";
$scpu = "";
foreach ($this->readaixdata() as $line) {
if (preg_match("/^Number Of Processors:\\s+(\\d+)/", $line, $ar_buf)) {
$ncpu = $ar_buf[1];
}
if (preg_match("/^Processor Type:\\s+(.+)/", $line, $ar_buf)) {
$tcpu = $ar_buf[1];
}
if (preg_match("/^Processor Version:\\s+(.+)/", $line, $ar_buf)) {
$vcpu = $ar_buf[1];
}
if (preg_match("/^CPU Type:\\s+(.+)/", $line, $ar_buf)) {
$ccpu = $ar_buf[1];
}
if (preg_match("/^Processor Clock Speed:\\s+(\\d+)\\s/", $line, $ar_buf)) {
$scpu = $ar_buf[1];
}
}
for ($i = 0; $i < $ncpu; $i++) {
$dev = new CpuDevice();
if (trim($tcpu) != "") {
$cpu = trim($tcpu);
if (trim($vcpu) != "") {
$cpu .= " " . trim($vcpu);
}
if (trim($ccpu) != "") {
$cpu .= " " . trim($ccpu);
}
$dev->setModel($cpu);
}
if (trim($scpu) != "") {
$dev->setCpuSpeed(trim($scpu));
}
$this->sys->setCpus($dev);
}
}
开发者ID:phucps89,项目名称:Tour,代码行数:47,代码来源:class.AIX.inc.php
示例12: _cpuinfo
/**
* 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);
}
}
}
开发者ID:pdeleonardis,项目名称:phpsysinfo,代码行数:30,代码来源:class.SunOS.inc.php
示例13: _cpuinfo
/**
* CPU information
* All of the tags here are highly architecture dependant
* @return void
*/
private function _cpuinfo()
{
$dev = new CpuDevice();
CommonFunctions::executeProgram('cat', '/tmp/webprtconf.txt |grep Type', $cpudev);
$dev->setModel($cpudev);
CommonFunctions::executeProgram('cat', '/tmp/webprtconf.txt | grep Speed | awk \'{print $4}\'', $cpuspeed);
$dev->setCpuSpeed($cpuspeed);
//$dev->setCache('512000'); //-don't know howto guess cache size
$this->sys->setCpus($dev);
}
开发者ID:sorrowchen,项目名称:openfiler-cn,代码行数:15,代码来源:class.AIX.inc.php
示例14: cpuinfo
/**
* CPU information
*
* @return void
*/
protected function cpuinfo()
{
$dev = new CpuDevice();
$dev->setModel($this->grabkey('hw.model'));
foreach ($this->readdmesg() as $line) {
if (preg_match("/" . $this->_CPURegExp1 . "/", $line, $ar_buf)) {
$dev->setCpuSpeed(round($ar_buf[2]));
break;
}
}
$this->sys->setCpus($dev);
}
开发者ID:jhbsz,项目名称:ossimTest,代码行数:17,代码来源:class.BSDCommon.inc.php
示例15: cpuinfo
/**
* get CPU information
*
* @return void
*/
protected function cpuinfo()
{
$dev = new CpuDevice();
$dev->setModel($this->grabkey('hw.model'));
$dev->setCpuSpeed($this->grabkey('hw.cpuspeed'));
$was = false;
foreach ($this->readdmesg() as $line) {
if (preg_match("/^cpu[0-9]+: (.*)/", $line, $ar_buf)) {
$was = true;
if (preg_match("/^cpu[0-9]+: (\\d+)([KM])B (.*) L2 cache/", $line, $ar_buf2)) {
if ($ar_buf2[2] == "M") {
$dev->setCache($ar_buf2[1] * 1024 * 1024);
} elseif ($ar_buf2[2] == "K") {
$dev->setCache($ar_buf2[1] * 1024);
}
} else {
$feats = preg_split("/,/", strtolower(trim($ar_buf[1])), -1, PREG_SPLIT_NO_EMPTY);
foreach ($feats as $feat) {
if ($feat == "vmx" || $feat == "svm") {
$dev->setVirt($feat);
}
}
}
} elseif ($was) {
break;
}
}
$ncpu = $this->grabkey('hw.ncpu');
if (is_null($ncpu) || trim($ncpu) == "" || !($ncpu >= 1)) {
$ncpu = 1;
}
for ($ncpu; $ncpu > 0; $ncpu--) {
$this->sys->setCpus($dev);
}
}
开发者ID:zseand,项目名称:phpsysinfo,代码行数:40,代码来源:class.OpenBSD.inc.php
示例16: cpuinfo
/**
* 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);
}
}
开发者ID:bbspike,项目名称:sentora-core,代码行数:58,代码来源:class.Darwin.inc.php
示例17: _cpuinfo
/**
* get the cpu information
*
* @return array
*/
protected function _cpuinfo()
{
if (CommonFunctions::executeProgram('sysinfo', '-cpu', $bufr, PSI_DEBUG)) {
$cpus = preg_split("/\nCPU #\\d+/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
$cpuspeed = "";
foreach ($cpus as $cpu) {
if (preg_match("/^.*running at (\\d+)MHz/", $cpu, $ar_buf)) {
$cpuspeed = $ar_buf[1];
} elseif (preg_match("/^: \"(.*)\"/", $cpu, $ar_buf)) {
$dev = new CpuDevice();
$dev->setModel($ar_buf[1]);
$arrLines = preg_split("/\n/", $cpu, -1, PREG_SPLIT_NO_EMPTY);
foreach ($arrLines as $Line) {
if (preg_match("/^\\s+Data TLB:\\s+(.*)K-byte/", $Line, $Line_buf)) {
$dev->setCache(max($Line_buf[1] * 1024, $dev->getCache()));
} elseif (preg_match("/^\\s+Data TLB:\\s+(.*)M-byte/", $Line, $Line_buf)) {
$dev->setCache(max($Line_buf[1] * 1024 * 1024, $dev->getCache()));
} elseif (preg_match("/^\\s+Data TLB:\\s+(.*)G-byte/", $Line, $Line_buf)) {
$dev->setCache(max($Line_buf[1] * 1024 * 1024 * 1024, $dev->getCache()));
} elseif (preg_match("/\\s+VMX/", $Line, $Line_buf)) {
$dev->setVirt("vmx");
} elseif (preg_match("/\\s+SVM/", $Line, $Line_buf)) {
$dev->setVirt("svm");
}
}
if ($cpuspeed != "") {
$dev->setCpuSpeed($cpuspeed);
}
$this->sys->setCpus($dev);
//echo ">>>>>".$cpu;
}
}
}
}
开发者ID:sorrowchen,项目名称:openfiler-cn,代码行数:39,代码来源:class.Haiku.inc.php
示例18: _cpuinfo
/**
* 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);
}
}
}
开发者ID:caglaroflazoglu,项目名称:sentora-core,代码行数:26,代码来源:class.WINNT.inc.php
示例19: _cpuinfo
/**
* 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;
//.........这里部分代码省略.........
开发者ID:phpsysinfo,项目名称:phpsysinfo,代码行数:101,代码来源:class.Linux.inc.php
注:本文中的CpuDevice类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论