189,7 → 189,18 |
} |
} |
foreach ($this->_sys->getNetDevices() as $dev) { |
if (!in_array(trim($dev->getName()), $hideDevices)) { |
if (defined('PSI_HIDE_NETWORK_INTERFACE_REGEX') && PSI_HIDE_NETWORK_INTERFACE_REGEX) { |
$hide = false; |
foreach ($hideDevices as $hidedev) { |
if (preg_match('/^'.$hidedev.'$/', trim($dev->getName()))) { |
$hide = true; |
break; |
} |
} |
} else { |
$hide =in_array(trim($dev->getName()), $hideDevices); |
} |
if (!$hide) { |
$device = $network->addChild('NetDevice'); |
$device->addAttribute('Name', $dev->getName()); |
$device->addAttribute('RxBytes', $dev->getRxBytes()); |
210,9 → 221,50 |
private function _buildHardware() |
{ |
$hardware = $this->_xml->addChild('Hardware'); |
if ($this->_sys->getMachine() != "") { |
$hardware->addAttribute('Name', $this->_sys->getMachine()); |
if (($machine = $this->_sys->getMachine()) != "") { |
if ((preg_match('/^(.* (.*\/.*\/.*))\/(.*\/.*\/.*)(, BIOS .*)$/', $machine, $mbuf) |
|| preg_match('/^(.* (.*\/.*))\/(.*\/.*)(, BIOS .*)$/', $machine, $mbuf) |
|| preg_match('/^(.* (.*))\/(.*)(, BIOS .*)$/', $machine, $mbuf) |
|| preg_match('/^((.*\/.*\/.*))\/(.*\/.*\/.*)(, BIOS .*)$/', $machine, $mbuf) |
|| preg_match('/^((.*\/.*))\/(.*\/.*)(, BIOS .*)$/', $machine, $mbuf) |
|| preg_match('/^((.*))\/(.*)(, BIOS .*)$/', $machine, $mbuf)) |
&& ($mbuf[2] === $mbuf[3])) { // find duplicates |
$machine = $mbuf[1].$mbuf[4]; // minimized machine name |
} |
$machine = trim(preg_replace("/^\s*\/?,?/", "", $machine)); // remove leading slash and comma |
|
if ($machine != "") { |
$hardware->addAttribute('Name', $machine); |
} |
} |
|
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) { |
$virt = $this->_sys->getVirtualizer(); |
$first = true; |
$virtstring = ""; |
foreach ($virt as $virtkey=>$virtvalue) if ($virtvalue) { |
if ($first) { |
$first = false; |
} else { |
$virtstring .= ", "; |
} |
if ($virtkey === 'microsoft') { |
$virtstring .= 'hyper-v'; |
} elseif ($virtkey === 'kvm') { |
$virtstring .= 'qemu-kvm'; |
} elseif ($virtkey === 'oracle') { |
$virtstring .= 'virtualbox'; |
} elseif ($virtkey === 'zvm') { |
$virtstring .= 'z/vm'; |
} else { |
$virtstring .= $virtkey; |
} |
} |
if ($virtstring !== "") { |
$hardware->addAttribute('Virtualizer', $virtstring); |
} |
} |
|
$cpu = null; |
$vendortab = null; |
foreach ($this->_sys->getCpus() as $oneCpu) { |
219,13 → 271,18 |
if ($cpu === null) $cpu = $hardware->addChild('CPU'); |
$tmp = $cpu->addChild('CpuCore'); |
$tmp->addAttribute('Model', $oneCpu->getModel()); |
if ($oneCpu->getCpuSpeed() !== 0) { |
$tmp->addAttribute('CpuSpeed', max($oneCpu->getCpuSpeed(), 0)); |
if ($oneCpu->getVoltage() > 0) { |
$tmp->addAttribute('Voltage', $oneCpu->getVoltage()); |
} |
if ($oneCpu->getCpuSpeedMax() !== 0) { |
if ($oneCpu->getCpuSpeed() > 0) { |
$tmp->addAttribute('CpuSpeed', $oneCpu->getCpuSpeed()); |
} elseif ($oneCpu->getCpuSpeed() == -1) { |
$tmp->addAttribute('CpuSpeed', 0); // core stopped |
} |
if ($oneCpu->getCpuSpeedMax() > 0) { |
$tmp->addAttribute('CpuSpeedMax', $oneCpu->getCpuSpeedMax()); |
} |
if ($oneCpu->getCpuSpeedMin() !== 0) { |
if ($oneCpu->getCpuSpeedMin() > 0) { |
$tmp->addAttribute('CpuSpeedMin', $oneCpu->getCpuSpeedMin()); |
} |
/* |
244,7 → 301,7 |
} |
if ($oneCpu->getVendorId() !== null) { |
if ($vendortab === null) $vendortab = @parse_ini_file(PSI_APP_ROOT."/data/cpus.ini", true); |
$shortvendorid = preg_replace('/[\s!]/', '', $oneCpu->getVendorId()); |
$shortvendorid = $oneCpu->getVendorId(); |
if ($vendortab && ($shortvendorid != "") && isset($vendortab['manufacturer'][$shortvendorid])) { |
$tmp->addAttribute('Manufacturer', $vendortab['manufacturer'][$shortvendorid]); |
} |
442,9 → 499,9 |
* |
* @param SimpleXmlExtended $mount Xml-Element |
* @param DiskDevice $dev DiskDevice |
* @param Integer $i counter |
* @param int $i counter |
* |
* @return Void |
* @return void |
*/ |
private function _fillDevice(SimpleXMLExtended $mount, DiskDevice $dev, $i) |
{ |
462,12 → 519,12 |
$mount->addAttribute('Inodes', $dev->getPercentInodesUsed()); |
} |
if ($dev->getIgnore() > 0) $mount->addAttribute('Ignore', $dev->getIgnore()); |
if (PSI_SHOW_MOUNT_OPTION === true) { |
if (PSI_SHOW_MOUNT_OPTION) { |
if ($dev->getOptions() !== null) { |
$mount->addAttribute('MountOptions', preg_replace("/,/", ", ", $dev->getOptions())); |
} |
} |
if (PSI_SHOW_MOUNT_POINT === true) { |
if (PSI_SHOW_MOUNT_POINT && ($dev->getMountPoint() !== null)) { |
$mount->addAttribute('MountPoint', $dev->getMountPoint()); |
} |
} |
480,7 → 537,6 |
private function _buildFilesystems() |
{ |
$hideMounts = $hideFstypes = $hideDisks = $ignoreFree = $ignoreTotal = $ignoreUsage = $ignoreThreshold = array(); |
$i = 1; |
if (defined('PSI_HIDE_MOUNTS') && is_string(PSI_HIDE_MOUNTS)) { |
if (preg_match(ARRAY_EXP, PSI_HIDE_MOUNTS)) { |
$hideMounts = eval(PSI_HIDE_MOUNTS); |
535,6 → 591,7 |
} |
} |
$fs = $this->_xml->addChild('FileSystem'); |
$i = 1; |
foreach ($this->_sys->getDiskDevices() as $disk) { |
if (!in_array($disk->getMountPoint(), $hideMounts, true) && !in_array($disk->getFsType(), $hideFstypes, true) && !in_array($disk->getName(), $hideDisks, true)) { |
$mount = $fs->addChild('Mount'); |
574,11 → 631,13 |
$item = $temp->addChild('Item'); |
$item->addAttribute('Label', $dev->getName()); |
$item->addAttribute('Value', $dev->getValue()); |
$alarm = false; |
if ($dev->getMax() !== null) { |
$item->addAttribute('Max', $dev->getMax()); |
$alarm = true; |
} |
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") { |
$item->addAttribute('Event', $dev->getEvent()); |
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) { |
$item->addAttribute('Event', ucfirst(strtolower($dev->getEvent()))); |
} |
} |
|
589,14 → 648,16 |
$item = $fan->addChild('Item'); |
$item->addAttribute('Label', $dev->getName()); |
$item->addAttribute('Value', $dev->getValue()); |
$alarm = false; |
if ($dev->getMin() !== null) { |
$item->addAttribute('Min', $dev->getMin()); |
$alarm = true; |
} |
if ($dev->getUnit() !== "") { |
$item->addAttribute('Unit', $dev->getUnit()); |
} |
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") { |
$item->addAttribute('Event', $dev->getEvent()); |
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) { |
$item->addAttribute('Event', ucfirst(strtolower($dev->getEvent()))); |
} |
} |
|
607,16 → 668,19 |
$item = $volt->addChild('Item'); |
$item->addAttribute('Label', $dev->getName()); |
$item->addAttribute('Value', $dev->getValue()); |
$alarm = false; |
if (($dev->getMin() === null) || ($dev->getMin() != 0) || ($dev->getMax() === null) || ($dev->getMax() != 0)) { |
if ($dev->getMin() !== null) { |
$item->addAttribute('Min', $dev->getMin()); |
$alarm = true; |
} |
if ($dev->getMax() !== null) { |
$item->addAttribute('Max', $dev->getMax()); |
$alarm = true; |
} |
} |
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") { |
$item->addAttribute('Event', $dev->getEvent()); |
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) { |
$item->addAttribute('Event', ucfirst(strtolower($dev->getEvent()))); |
} |
} |
|
627,11 → 691,13 |
$item = $power->addChild('Item'); |
$item->addAttribute('Label', $dev->getName()); |
$item->addAttribute('Value', $dev->getValue()); |
$alarm = false; |
if ($dev->getMax() !== null) { |
$item->addAttribute('Max', $dev->getMax()); |
$alarm = true; |
} |
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") { |
$item->addAttribute('Event', $dev->getEvent()); |
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) { |
$item->addAttribute('Event', ucfirst(strtolower($dev->getEvent()))); |
} |
} |
|
642,16 → 708,19 |
$item = $current->addChild('Item'); |
$item->addAttribute('Label', $dev->getName()); |
$item->addAttribute('Value', $dev->getValue()); |
$alarm = false; |
if (($dev->getMin() === null) || ($dev->getMin() != 0) || ($dev->getMax() === null) || ($dev->getMax() != 0)) { |
if ($dev->getMin() !== null) { |
$item->addAttribute('Min', $dev->getMin()); |
$alarm = true; |
} |
if ($dev->getMax() !== null) { |
$item->addAttribute('Max', $dev->getMax()); |
$alarm = true; |
} |
} |
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") { |
$item->addAttribute('Event', $dev->getEvent()); |
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && ($dev->getEvent() !== "") && (((strtolower($dev->getEvent())) !== "alarm") || $alarm || ($dev->getValue() == 0))) { |
$item->addAttribute('Event', ucfirst(strtolower($dev->getEvent()))); |
} |
} |
|
666,7 → 735,7 |
$item->addAttribute('Unit', $dev->getUnit()); |
} |
if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") { |
$item->addAttribute('Event', $dev->getEvent()); |
$item->addAttribute('Event', ucfirst(strtolower($dev->getEvent()))); |
} |
} |
} |
681,7 → 750,7 |
private function _buildUpsinfo() |
{ |
$upsinfo = $this->_xml->addChild('UPSInfo'); |
if (defined('PSI_UPS_APCUPSD_CGI_ENABLE') && PSI_UPS_APCUPSD_CGI_ENABLE) { |
if (!defined('PSI_EMU_HOSTNAME') && defined('PSI_UPS_APCUPSD_CGI_ENABLE') && PSI_UPS_APCUPSD_CGI_ENABLE) { |
$upsinfo->addAttribute('ApcupsdCgiLinks', true); |
} |
if (sizeof(unserialize(PSI_UPSINFO))>0) { |
701,6 → 770,9 |
$item->addAttribute('StartTime', $ups->getStartTime()); |
} |
$item->addAttribute('Status', $ups->getStatus()); |
if ($ups->getBeeperStatus() !== null) { |
$item->addAttribute('BeeperStatus', $ups->getBeeperStatus()); |
} |
if ($ups->getTemperatur() !== null) { |
$item->addAttribute('Temperature', $ups->getTemperatur()); |
} |
748,10 → 820,10 |
{ |
if (($this->_plugin == '') || $this->_complete_request) { |
if ($this->_sys === null) { |
if (PSI_DEBUG === true) { |
if (PSI_DEBUG) { |
// unstable version check |
if (!is_numeric(substr(PSI_VERSION, -1))) { |
$this->_errors->addError("WARN", "This is an unstable version of phpSysInfo, some things may not work correctly"); |
$this->_errors->addWarning("This is an unstable version of phpSysInfo, some things may not work correctly"); |
} |
|
// Safe mode check |
771,7 → 843,7 |
$this->_errors->addError("WARN", "PhpSysInfo requires '.' inside the 'include_path' in php.ini"); |
} |
// popen mode check |
if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN === true) { |
if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN) { |
$this->_errors->addError("WARN", "Installed version of PHP does not support proc_open() function, popen() is used"); |
} |
} |