本文整理汇总了PHP中HWDevice类的典型用法代码示例。如果您正苦于以下问题:PHP HWDevice类的具体用法?PHP HWDevice怎么用?PHP HWDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HWDevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pciconf
/**
* parsing the output of pciconf command
*
* @return Array
*/
public static function pciconf()
{
$arrResults = array();
$intS = 0;
if (CommonFunctions::executeProgram("pciconf", "-lv", $strBuf, PSI_DEBUG)) {
$arrTemp = array();
$arrLines = preg_split("/\n/", $strBuf, -1, PREG_SPLIT_NO_EMPTY);
foreach ($arrLines as $strLine) {
if (preg_match("/(.*) = '(.*)'/", $strLine, $arrParts)) {
if (trim($arrParts[1]) == "vendor") {
$arrTemp[$intS] = trim($arrParts[2]);
} elseif (trim($arrParts[1]) == "device") {
$arrTemp[$intS] .= " - " . trim($arrParts[2]);
$intS++;
}
}
}
foreach ($arrTemp as $name) {
$dev = new HWDevice();
$dev->setName($name);
$arrResults[] = $dev;
}
}
return $arrResults;
}
示例2: equals
/**
* compare a given device with the internal one
*
* @param HWDevice $dev device that should be compared
*
* @return boolean
*/
public function equals($dev)
{
if ($dev->getName() === $this->_name && $dev->getCapacity() === $this->_capacity) {
return true;
} else {
return false;
}
}
示例3: lspci
/**
* parsing the output of lspci command
*
* @return Array
*/
public static function lspci($debug = PSI_DEBUG)
{
$arrResults = array();
if (CommonFunctions::executeProgram("lspci", "", $strBuf, $debug)) {
$arrLines = preg_split("/\n/", $strBuf, -1, PREG_SPLIT_NO_EMPTY);
foreach ($arrLines as $strLine) {
$arrParams = preg_split('/ /', trim($strLine), 2);
if (count($arrParams) == 2) {
$strName = $arrParams[1];
} else {
$strName = "unknown";
}
$strName = preg_replace('/\\(.*\\)/', '', $strName);
$dev = new HWDevice();
$dev->setName($strName);
$arrResults[] = $dev;
}
}
return $arrResults;
}
示例4: _usb
/**
* USB devices
*
* @return array
*/
private function _usb()
{
$devnum = -1;
if (!CommonFunctions::executeProgram('lsusb', '', $bufr, PSI_DEBUG)) {
if (CommonFunctions::rfts('/proc/bus/usb/devices', $bufr, 0, 4096, false)) {
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
foreach ($bufe as $buf) {
if (preg_match('/^T/', $buf)) {
$devnum += 1;
$results[$devnum] = "";
} elseif (preg_match('/^S:/', $buf)) {
list($key, $value) = preg_split('/: /', $buf, 2);
list($key, $value2) = preg_split('/=/', $value, 2);
if (trim($key) != "SerialNumber") {
$results[$devnum] .= " " . trim($value2);
}
}
}
foreach ($results as $var) {
$dev = new HWDevice();
$dev->setName($var);
$this->sys->setUsbDevices($dev);
}
}
} else {
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
foreach ($bufe as $buf) {
$device = preg_split("/ /", $buf, 7);
if (isset($device[6]) && trim($device[6]) != "") {
$dev = new HWDevice();
$dev->setName(trim($device[6]));
$this->sys->setUsbDevices($dev);
}
}
}
}
示例5: ide
/**
* get the ide device information out of ioreg
*
* @return void
*/
protected function ide()
{
$s = $this->_grabioreg('IOATABlockStorageDevice');
$lines = preg_split("/\n/", $s, -1, PREG_SPLIT_NO_EMPTY);
foreach ($lines as $line) {
$ar_buf = preg_split("/\\/\\//", $line, 19);
if (isset($ar_buf[1]) && $ar_buf[1] == 'class IOMedia' && preg_match('/Media/', $ar_buf[0])) {
$dev = new HWDevice();
$dev->setName($ar_buf[0]);
$this->sys->setIdeDevices($dev);
}
}
}
示例6: _pci
/**
* PCI devices
* get the pci device information out of dmesg
*
* @return void
*/
protected function _pci()
{
if (CommonFunctions::rfts('/proc/pci', $strBuf, 0, 4096, false)) {
$arrLines = preg_split("/\n/", $strBuf, -1, PREG_SPLIT_NO_EMPTY);
foreach ($arrLines as $strLine) {
$arrParams = preg_split('/\\s+/', trim($strLine), 4);
if (count($arrParams) == 4) {
$strName = $arrParams[3];
} else {
$strName = "unknown";
}
$strName = preg_replace('/\\(.*\\)/', '', $strName);
$dev = new HWDevice();
$dev->setName($strName);
$arrResults[] = $dev;
}
foreach ($arrResults as $dev) {
$this->sys->setPciDevices($dev);
}
}
if (!is_array($arrResults) && is_array($results = Parser::lspci())) {
/* if access error: chmod 4755 /usr/bin/lspci */
foreach ($results as $dev) {
$this->sys->setPciDevices($dev);
}
}
}
示例7: _buildHardware
/**
* generate the hardware information
*
* @return void
*/
private function _buildHardware()
{
$dev = new HWDevice();
$hardware = $this->_xml->addChild('Hardware');
$pci = $hardware->addChild('PCI');
foreach (System::removeDupsAndCount($this->_sys->getPciDevices()) as $dev) {
$tmp = $pci->addChild('Device');
$tmp->addAttribute('Name', $dev->getName());
$tmp->addAttribute('Count', $dev->getCount());
}
$usb = $hardware->addChild('USB');
foreach (System::removeDupsAndCount($this->_sys->getUsbDevices()) as $dev) {
$tmp = $usb->addChild('Device');
$tmp->addAttribute('Name', $dev->getName());
$tmp->addAttribute('Count', $dev->getCount());
}
$ide = $hardware->addChild('IDE');
foreach (System::removeDupsAndCount($this->_sys->getIdeDevices()) as $dev) {
$tmp = $ide->addChild('Device');
$tmp->addAttribute('Name', $dev->getName());
$tmp->addAttribute('Count', $dev->getCount());
if ($dev->getCapacity() !== null) {
$tmp->addAttribute('Capacity', $dev->getCapacity());
}
}
$scsi = $hardware->addChild('SCSI');
foreach (System::removeDupsAndCount($this->_sys->getScsiDevices()) as $dev) {
$tmp = $scsi->addChild('Device');
$tmp->addAttribute('Name', $dev->getName());
$tmp->addAttribute('Count', $dev->getCount());
if ($dev->getCapacity() !== null) {
$tmp->addAttribute('Capacity', $dev->getCapacity());
}
}
$cpu = $hardware->addChild('CPU');
foreach ($this->_sys->getCpus() as $oneCpu) {
$tmp = $cpu->addChild('CpuCore');
$tmp->addAttribute('Model', $oneCpu->getModel());
if ($oneCpu->getCpuSpeed() !== 0) {
$tmp->addAttribute('CpuSpeed', $oneCpu->getCpuSpeed());
}
if ($oneCpu->getCpuSpeedMax() !== 0) {
$tmp->addAttribute('CpuSpeedMax', $oneCpu->getCpuSpeedMax());
}
if ($oneCpu->getCpuSpeedMin() !== 0) {
$tmp->addAttribute('CpuSpeedMin', $oneCpu->getCpuSpeedMin());
}
if ($oneCpu->getTemp() !== null) {
$tmp->addAttribute('CpuTemp', $oneCpu->getTemp());
}
if ($oneCpu->getBusSpeed() !== null) {
$tmp->addAttribute('BusSpeed', $oneCpu->getBusSpeed());
}
if ($oneCpu->getCache() !== null) {
$tmp->addAttribute('Cache', $oneCpu->getCache());
}
if ($oneCpu->getVirt() !== null) {
$tmp->addAttribute('Virt', $oneCpu->getVirt());
}
if ($oneCpu->getBogomips() !== null) {
$tmp->addAttribute('Bogomips', $oneCpu->getBogomips());
}
if ($oneCpu->getLoad() !== null) {
$tmp->addAttribute('Load', $oneCpu->getLoad());
}
}
}
示例8: _hardware
/**
* Hardwaredevices
*
* @return void
*/
private function _hardware()
{
foreach ($this->_devicelist('PCI') as $pciDev) {
$dev = new HWDevice();
$dev->setName($pciDev);
$this->sys->setPciDevices($dev);
}
foreach ($this->_devicelist('IDE') as $ideDev) {
$dev = new HWDevice();
$dev->setName($ideDev);
$this->sys->setIdeDevices($dev);
}
foreach ($this->_devicelist('SCSI') as $scsiDev) {
$dev = new HWDevice();
$dev->setName($scsiDev);
$this->sys->setScsiDevices($dev);
}
foreach ($this->_devicelist('USB') as $usbDev) {
$dev = new HWDevice();
$dev->setName($usbDev);
$this->sys->setUsbDevices($dev);
}
}
示例9: usb
/**
* USB devices
* get the ide device information out of dmesg
*
* @return void
*/
protected function usb()
{
foreach ($this->readdmesg() as $line) {
// if (preg_match('/^(ugen[0-9\.]+): <(.*)> (.*) (.*)/', $line, $ar_buf)) {
// $dev->setName($ar_buf[1].": ".$ar_buf[2]);
if (preg_match('/^(u[a-z]+[0-9]+): <([^,]*)(.*)> on (usbus[0-9]+)/', $line, $ar_buf)) {
$dev = new HWDevice();
$dev->setName($ar_buf[2]);
$this->sys->setUSBDevices($dev);
}
}
}
示例10: _usb
/**
* USB devices
* @return void
*/
private function _usb()
{
foreach ($this->readaixdata() as $line) {
if (preg_match("/^[\\*\\+]\\s\\S+\\s+\\S+\\s+(.*USB.*)/", $line, $ar_buf)) {
$dev = new HWDevice();
$dev->setName(trim($ar_buf[1]));
$this->sys->setUsbDevices($dev);
}
}
}
示例11: ide
/**
* get the ide information
*
* @return array
*/
protected function ide()
{
foreach ($this->readdmesg() as $line) {
if (preg_match('/^(.*): (.*) <(.*)> at (ata[0-9]\\-(.*)) (.*)/', $line, $ar_buf)) {
$dev = new HWDevice();
$dev->setName($ar_buf[1]);
if (!preg_match("/^acd[0-9](.*)/", $ar_buf[1])) {
$dev->setCapacity($ar_buf[2] * 1024);
}
$this->sys->setIdeDevices($dev);
}
}
}
示例12: _tb
/**
* get the thunderbolt device information out of ioreg
*
* @return void
*/
protected function _tb()
{
$s = $this->_grabioreg('IOThunderboltPort');
$lines = preg_split("/\n/", $s, -1, PREG_SPLIT_NO_EMPTY);
foreach ($lines as $line) {
$dev = new HWDevice();
if (!preg_match('/"Description" = "([^"]*)"/', $line, $ar_buf)) {
$ar_buf = preg_split("/[\\s@]+/", $line, 19);
}
$dev->setName(trim($ar_buf[1]));
$this->sys->setTbDevices($dev);
}
}
示例13: _usb
/**
* USB devices
*
* @return array
*/
private function _usb()
{
if (CommonFunctions::executeProgram('lsusb', '', $bufr, false)) {
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
foreach ($bufe as $buf) {
$device = preg_split("/ /", $buf, 6);
if (isset($device[5]) && trim($device[5]) != "") {
$dev = new HWDevice();
$dev->setName(trim($device[5]));
$this->sys->setUsbDevices($dev);
}
}
}
}
示例14: ide
/**
* IDE devices
* get the ide device information out of dmesg
*
* @return void
*/
protected function ide()
{
foreach ($this->readdmesg() as $line) {
if (preg_match('/^(ad[0-9]+): (.*)MB <(.*)> (.*) (.*)/', $line, $ar_buf)) {
$dev = new HWDevice();
$dev->setName($ar_buf[1]);
$dev->setCapacity($ar_buf[2] * 1024);
$this->sys->setIdeDevices($dev);
} elseif (preg_match('/^(acd[0-9]+): (.*) <(.*)> (.*)/', $line, $ar_buf)) {
$dev = new HWDevice();
$dev->setName($ar_buf[1]);
$this->sys->setIdeDevices($dev);
}
}
}
示例15: _usb
/**
* USB devices
* get the usb device information
*
* @return void
*/
protected function _usb()
{
if (CommonFunctions::executeProgram('listusb', '', $bufr, PSI_DEBUG)) {
$devices = preg_split("/\n/", $bufr);
foreach ($devices as $device) {
if (preg_match("/^\\S+\\s+\\S+\\s+\"(.*)\"\\s+\"(.*)\"/", $device, $ar_buf)) {
$dev = new HWDevice();
$dev->setName(trim($ar_buf[1] . " " . $ar_buf[2]));
$this->sys->setUSBDevices($dev);
}
}
}
}