34,7 → 34,7 |
/** |
* Assoc array of all CPUs loads. |
*/ |
private $_cpu_loads = null; |
protected $_cpu_loads = null; |
|
/** |
* Version string. |
196,7 → 196,7 |
$this->_machine_info['machine'] = trim(preg_replace("/^\/,?/", "", preg_replace("/ ?(To be filled by O\.E\.M\.|System manufacturer|System Product Name|Not Specified|Default string) ?/i", "", $this->_machine_info['machine']))); |
} |
|
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null) && count($vendor_array)>0) { |
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null) && count($vendor_array) > 0) { |
$virt = CommonFunctions::decodevirtualizer($vendor_array); |
if ($virt !== null) { |
$this->_machine_info['hypervisor'] = $virt; |
216,20 → 216,29 |
{ |
if ($this->_kernel_string === null) { |
$this->_kernel_string = ""; |
if (CommonFunctions::executeProgram($uname="uptrack-uname", '-r', $strBuf, false) || // show effective kernel if ksplice uptrack is installed |
CommonFunctions::executeProgram($uname="uname", '-r', $strBuf, PSI_DEBUG)) { |
if ($this->sys->getOS() == 'SSH') { |
if (CommonFunctions::executeProgram('uname', '-s', $strBuf, false) && ($strBuf !== '')) { |
$this->sys->setOS($strBuf); |
} else { |
return $this->_kernel_string; |
} |
} |
if ((CommonFunctions::executeProgram($uname="uptrack-uname", '-r', $strBuf, false) && ($strBuf !== '')) || // show effective kernel if ksplice uptrack is installed |
(CommonFunctions::executeProgram($uname="uname", '-r', $strBuf, PSI_DEBUG) && ($strBuf !== ''))) { |
$this->_kernel_string = $strBuf; |
if (CommonFunctions::executeProgram($uname, '-v', $strBuf, PSI_DEBUG)) { |
if (CommonFunctions::executeProgram($uname, '-v', $strBuf, PSI_DEBUG) && ($strBuf !== '')) { |
if (preg_match('/ SMP /', $strBuf)) { |
$this->_kernel_string .= ' (SMP)'; |
} |
} |
if (CommonFunctions::executeProgram($uname, '-m', $strBuf, PSI_DEBUG)) { |
if (CommonFunctions::executeProgram($uname, '-m', $strBuf, PSI_DEBUG) && ($strBuf !== '')) { |
$this->_kernel_string .= ' '.$strBuf; |
} |
} elseif (CommonFunctions::rfts('/proc/version', $strBuf, 1)) { |
if (preg_match('/version\s+(\S+)/', $strBuf, $ar_buf)) { |
if (preg_match('/\/Hurd-([^\)]+)/', $strBuf, $ar_buf)) { |
$this->_kernel_string = $ar_buf[1]; |
} elseif (preg_match('/version\s+(\S+)/', $strBuf, $ar_buf)) { |
$this->_kernel_string = $ar_buf[1]; |
if (preg_match('/ SMP /', $strBuf)) { |
$this->_kernel_string .= ' (SMP)'; |
} |
241,11 → 250,20 |
} |
|
/** |
* check OS type |
*/ |
public function __construct($blockname = false) |
{ |
parent::__construct($blockname); |
$this->_get_kernel_string(); |
} |
|
/** |
* Machine |
* |
* @return void |
*/ |
private function _machine() |
protected function _machine() |
{ |
$machine_info = $this->_get_machine_info(); |
if (isset($machine_info['machine'])) { |
279,7 → 297,7 |
*/ |
protected function _hostname() |
{ |
if (PSI_USE_VHOST) { |
if (PSI_USE_VHOST && !defined('PSI_EMU_PORT')) { |
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm); |
} else { |
if (CommonFunctions::rfts('/proc/sys/kernel/hostname', $result, 1, 4096, PSI_DEBUG && (PSI_OS != 'Android'))) { |
299,7 → 317,7 |
* |
* @return void |
*/ |
private function _kernel() |
protected function _kernel() |
{ |
if (($verBuf = $this->_get_kernel_string()) != "") { |
$this->sys->setKernel($verBuf); |
334,14 → 352,14 |
$novm = true; |
// code based on src/basic/virt.c from systemd-detect-virt source code (https://github.com/systemd/systemd) |
|
// First, try to detect Oracle Virtualbox and Amazon EC2 Nitro, even if they use KVM, as well as Xen even if |
// it cloaks as Microsoft Hyper-V. Attempt to detect uml at this stage also since it runs as a user-process |
// nested inside other VMs. Also check for Xen now, because Xen PV mode does not override CPUID when nested |
// inside another hypervisor. |
// First, try to detect Oracle Virtualbox, Amazon EC2 Nitro and Parallels, even if they use KVM, |
// as well as Xen even if it cloaks as Microsoft Hyper-V. Attempt to detect uml at this stage also |
// since it runs as a user-process nested inside other VMs. Also check for Xen now, because Xen PV |
// mode does not override CPUID when nested inside another hypervisor. |
$machine_info = $this->_get_machine_info(); |
if (isset($machine_info['hypervisor'])) { |
$hypervisor = $machine_info['hypervisor']; |
if (($hypervisor === 'oracle') || ($hypervisor === 'amazon') || ($hypervisor === 'xen')) { |
if (($hypervisor === 'oracle') || ($hypervisor === 'amazon') || ($hypervisor === 'xen') || ($hypervisor === 'parallels')) { |
$this->sys->setVirtualizer($hypervisor); |
$novm = false; |
} |
520,12 → 538,15 |
* |
* @return void |
*/ |
protected function _uptime() |
protected function _uptime($bufu = null) |
{ |
if (CommonFunctions::rfts('/proc/uptime', $buf, 1, 4096, PSI_OS != 'Android')) { |
$ar_buf = preg_split('/ /', $buf); |
$this->sys->setUptime(trim($ar_buf[0])); |
} elseif (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) { |
} elseif (($this->_uptime !== null) || ($bufu !== null) || CommonFunctions::executeProgram('uptime', '', $bufu)) { |
if (($this->_uptime === null) && ($bufu !== null)) { |
$this->_uptime = $bufu; |
} |
if (preg_match("/up (\d+) day[s]?,[ ]+(\d+):(\d+),/", $this->_uptime, $ar_buf)) { |
$min = $ar_buf[3]; |
$hours = $ar_buf[2]; |
539,9 → 560,19 |
$min = $ar_buf[2]; |
$hours = $ar_buf[1]; |
$this->sys->setUptime($hours * 3600 + $min * 60); |
} elseif (preg_match("/up[ ]+(\d+):(\d+):(\d+)/", $this->_uptime, $ar_buf)) { |
$sec = $ar_buf[3]; |
$min = $ar_buf[2]; |
$hours = $ar_buf[1]; |
$this->sys->setUptime($hours * 3600 + $min * 60 + $sec); |
} elseif (preg_match("/up[ ]+(\d+) min,/", $this->_uptime, $ar_buf)) { |
$min = $ar_buf[1]; |
$this->sys->setUptime($min * 60); |
} elseif (preg_match("/up[ ]+(\d+) day[s]?,[ ]+(\d+) hour[s]?,[ ]+(\d+) minute[s]?/", $this->_uptime, $ar_buf)) { |
$min = $ar_buf[3]; |
$hours = $ar_buf[2]; |
$days = $ar_buf[1]; |
$this->sys->setUptime($days * 86400 + $hours * 3600 + $min * 60); |
} |
} |
} |
552,15 → 583,15 |
* |
* @return void |
*/ |
protected function _loadavg() |
protected function _loadavg($buf = null) |
{ |
if (CommonFunctions::rfts('/proc/loadavg', $buf, 1, 4096, PSI_OS != 'Android')) { |
if ((($buf !== null) || CommonFunctions::rfts('/proc/loadavg', $buf, 1, 4096, PSI_OS != 'Android')) && preg_match("/^\d/", trim($buf))) { |
$result = preg_split("/\s/", $buf, 4); |
// don't need the extra values, only first three |
unset($result[3]); |
$this->sys->setLoad(implode(' ', $result)); |
} elseif ((($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) && preg_match("/load average: (.*), (.*), (.*)$/", $this->_uptime, $ar_buf)) { |
$this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]); |
} elseif (($buf === null) && ((($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) && preg_match("/load average: (.*), (.*), (.*)$/", $this->_uptime, $ar_buf))) { |
$this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]); |
} |
if (PSI_LOAD_BAR) { |
$this->sys->setLoadPercent($this->_parseProcStat('cpu')); |
641,10 → 672,9 |
* |
* @return void |
*/ |
protected function _cpuinfo() |
protected function _cpuinfo($bufr = null) |
{ |
if (CommonFunctions::rfts('/proc/cpuinfo', $bufr)) { |
|
if (($bufr !== null) || CommonFunctions::rfts('/proc/cpuinfo', $bufr)) { |
$cpulist = null; |
$raslist = null; |
|
703,11 → 733,15 |
case 'cpu frequency': |
if (preg_match('/^(\d+)\s+Hz/i', $arrBuff1, $bufr2)) { |
$_cpus = round($bufr2[1]/1000000); |
} elseif (preg_match('/^(\d+)\s+MHz/i', $arrBuff1, $bufr2)) { |
$_cpus = $bufr2[1]; |
} |
break; |
case 'system bus frequency': |
if (preg_match('/^(\d+)\s+Hz/i', $arrBuff1, $bufr2)) { |
$_buss = round($bufr2[1]/1000000); |
} elseif (preg_match('/^(\d+)\s+MHz/i', $arrBuff1, $bufr2)) { |
$_buss = $bufr2[1]; |
} |
break; |
case 'bogomips per cpu': |
741,7 → 775,7 |
case 'processor': |
$proc = $arrBuff1; |
if (is_numeric($proc)) { |
if (($procname !== null) && (strlen($procname)>0)) { |
if (($procname !== null) && (strlen($procname) > 0)) { |
$dev->setModel($procname); |
} |
} else { |
755,25 → 789,40 |
case 'cpu': |
$dev->setModel($arrBuff1); |
break; |
case 'cpu frequency': |
if (preg_match('/^(\d+)\s+Hz/i', $arrBuff1, $bufr2)) { |
if (($tmpsp = round($bufr2[1]/1000000)) > 0) { |
$dev->setCpuSpeed($tmpsp); |
$speedset = true; |
} |
} elseif (preg_match('/^(\d+)\s+MHz/i', $arrBuff1, $bufr2)) { |
if ($bufr2[1] > 0) { |
$dev->setCpuSpeed($bufr2[1]); |
$speedset = true; |
} |
} |
break; |
case 'cpu mhz': |
case 'clock': |
if ($arrBuff1 > 0) { // openSUSE fix |
if ($arrBuff1 > 0) { |
$dev->setCpuSpeed($arrBuff1); |
$speedset = true; |
} |
break; |
case 'cpu mhz static': |
if ($arrBuff1 > 0) { // openSUSE fix |
$dev->setCpuSpeedMax($arrBuff1); |
} |
$dev->setCpuSpeedMax($arrBuff1); |
break; |
case 'cycle frequency [hz]': |
$dev->setCpuSpeed($arrBuff1 / 1000000); |
$speedset = true; |
if (($tmpsp = round($arrBuff1/1000000)) > 0) { |
$dev->setCpuSpeed($tmpsp); |
$speedset = true; |
} |
break; |
case 'cpu0clktck': |
$dev->setCpuSpeed(hexdec($arrBuff1) / 1000000); // Linux sparc64 |
$speedset = true; |
case 'cpu0clktck': // Linux sparc64 |
if (($tmpsp = round(hexdec($arrBuff1)/1000000)) > 0) { |
$dev->setCpuSpeed($tmpsp); |
$speedset = true; |
} |
break; |
case 'l3 cache': |
case 'cache size': |
845,8 → 894,8 |
// 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 |
if (($arch === "5TE") && (($bogo = $dev->getBogomips()) !== null) && ($bogo > 0)) { |
$dev->setCpuSpeed($bogo); // BogoMIPS are not BogoMIPS on this CPU, it's the speed |
$speedset = true; |
$dev->setBogomips(null); // no BogoMIPS available, unset previously set BogoMIPS |
} |
854,7 → 903,7 |
if (($dev->getBusSpeed() == 0) && ($_buss !== null)) { |
$dev->setBusSpeed($_buss); |
} |
if (($dev->getCpuSpeed() == 0) && ($_cpus !== null)) { |
if (($dev->getCpuSpeed() == 0) && ($_cpus !== null) && ($_cpus > 0)) { |
$dev->setCpuSpeed($_cpus); |
$speedset = true; |
} |
873,18 → 922,20 |
$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(trim($buf) / 1000); |
$speedset = true; |
} elseif (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/scaling_cur_freq', $buf, 1, 4096, false)) { |
$dev->setCpuSpeed(trim($buf) / 1000); |
$speedset = true; |
if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_cur_freq', $buf, 1, 4096, false) |
|| CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/scaling_cur_freq', $buf, 1, 4096, false)) { |
if (round(trim($buf)/1000) > 0) { |
$dev->setCpuSpeed(round(trim($buf)/1000)); |
$speedset = true; |
} |
} |
if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_max_freq', $buf, 1, 4096, false)) { |
$dev->setCpuSpeedMax(trim($buf) / 1000); |
if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_max_freq', $buf, 1, 4096, false) |
|| CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/scaling_max_freq', $buf, 1, 4096, false)) { |
$dev->setCpuSpeedMax(round(trim($buf)/1000)); |
} |
if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_min_freq', $buf, 1, 4096, false)) { |
$dev->setCpuSpeedMin(trim($buf) / 1000); |
if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_min_freq', $buf, 1, 4096, false) |
|| CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/scaling_min_freq', $buf, 1, 4096, false)) { |
$dev->setCpuSpeedMin(round(trim($buf)/1000)); |
} |
// variable speed processors specific code ends |
if (PSI_LOAD_BAR) { |
901,9 → 952,15 |
&& (($_hard === 'BCM2708') || ($_hard === 'BCM2835') || ($_hard === 'BCM2709') || ($_hard === 'BCM2836') || ($_hard === 'BCM2710') || ($_hard === 'BCM2837') || ($_hard === 'BCM2711') || ($_hard === 'BCM2838')) |
&& ($_revi !== null)) { // Raspberry Pi detection (instead of 'cat /proc/device-tree/model') |
if ($raslist === null) $raslist = @parse_ini_file(PSI_APP_ROOT."/data/raspberry.ini", true); |
$oldmach = $this->sys->getMachine(); |
if (($oldmach !== '') && preg_match("/^raspberrypi rpi(,.+)/", $oldmach, $machbuf)) { |
$oldmachend = $machbuf[1]; |
} else { |
$oldmachend = ''; |
} |
if ($raslist && !preg_match('/[^0-9a-f]/', $_revi)) { |
if (($revidec = hexdec($_revi)) & 0x800000) { |
if ($this->sys->getMachine() === '') { |
if (($oldmach === '') || ($oldmachend !== '')) { |
$manufacturer = ($revidec >> 16) & 15; |
if (isset($raslist['manufacturer'][$manufacturer])) { |
$manuf = ' '.$raslist['manufacturer'][$manufacturer]; |
912,17 → 969,17 |
} |
$model = ($revidec >> 4) & 255; |
if (isset($raslist['model'][$model])) { |
$this->sys->setMachine('Raspberry Pi '.$raslist['model'][$model].' (PCB 1.'.($revidec & 15).$manuf.')'); |
$this->sys->setMachine('Raspberry Pi '.$raslist['model'][$model].' (PCB 1.'.($revidec & 15).$manuf.')'.$oldmachend); |
} else { |
$this->sys->setMachine('Raspberry Pi (PCB 1.'.($revidec & 15).$manuf.')'); |
$this->sys->setMachine('Raspberry Pi (PCB 1.'.($revidec & 15).$manuf.')'.$oldmachend); |
} |
} |
} else { |
if ($this->sys->getMachine() === '') { |
if (($oldmach === '') || ($oldmachend !== '')) { |
if (isset($raslist['old'][$revidec & 0x7fffff])) { |
$this->sys->setMachine('Raspberry Pi '.$raslist['old'][$revidec & 0x7fffff]); |
$this->sys->setMachine('Raspberry Pi '.$raslist['old'][$revidec & 0x7fffff].$oldmachend); |
} else { |
$this->sys->setMachine('Raspberry Pi'); |
$this->sys->setMachine('Raspberry Pi'.$oldmachend); |
} |
} |
} |
1119,52 → 1176,54 |
* |
* @return void |
*/ |
protected function _usb() |
protected function _usb($bufu = null) |
{ |
$usbarray = array(); |
if (CommonFunctions::executeProgram('lsusb', (PSI_OS != 'Android')?'':'2>/dev/null', $bufr, PSI_DEBUG && (PSI_OS != 'Android'), 5) && ($bufr !== "")) { |
$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]) != "")) || |
((isset($device[5]) && trim($device[5]) != ""))) { |
$usbid = intval($device[1]).'-'.intval(trim($device[3], ':')).' '.$device[5]; |
if ((isset($device[6]) && trim($device[6]) != "")) { |
$usbarray[$usbid]['name'] = trim($device[6]); |
} else { |
$usbarray[$usbid]['name'] = 'unknown'; |
if ($nobufu = ($bufu === null)) { |
if (CommonFunctions::executeProgram('lsusb', (PSI_OS != 'Android')?'':'2>/dev/null', $bufr, PSI_DEBUG && (PSI_OS != 'Android'), 5) && ($bufr !== "")) { |
$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]) != "")) || |
((isset($device[5]) && trim($device[5]) != ""))) { |
$usbid = intval($device[1]).'-'.intval(trim($device[3], ':')).' '.$device[5]; |
if ((isset($device[6]) && trim($device[6]) != "")) { |
$usbarray[$usbid]['name'] = trim($device[6]); |
} else { |
$usbarray[$usbid]['name'] = 'unknown'; |
} |
} |
} |
} |
} |
|
$usbdevices = CommonFunctions::findglob('/sys/bus/usb/devices/*/idProduct', GLOB_NOSORT); |
if (is_array($usbdevices) && (($total = count($usbdevices)) > 0)) { |
for ($i = 0; $i < $total; $i++) { |
if (CommonFunctions::rfts($usbdevices[$i], $idproduct, 1, 4096, false) && (($idproduct=trim($idproduct)) != "")) { // is readable |
$busnum = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/busnum'); |
$devnum = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/devnum'); |
$idvendor = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/idVendor'); |
if (($busnum!==null) && ($devnum!==null) && ($idvendor!==null)) { |
$usbid = intval($busnum).'-'.intval($devnum).' '.$idvendor.':'.$idproduct; |
$manufacturer = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/manufacturer'); |
if ($manufacturer!==null) { |
$usbarray[$usbid]['manufacturer'] = $manufacturer; |
} |
$product = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/product'); |
if ($product!==null) { |
$usbarray[$usbid]['product'] = $product; |
} |
$speed = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/speed'); |
if ($product!==null) { |
$usbarray[$usbid]['speed'] = $speed; |
} |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS |
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) { |
$serial = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/serial'); |
if (($serial!==null) && !preg_match('/\W/', $serial)) { |
$usbarray[$usbid]['serial'] = $serial; |
$usbdevices = CommonFunctions::findglob('/sys/bus/usb/devices/*/idProduct', GLOB_NOSORT); |
if (is_array($usbdevices) && (($total = count($usbdevices)) > 0)) { |
for ($i = 0; $i < $total; $i++) { |
if (CommonFunctions::rfts($usbdevices[$i], $idproduct, 1, 4096, false) && (($idproduct=trim($idproduct)) != "")) { // is readable |
$busnum = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/busnum'); |
$devnum = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/devnum'); |
$idvendor = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/idVendor'); |
if (($busnum!==null) && ($devnum!==null) && ($idvendor!==null)) { |
$usbid = intval($busnum).'-'.intval($devnum).' '.$idvendor.':'.$idproduct; |
$manufacturer = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/manufacturer'); |
if ($manufacturer!==null) { |
$usbarray[$usbid]['manufacturer'] = $manufacturer; |
} |
$product = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/product'); |
if ($product!==null) { |
$usbarray[$usbid]['product'] = $product; |
} |
$speed = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/speed'); |
if ($product!==null) { |
$usbarray[$usbid]['speed'] = $speed; |
} |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS |
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) { |
$serial = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/serial'); |
if (($serial!==null) && !preg_match('/\W/', $serial)) { |
$usbarray[$usbid]['serial'] = $serial; |
} |
} |
} |
} |
} |
1171,9 → 1230,9 |
} |
} |
|
if ((count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/usb/devices', $bufr, 0, 4096, false)) { // usb-devices |
if (!$nobufu || ((count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/usb/devices', $bufu, 0, 4096, false))) { // usb-devices |
$devnum = -1; |
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); |
$bufe = preg_split("/\n/", $bufu, -1, PREG_SPLIT_NO_EMPTY); |
foreach ($bufe as $buf) { |
if (preg_match('/^T/', $buf)) { |
$devnum++; |
1202,7 → 1261,7 |
} |
} |
|
if ((count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/input/devices', $bufr, 0, 4096, false)) { |
if ($nobufu && (count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/input/devices', $bufr, 0, 4096, false)) { |
$devnam = "unknown"; |
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); |
foreach ($bufe as $buf) { |
1375,9 → 1434,9 |
* |
* @return void |
*/ |
protected function _network() |
protected function _network($bufr = null) |
{ |
if (CommonFunctions::rfts('/proc/net/dev', $bufr, 0, 4096, PSI_DEBUG)) { |
if (($bufr === null) && CommonFunctions::rfts('/proc/net/dev', $bufr, 0, 4096, PSI_DEBUG)) { |
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); |
foreach ($bufe as $buf) { |
if (preg_match('/:/', $buf)) { |
1420,7 → 1479,8 |
|| preg_match('/^'.trim($dev_name).':\s+ip\s+(\S+)\s+mask/i', $buf2, $ar_buf2) |
|| preg_match('/^\s+inet6\saddr:\s([^\/\s]+)(.+)\s+Scope:[GH]/i', $buf2, $ar_buf2) |
|| preg_match('/^\s+inet6\s+(\S+)\s+prefixlen(.+)((<global>)|(<host>))/i', $buf2, $ar_buf2) |
|| preg_match('/^\s+inet6?\s+([^\/\s]+).*\s+scope\s((global)|(host))/i', $buf2, $ar_buf2)) |
|| preg_match('/^\s+inet6?\s+([^\/\s]+).*\s+scope\s((global)|(host))/i', $buf2, $ar_buf2) |
|| preg_match('/^\s+inet\saddr6:\s+(\S+)\s+prefixlen(.+)/i', $buf2, $ar_buf2)) |
&& ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1])) { |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1])); |
} |
1447,7 → 1507,7 |
$this->sys->setNetDevices($dev); |
} |
} |
} elseif (CommonFunctions::executeProgram('ip', 'addr show', $bufr, PSI_DEBUG) && ($bufr!="")) { |
} elseif (($bufr === null) && CommonFunctions::executeProgram('ip', 'addr show', $bufr, PSI_DEBUG) && ($bufr!="")) { |
$lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); |
$was = false; |
$macaddr = ""; |
1526,7 → 1586,7 |
} |
$this->sys->setNetDevices($dev); |
} |
} elseif (CommonFunctions::executeProgram('ifconfig', '-a', $bufr, PSI_DEBUG)) { |
} elseif (($bufr !== null) || CommonFunctions::executeProgram('ifconfig', '-a', $bufr, PSI_DEBUG)) { |
$lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); |
$was = false; |
$errors = 0; |
1617,7 → 1677,8 |
} elseif ((preg_match('/^\s+inet\saddr:(\S+)/i', $line, $ar_buf2) |
|| preg_match('/^\s+inet\s+(\S+)\s+netmask/i', $line, $ar_buf2) |
|| preg_match('/^\s+inet6\saddr:\s([^\/\s]+)(.+)\s+Scope:[GH]/i', $line, $ar_buf2) |
|| preg_match('/^\s+inet6\s+(\S+)\s+prefixlen(.+)((<global>)|(<host>))/i', $line, $ar_buf2)) |
|| preg_match('/^\s+inet6\s+(\S+)\s+prefixlen(.+)((<global>)|(<host>))/i', $line, $ar_buf2) |
|| preg_match('/^\s+inet\saddr6:\s+(\S+)\s+prefixlen(.+)/i', $line, $ar_buf2)) |
&& ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1])) { |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1])); |
} |
1644,9 → 1705,9 |
* |
* @return void |
*/ |
protected function _memory() |
protected function _memory($mbuf = null, $sbuf = null) |
{ |
if (CommonFunctions::rfts('/proc/meminfo', $mbuf)) { |
if (($mbuf !== null) || CommonFunctions::rfts('/proc/meminfo', $mbuf)) { |
$swaptotal = null; |
$swapfree = null; |
$bufe = preg_split("/\n/", $mbuf, -1, PREG_SPLIT_NO_EMPTY); |
1670,7 → 1731,7 |
if (($this->sys->getMemCache() !== null) && ($this->sys->getMemBuffer() !== null)) { |
$this->sys->setMemApplication($this->sys->getMemUsed() - $this->sys->getMemCache() - $this->sys->getMemBuffer()); |
} |
if (CommonFunctions::rfts('/proc/swaps', $sbuf, 0, 4096, false)) { |
if (($sbuf !== null) || CommonFunctions::rfts('/proc/swaps', $sbuf, 0, 4096, false)) { |
$swaps = preg_split("/\n/", $sbuf, -1, PREG_SPLIT_NO_EMPTY); |
unset($swaps[0]); |
foreach ($swaps as $swap) { |
1699,7 → 1760,7 |
* |
* @return void |
*/ |
private function _filesystems() |
protected function _filesystems() |
{ |
$df_args = ""; |
$hideFstypes = array(); |
2039,6 → 2100,26 |
$this->sys->setDistribution(trim($buf)); |
} |
} |
} elseif (CommonFunctions::fileexists($filename="/etc/slackware-version")) { |
if (!CommonFunctions::rfts($filename, $buf, 1, 4096, false)) { |
$buf = ""; |
} |
if (isset($list['Slackware']['Image'])) { |
$this->sys->setDistributionIcon($list['Slackware']['Image']); |
} |
if (isset($list['Slackware']['Name'])) { |
if (($buf === null) || (trim($buf) == "")) { |
$this->sys->setDistribution($list['Slackware']['Name']); |
} else { |
$this->sys->setDistribution($list['Slackware']['Name']." ".trim($buf)); |
} |
} else { |
if (($buf === null) || (trim($buf) == "")) { |
$this->sys->setDistribution('Slackware'); |
} else { |
$this->sys->setDistribution(trim($buf)); |
} |
} |
} elseif (CommonFunctions::fileexists($filename="/etc/config/uLinux.conf") |
&& CommonFunctions::rfts($filename, $buf, 0, 4096, false) |
&& preg_match("/^Rsync\sModel\s*=\s*QNAP/m", $buf) |