Line 32... |
Line 32... |
32 |
private $_uptime = null;
|
32 |
private $_uptime = null;
|
33 |
|
33 |
|
34 |
/**
|
34 |
/**
|
35 |
* Assoc array of all CPUs loads.
|
35 |
* Assoc array of all CPUs loads.
|
36 |
*/
|
36 |
*/
|
37 |
private $_cpu_loads = null;
|
37 |
protected $_cpu_loads = null;
|
38 |
|
38 |
|
39 |
/**
|
39 |
/**
|
40 |
* Version string.
|
40 |
* Version string.
|
41 |
*/
|
41 |
*/
|
42 |
private $_kernel_string = null;
|
42 |
private $_kernel_string = null;
|
Line 194... |
Line 194... |
194 |
}
|
194 |
}
|
195 |
if (isset($this->_machine_info['machine'])) {
|
195 |
if (isset($this->_machine_info['machine'])) {
|
196 |
$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'])));
|
196 |
$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'])));
|
197 |
}
|
197 |
}
|
198 |
|
198 |
|
199 |
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null) && count($vendor_array)>0) {
|
199 |
if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null) && count($vendor_array) > 0) {
|
200 |
$virt = CommonFunctions::decodevirtualizer($vendor_array);
|
200 |
$virt = CommonFunctions::decodevirtualizer($vendor_array);
|
201 |
if ($virt !== null) {
|
201 |
if ($virt !== null) {
|
202 |
$this->_machine_info['hypervisor'] = $virt;
|
202 |
$this->_machine_info['hypervisor'] = $virt;
|
203 |
}
|
203 |
}
|
204 |
}
|
204 |
}
|
Line 214... |
Line 214... |
214 |
*/
|
214 |
*/
|
215 |
private function _get_kernel_string()
|
215 |
private function _get_kernel_string()
|
216 |
{
|
216 |
{
|
217 |
if ($this->_kernel_string === null) {
|
217 |
if ($this->_kernel_string === null) {
|
218 |
$this->_kernel_string = "";
|
218 |
$this->_kernel_string = "";
|
- |
|
219 |
if ($this->sys->getOS() == 'SSH') {
|
- |
|
220 |
if (CommonFunctions::executeProgram('uname', '-s', $strBuf, false) && ($strBuf !== '')) {
|
- |
|
221 |
$this->sys->setOS($strBuf);
|
- |
|
222 |
} else {
|
- |
|
223 |
return $this->_kernel_string;
|
- |
|
224 |
}
|
- |
|
225 |
}
|
219 |
if (CommonFunctions::executeProgram($uname="uptrack-uname", '-r', $strBuf, false) || // show effective kernel if ksplice uptrack is installed
|
226 |
if ((CommonFunctions::executeProgram($uname="uptrack-uname", '-r', $strBuf, false) && ($strBuf !== '')) || // show effective kernel if ksplice uptrack is installed
|
220 |
CommonFunctions::executeProgram($uname="uname", '-r', $strBuf, PSI_DEBUG)) {
|
227 |
(CommonFunctions::executeProgram($uname="uname", '-r', $strBuf, PSI_DEBUG) && ($strBuf !== ''))) {
|
221 |
$this->_kernel_string = $strBuf;
|
228 |
$this->_kernel_string = $strBuf;
|
222 |
if (CommonFunctions::executeProgram($uname, '-v', $strBuf, PSI_DEBUG)) {
|
229 |
if (CommonFunctions::executeProgram($uname, '-v', $strBuf, PSI_DEBUG) && ($strBuf !== '')) {
|
223 |
if (preg_match('/ SMP /', $strBuf)) {
|
230 |
if (preg_match('/ SMP /', $strBuf)) {
|
224 |
$this->_kernel_string .= ' (SMP)';
|
231 |
$this->_kernel_string .= ' (SMP)';
|
225 |
}
|
232 |
}
|
226 |
}
|
233 |
}
|
227 |
if (CommonFunctions::executeProgram($uname, '-m', $strBuf, PSI_DEBUG)) {
|
234 |
if (CommonFunctions::executeProgram($uname, '-m', $strBuf, PSI_DEBUG) && ($strBuf !== '')) {
|
228 |
$this->_kernel_string .= ' '.$strBuf;
|
235 |
$this->_kernel_string .= ' '.$strBuf;
|
229 |
}
|
236 |
}
|
230 |
} elseif (CommonFunctions::rfts('/proc/version', $strBuf, 1)) {
|
237 |
} elseif (CommonFunctions::rfts('/proc/version', $strBuf, 1)) {
|
- |
|
238 |
if (preg_match('/\/Hurd-([^\)]+)/', $strBuf, $ar_buf)) {
|
- |
|
239 |
$this->_kernel_string = $ar_buf[1];
|
231 |
if (preg_match('/version\s+(\S+)/', $strBuf, $ar_buf)) {
|
240 |
} elseif (preg_match('/version\s+(\S+)/', $strBuf, $ar_buf)) {
|
232 |
$this->_kernel_string = $ar_buf[1];
|
241 |
$this->_kernel_string = $ar_buf[1];
|
233 |
if (preg_match('/ SMP /', $strBuf)) {
|
242 |
if (preg_match('/ SMP /', $strBuf)) {
|
234 |
$this->_kernel_string .= ' (SMP)';
|
243 |
$this->_kernel_string .= ' (SMP)';
|
235 |
}
|
244 |
}
|
236 |
}
|
245 |
}
|
Line 239... |
Line 248... |
239 |
|
248 |
|
240 |
return $this->_kernel_string;
|
249 |
return $this->_kernel_string;
|
241 |
}
|
250 |
}
|
242 |
|
251 |
|
243 |
/**
|
252 |
/**
|
- |
|
253 |
* check OS type
|
- |
|
254 |
*/
|
- |
|
255 |
public function __construct($blockname = false)
|
- |
|
256 |
{
|
- |
|
257 |
parent::__construct($blockname);
|
- |
|
258 |
$this->_get_kernel_string();
|
- |
|
259 |
}
|
- |
|
260 |
|
- |
|
261 |
/**
|
244 |
* Machine
|
262 |
* Machine
|
245 |
*
|
263 |
*
|
246 |
* @return void
|
264 |
* @return void
|
247 |
*/
|
265 |
*/
|
248 |
private function _machine()
|
266 |
protected function _machine()
|
249 |
{
|
267 |
{
|
250 |
$machine_info = $this->_get_machine_info();
|
268 |
$machine_info = $this->_get_machine_info();
|
251 |
if (isset($machine_info['machine'])) {
|
269 |
if (isset($machine_info['machine'])) {
|
252 |
$machine = $machine_info['machine'];
|
270 |
$machine = $machine_info['machine'];
|
253 |
} else {
|
271 |
} else {
|
Line 277... |
Line 295... |
277 |
*
|
295 |
*
|
278 |
* @return void
|
296 |
* @return void
|
279 |
*/
|
297 |
*/
|
280 |
protected function _hostname()
|
298 |
protected function _hostname()
|
281 |
{
|
299 |
{
|
282 |
if (PSI_USE_VHOST) {
|
300 |
if (PSI_USE_VHOST && !defined('PSI_EMU_PORT')) {
|
283 |
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
|
301 |
if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
|
284 |
} else {
|
302 |
} else {
|
285 |
if (CommonFunctions::rfts('/proc/sys/kernel/hostname', $result, 1, 4096, PSI_DEBUG && (PSI_OS != 'Android'))) {
|
303 |
if (CommonFunctions::rfts('/proc/sys/kernel/hostname', $result, 1, 4096, PSI_DEBUG && (PSI_OS != 'Android'))) {
|
286 |
$result = trim($result);
|
304 |
$result = trim($result);
|
287 |
$ip = gethostbyname($result);
|
305 |
$ip = gethostbyname($result);
|
Line 297... |
Line 315... |
297 |
/**
|
315 |
/**
|
298 |
* Kernel Version
|
316 |
* Kernel Version
|
299 |
*
|
317 |
*
|
300 |
* @return void
|
318 |
* @return void
|
301 |
*/
|
319 |
*/
|
302 |
private function _kernel()
|
320 |
protected function _kernel()
|
303 |
{
|
321 |
{
|
304 |
if (($verBuf = $this->_get_kernel_string()) != "") {
|
322 |
if (($verBuf = $this->_get_kernel_string()) != "") {
|
305 |
$this->sys->setKernel($verBuf);
|
323 |
$this->sys->setKernel($verBuf);
|
306 |
}
|
324 |
}
|
307 |
}
|
325 |
}
|
Line 332... |
Line 350... |
332 |
$cpuvirt = $this->sys->getVirtualizer(); // previous info from _cpuinfo()
|
350 |
$cpuvirt = $this->sys->getVirtualizer(); // previous info from _cpuinfo()
|
333 |
|
351 |
|
334 |
$novm = true;
|
352 |
$novm = true;
|
335 |
// code based on src/basic/virt.c from systemd-detect-virt source code (https://github.com/systemd/systemd)
|
353 |
// code based on src/basic/virt.c from systemd-detect-virt source code (https://github.com/systemd/systemd)
|
336 |
|
354 |
|
337 |
// First, try to detect Oracle Virtualbox and Amazon EC2 Nitro, even if they use KVM, as well as Xen even if
|
355 |
// First, try to detect Oracle Virtualbox, Amazon EC2 Nitro and Parallels, even if they use KVM,
|
338 |
// it cloaks as Microsoft Hyper-V. Attempt to detect uml at this stage also since it runs as a user-process
|
356 |
// as well as Xen even if it cloaks as Microsoft Hyper-V. Attempt to detect uml at this stage also
|
339 |
// nested inside other VMs. Also check for Xen now, because Xen PV mode does not override CPUID when nested
|
357 |
// since it runs as a user-process nested inside other VMs. Also check for Xen now, because Xen PV
|
340 |
// inside another hypervisor.
|
358 |
// mode does not override CPUID when nested inside another hypervisor.
|
341 |
$machine_info = $this->_get_machine_info();
|
359 |
$machine_info = $this->_get_machine_info();
|
342 |
if (isset($machine_info['hypervisor'])) {
|
360 |
if (isset($machine_info['hypervisor'])) {
|
343 |
$hypervisor = $machine_info['hypervisor'];
|
361 |
$hypervisor = $machine_info['hypervisor'];
|
344 |
if (($hypervisor === 'oracle') || ($hypervisor === 'amazon') || ($hypervisor === 'xen')) {
|
362 |
if (($hypervisor === 'oracle') || ($hypervisor === 'amazon') || ($hypervisor === 'xen') || ($hypervisor === 'parallels')) {
|
345 |
$this->sys->setVirtualizer($hypervisor);
|
363 |
$this->sys->setVirtualizer($hypervisor);
|
346 |
$novm = false;
|
364 |
$novm = false;
|
347 |
}
|
365 |
}
|
348 |
}
|
366 |
}
|
349 |
|
367 |
|
Line 518... |
Line 536... |
518 |
* UpTime
|
536 |
* UpTime
|
519 |
* time the system is running
|
537 |
* time the system is running
|
520 |
*
|
538 |
*
|
521 |
* @return void
|
539 |
* @return void
|
522 |
*/
|
540 |
*/
|
523 |
protected function _uptime()
|
541 |
protected function _uptime($bufu = null)
|
524 |
{
|
542 |
{
|
525 |
if (CommonFunctions::rfts('/proc/uptime', $buf, 1, 4096, PSI_OS != 'Android')) {
|
543 |
if (CommonFunctions::rfts('/proc/uptime', $buf, 1, 4096, PSI_OS != 'Android')) {
|
526 |
$ar_buf = preg_split('/ /', $buf);
|
544 |
$ar_buf = preg_split('/ /', $buf);
|
527 |
$this->sys->setUptime(trim($ar_buf[0]));
|
545 |
$this->sys->setUptime(trim($ar_buf[0]));
|
528 |
} elseif (($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) {
|
546 |
} elseif (($this->_uptime !== null) || ($bufu !== null) || CommonFunctions::executeProgram('uptime', '', $bufu)) {
|
- |
|
547 |
if (($this->_uptime === null) && ($bufu !== null)) {
|
- |
|
548 |
$this->_uptime = $bufu;
|
- |
|
549 |
}
|
529 |
if (preg_match("/up (\d+) day[s]?,[ ]+(\d+):(\d+),/", $this->_uptime, $ar_buf)) {
|
550 |
if (preg_match("/up (\d+) day[s]?,[ ]+(\d+):(\d+),/", $this->_uptime, $ar_buf)) {
|
530 |
$min = $ar_buf[3];
|
551 |
$min = $ar_buf[3];
|
531 |
$hours = $ar_buf[2];
|
552 |
$hours = $ar_buf[2];
|
532 |
$days = $ar_buf[1];
|
553 |
$days = $ar_buf[1];
|
533 |
$this->sys->setUptime($days * 86400 + $hours * 3600 + $min * 60);
|
554 |
$this->sys->setUptime($days * 86400 + $hours * 3600 + $min * 60);
|
Line 537... |
Line 558... |
537 |
$this->sys->setUptime($days * 86400 + $min * 60);
|
558 |
$this->sys->setUptime($days * 86400 + $min * 60);
|
538 |
} elseif (preg_match("/up[ ]+(\d+):(\d+),/", $this->_uptime, $ar_buf)) {
|
559 |
} elseif (preg_match("/up[ ]+(\d+):(\d+),/", $this->_uptime, $ar_buf)) {
|
539 |
$min = $ar_buf[2];
|
560 |
$min = $ar_buf[2];
|
540 |
$hours = $ar_buf[1];
|
561 |
$hours = $ar_buf[1];
|
541 |
$this->sys->setUptime($hours * 3600 + $min * 60);
|
562 |
$this->sys->setUptime($hours * 3600 + $min * 60);
|
- |
|
563 |
} elseif (preg_match("/up[ ]+(\d+):(\d+):(\d+)/", $this->_uptime, $ar_buf)) {
|
- |
|
564 |
$sec = $ar_buf[3];
|
- |
|
565 |
$min = $ar_buf[2];
|
- |
|
566 |
$hours = $ar_buf[1];
|
- |
|
567 |
$this->sys->setUptime($hours * 3600 + $min * 60 + $sec);
|
542 |
} elseif (preg_match("/up[ ]+(\d+) min,/", $this->_uptime, $ar_buf)) {
|
568 |
} elseif (preg_match("/up[ ]+(\d+) min,/", $this->_uptime, $ar_buf)) {
|
543 |
$min = $ar_buf[1];
|
569 |
$min = $ar_buf[1];
|
544 |
$this->sys->setUptime($min * 60);
|
570 |
$this->sys->setUptime($min * 60);
|
- |
|
571 |
} elseif (preg_match("/up[ ]+(\d+) day[s]?,[ ]+(\d+) hour[s]?,[ ]+(\d+) minute[s]?/", $this->_uptime, $ar_buf)) {
|
- |
|
572 |
$min = $ar_buf[3];
|
- |
|
573 |
$hours = $ar_buf[2];
|
- |
|
574 |
$days = $ar_buf[1];
|
- |
|
575 |
$this->sys->setUptime($days * 86400 + $hours * 3600 + $min * 60);
|
545 |
}
|
576 |
}
|
546 |
}
|
577 |
}
|
547 |
}
|
578 |
}
|
548 |
|
579 |
|
549 |
/**
|
580 |
/**
|
550 |
* Processor Load
|
581 |
* Processor Load
|
551 |
* optionally create a loadbar
|
582 |
* optionally create a loadbar
|
552 |
*
|
583 |
*
|
553 |
* @return void
|
584 |
* @return void
|
554 |
*/
|
585 |
*/
|
555 |
protected function _loadavg()
|
586 |
protected function _loadavg($buf = null)
|
556 |
{
|
587 |
{
|
557 |
if (CommonFunctions::rfts('/proc/loadavg', $buf, 1, 4096, PSI_OS != 'Android')) {
|
588 |
if ((($buf !== null) || CommonFunctions::rfts('/proc/loadavg', $buf, 1, 4096, PSI_OS != 'Android')) && preg_match("/^\d/", trim($buf))) {
|
558 |
$result = preg_split("/\s/", $buf, 4);
|
589 |
$result = preg_split("/\s/", $buf, 4);
|
559 |
// don't need the extra values, only first three
|
590 |
// don't need the extra values, only first three
|
560 |
unset($result[3]);
|
591 |
unset($result[3]);
|
561 |
$this->sys->setLoad(implode(' ', $result));
|
592 |
$this->sys->setLoad(implode(' ', $result));
|
562 |
} elseif ((($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) && preg_match("/load average: (.*), (.*), (.*)$/", $this->_uptime, $ar_buf)) {
|
593 |
} elseif (($buf === null) && ((($this->_uptime !== null) || CommonFunctions::executeProgram('uptime', '', $this->_uptime)) && preg_match("/load average: (.*), (.*), (.*)$/", $this->_uptime, $ar_buf))) {
|
563 |
$this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]);
|
594 |
$this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]);
|
564 |
}
|
595 |
}
|
565 |
if (PSI_LOAD_BAR) {
|
596 |
if (PSI_LOAD_BAR) {
|
566 |
$this->sys->setLoadPercent($this->_parseProcStat('cpu'));
|
597 |
$this->sys->setLoadPercent($this->_parseProcStat('cpu'));
|
567 |
}
|
598 |
}
|
568 |
}
|
599 |
}
|
Line 639... |
Line 670... |
639 |
* CPU information
|
670 |
* CPU information
|
640 |
* All of the tags here are highly architecture dependant.
|
671 |
* All of the tags here are highly architecture dependant.
|
641 |
*
|
672 |
*
|
642 |
* @return void
|
673 |
* @return void
|
643 |
*/
|
674 |
*/
|
644 |
protected function _cpuinfo()
|
675 |
protected function _cpuinfo($bufr = null)
|
645 |
{
|
676 |
{
|
646 |
if (CommonFunctions::rfts('/proc/cpuinfo', $bufr)) {
|
677 |
if (($bufr !== null) || CommonFunctions::rfts('/proc/cpuinfo', $bufr)) {
|
647 |
|
- |
|
648 |
$cpulist = null;
|
678 |
$cpulist = null;
|
649 |
$raslist = null;
|
679 |
$raslist = null;
|
650 |
|
680 |
|
651 |
// sparc
|
681 |
// sparc
|
652 |
if (preg_match('/\nCpu(\d+)Bogo\s*:/i', $bufr)) {
|
682 |
if (preg_match('/\nCpu(\d+)Bogo\s*:/i', $bufr)) {
|
Line 701... |
Line 731... |
701 |
$_revi = $arrBuff1;
|
731 |
$_revi = $arrBuff1;
|
702 |
break;
|
732 |
break;
|
703 |
case 'cpu frequency':
|
733 |
case 'cpu frequency':
|
704 |
if (preg_match('/^(\d+)\s+Hz/i', $arrBuff1, $bufr2)) {
|
734 |
if (preg_match('/^(\d+)\s+Hz/i', $arrBuff1, $bufr2)) {
|
705 |
$_cpus = round($bufr2[1]/1000000);
|
735 |
$_cpus = round($bufr2[1]/1000000);
|
- |
|
736 |
} elseif (preg_match('/^(\d+)\s+MHz/i', $arrBuff1, $bufr2)) {
|
- |
|
737 |
$_cpus = $bufr2[1];
|
706 |
}
|
738 |
}
|
707 |
break;
|
739 |
break;
|
708 |
case 'system bus frequency':
|
740 |
case 'system bus frequency':
|
709 |
if (preg_match('/^(\d+)\s+Hz/i', $arrBuff1, $bufr2)) {
|
741 |
if (preg_match('/^(\d+)\s+Hz/i', $arrBuff1, $bufr2)) {
|
710 |
$_buss = round($bufr2[1]/1000000);
|
742 |
$_buss = round($bufr2[1]/1000000);
|
- |
|
743 |
} elseif (preg_match('/^(\d+)\s+MHz/i', $arrBuff1, $bufr2)) {
|
- |
|
744 |
$_buss = $bufr2[1];
|
711 |
}
|
745 |
}
|
712 |
break;
|
746 |
break;
|
713 |
case 'bogomips per cpu':
|
747 |
case 'bogomips per cpu':
|
714 |
$_bogo = round($arrBuff1);
|
748 |
$_bogo = round($arrBuff1);
|
715 |
break;
|
749 |
break;
|
Line 739... |
Line 773... |
739 |
if ((count($arrBuff) == 2) && (($arrBuff1 = trim($arrBuff[1])) !== '')) {
|
773 |
if ((count($arrBuff) == 2) && (($arrBuff1 = trim($arrBuff[1])) !== '')) {
|
740 |
switch (strtolower($arrBuff[0])) {
|
774 |
switch (strtolower($arrBuff[0])) {
|
741 |
case 'processor':
|
775 |
case 'processor':
|
742 |
$proc = $arrBuff1;
|
776 |
$proc = $arrBuff1;
|
743 |
if (is_numeric($proc)) {
|
777 |
if (is_numeric($proc)) {
|
744 |
if (($procname !== null) && (strlen($procname)>0)) {
|
778 |
if (($procname !== null) && (strlen($procname) > 0)) {
|
745 |
$dev->setModel($procname);
|
779 |
$dev->setModel($procname);
|
746 |
}
|
780 |
}
|
747 |
} else {
|
781 |
} else {
|
748 |
$procname = $proc;
|
782 |
$procname = $proc;
|
749 |
$dev->setModel($procname);
|
783 |
$dev->setModel($procname);
|
Line 753... |
Line 787... |
753 |
case 'cpu model':
|
787 |
case 'cpu model':
|
754 |
case 'cpu type':
|
788 |
case 'cpu type':
|
755 |
case 'cpu':
|
789 |
case 'cpu':
|
756 |
$dev->setModel($arrBuff1);
|
790 |
$dev->setModel($arrBuff1);
|
757 |
break;
|
791 |
break;
|
- |
|
792 |
case 'cpu frequency':
|
- |
|
793 |
if (preg_match('/^(\d+)\s+Hz/i', $arrBuff1, $bufr2)) {
|
- |
|
794 |
if (($tmpsp = round($bufr2[1]/1000000)) > 0) {
|
- |
|
795 |
$dev->setCpuSpeed($tmpsp);
|
- |
|
796 |
$speedset = true;
|
- |
|
797 |
}
|
- |
|
798 |
} elseif (preg_match('/^(\d+)\s+MHz/i', $arrBuff1, $bufr2)) {
|
- |
|
799 |
if ($bufr2[1] > 0) {
|
- |
|
800 |
$dev->setCpuSpeed($bufr2[1]);
|
- |
|
801 |
$speedset = true;
|
- |
|
802 |
}
|
- |
|
803 |
}
|
- |
|
804 |
break;
|
758 |
case 'cpu mhz':
|
805 |
case 'cpu mhz':
|
759 |
case 'clock':
|
806 |
case 'clock':
|
760 |
if ($arrBuff1 > 0) { // openSUSE fix
|
807 |
if ($arrBuff1 > 0) {
|
761 |
$dev->setCpuSpeed($arrBuff1);
|
808 |
$dev->setCpuSpeed($arrBuff1);
|
762 |
$speedset = true;
|
809 |
$speedset = true;
|
763 |
}
|
810 |
}
|
764 |
break;
|
811 |
break;
|
765 |
case 'cpu mhz static':
|
812 |
case 'cpu mhz static':
|
766 |
if ($arrBuff1 > 0) { // openSUSE fix
|
- |
|
767 |
$dev->setCpuSpeedMax($arrBuff1);
|
813 |
$dev->setCpuSpeedMax($arrBuff1);
|
768 |
}
|
- |
|
769 |
break;
|
814 |
break;
|
770 |
case 'cycle frequency [hz]':
|
815 |
case 'cycle frequency [hz]':
|
- |
|
816 |
if (($tmpsp = round($arrBuff1/1000000)) > 0) {
|
771 |
$dev->setCpuSpeed($arrBuff1 / 1000000);
|
817 |
$dev->setCpuSpeed($tmpsp);
|
772 |
$speedset = true;
|
818 |
$speedset = true;
|
- |
|
819 |
}
|
773 |
break;
|
820 |
break;
|
774 |
case 'cpu0clktck':
|
821 |
case 'cpu0clktck': // Linux sparc64
|
775 |
$dev->setCpuSpeed(hexdec($arrBuff1) / 1000000); // Linux sparc64
|
822 |
if (($tmpsp = round(hexdec($arrBuff1)/1000000)) > 0) {
|
- |
|
823 |
$dev->setCpuSpeed($tmpsp);
|
776 |
$speedset = true;
|
824 |
$speedset = true;
|
- |
|
825 |
}
|
777 |
break;
|
826 |
break;
|
778 |
case 'l3 cache':
|
827 |
case 'l3 cache':
|
779 |
case 'cache size':
|
828 |
case 'cache size':
|
780 |
$dev->setCache(trim(preg_replace("/[a-zA-Z]/", "", $arrBuff1)) * 1024);
|
829 |
$dev->setCache(trim(preg_replace("/[a-zA-Z]/", "", $arrBuff1)) * 1024);
|
781 |
break;
|
830 |
break;
|
Line 843... |
Line 892... |
843 |
}
|
892 |
}
|
844 |
}
|
893 |
}
|
845 |
// sparc64 specific code ends
|
894 |
// sparc64 specific code ends
|
846 |
|
895 |
|
847 |
// XScale detection code
|
896 |
// XScale detection code
|
848 |
if (($arch === "5TE") && ($dev->getBogomips() !== null)) {
|
897 |
if (($arch === "5TE") && (($bogo = $dev->getBogomips()) !== null) && ($bogo > 0)) {
|
849 |
$dev->setCpuSpeed($dev->getBogomips()); // BogoMIPS are not BogoMIPS on this CPU, it's the speed
|
898 |
$dev->setCpuSpeed($bogo); // BogoMIPS are not BogoMIPS on this CPU, it's the speed
|
850 |
$speedset = true;
|
899 |
$speedset = true;
|
851 |
$dev->setBogomips(null); // no BogoMIPS available, unset previously set BogoMIPS
|
900 |
$dev->setBogomips(null); // no BogoMIPS available, unset previously set BogoMIPS
|
852 |
}
|
901 |
}
|
853 |
|
902 |
|
854 |
if (($dev->getBusSpeed() == 0) && ($_buss !== null)) {
|
903 |
if (($dev->getBusSpeed() == 0) && ($_buss !== null)) {
|
855 |
$dev->setBusSpeed($_buss);
|
904 |
$dev->setBusSpeed($_buss);
|
856 |
}
|
905 |
}
|
857 |
if (($dev->getCpuSpeed() == 0) && ($_cpus !== null)) {
|
906 |
if (($dev->getCpuSpeed() == 0) && ($_cpus !== null) && ($_cpus > 0)) {
|
858 |
$dev->setCpuSpeed($_cpus);
|
907 |
$dev->setCpuSpeed($_cpus);
|
859 |
$speedset = true;
|
908 |
$speedset = true;
|
860 |
}
|
909 |
}
|
861 |
if (($dev->getBogomips() == 0) && ($_bogo !== null)) {
|
910 |
if (($dev->getBogomips() == 0) && ($_bogo !== null)) {
|
862 |
$dev->setBogomips($_bogo);
|
911 |
$dev->setBogomips($_bogo);
|
Line 871... |
Line 920... |
871 |
if ($proc !== null) {
|
920 |
if ($proc !== null) {
|
872 |
if (!is_numeric($proc)) {
|
921 |
if (!is_numeric($proc)) {
|
873 |
$proc = 0;
|
922 |
$proc = 0;
|
874 |
}
|
923 |
}
|
875 |
// variable speed processors specific code follows
|
924 |
// variable speed processors specific code follows
|
876 |
if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_cur_freq', $buf, 1, 4096, false)) {
|
925 |
if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_cur_freq', $buf, 1, 4096, false)
|
877 |
$dev->setCpuSpeed(trim($buf) / 1000);
|
926 |
|| CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/scaling_cur_freq', $buf, 1, 4096, false)) {
|
878 |
$speedset = true;
|
927 |
if (round(trim($buf)/1000) > 0) {
|
879 |
} elseif (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/scaling_cur_freq', $buf, 1, 4096, false)) {
|
- |
|
880 |
$dev->setCpuSpeed(trim($buf) / 1000);
|
928 |
$dev->setCpuSpeed(round(trim($buf)/1000));
|
881 |
$speedset = true;
|
929 |
$speedset = true;
|
882 |
}
|
930 |
}
|
883 |
if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_max_freq', $buf, 1, 4096, false)) {
|
- |
|
884 |
$dev->setCpuSpeedMax(trim($buf) / 1000);
|
- |
|
885 |
}
|
931 |
}
|
- |
|
932 |
if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_max_freq', $buf, 1, 4096, false)
|
- |
|
933 |
|| CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/scaling_max_freq', $buf, 1, 4096, false)) {
|
- |
|
934 |
$dev->setCpuSpeedMax(round(trim($buf)/1000));
|
- |
|
935 |
}
|
886 |
if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_min_freq', $buf, 1, 4096, false)) {
|
936 |
if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_min_freq', $buf, 1, 4096, false)
|
- |
|
937 |
|| CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/scaling_min_freq', $buf, 1, 4096, false)) {
|
887 |
$dev->setCpuSpeedMin(trim($buf) / 1000);
|
938 |
$dev->setCpuSpeedMin(round(trim($buf)/1000));
|
888 |
}
|
939 |
}
|
889 |
// variable speed processors specific code ends
|
940 |
// variable speed processors specific code ends
|
890 |
if (PSI_LOAD_BAR) {
|
941 |
if (PSI_LOAD_BAR) {
|
891 |
$dev->setLoad($this->_parseProcStat('cpu'.$proc));
|
942 |
$dev->setLoad($this->_parseProcStat('cpu'.$proc));
|
892 |
}
|
943 |
}
|
Line 899... |
Line 950... |
899 |
if (($arch !== null) && ($impl !== null) && ($part !== null)) {
|
950 |
if (($arch !== null) && ($impl !== null) && ($part !== null)) {
|
900 |
if (($impl === '0x41')
|
951 |
if (($impl === '0x41')
|
901 |
&& (($_hard === 'BCM2708') || ($_hard === 'BCM2835') || ($_hard === 'BCM2709') || ($_hard === 'BCM2836') || ($_hard === 'BCM2710') || ($_hard === 'BCM2837') || ($_hard === 'BCM2711') || ($_hard === 'BCM2838'))
|
952 |
&& (($_hard === 'BCM2708') || ($_hard === 'BCM2835') || ($_hard === 'BCM2709') || ($_hard === 'BCM2836') || ($_hard === 'BCM2710') || ($_hard === 'BCM2837') || ($_hard === 'BCM2711') || ($_hard === 'BCM2838'))
|
902 |
&& ($_revi !== null)) { // Raspberry Pi detection (instead of 'cat /proc/device-tree/model')
|
953 |
&& ($_revi !== null)) { // Raspberry Pi detection (instead of 'cat /proc/device-tree/model')
|
903 |
if ($raslist === null) $raslist = @parse_ini_file(PSI_APP_ROOT."/data/raspberry.ini", true);
|
954 |
if ($raslist === null) $raslist = @parse_ini_file(PSI_APP_ROOT."/data/raspberry.ini", true);
|
- |
|
955 |
$oldmach = $this->sys->getMachine();
|
- |
|
956 |
if (($oldmach !== '') && preg_match("/^raspberrypi rpi(,.+)/", $oldmach, $machbuf)) {
|
- |
|
957 |
$oldmachend = $machbuf[1];
|
- |
|
958 |
} else {
|
- |
|
959 |
$oldmachend = '';
|
- |
|
960 |
}
|
904 |
if ($raslist && !preg_match('/[^0-9a-f]/', $_revi)) {
|
961 |
if ($raslist && !preg_match('/[^0-9a-f]/', $_revi)) {
|
905 |
if (($revidec = hexdec($_revi)) & 0x800000) {
|
962 |
if (($revidec = hexdec($_revi)) & 0x800000) {
|
906 |
if ($this->sys->getMachine() === '') {
|
963 |
if (($oldmach === '') || ($oldmachend !== '')) {
|
907 |
$manufacturer = ($revidec >> 16) & 15;
|
964 |
$manufacturer = ($revidec >> 16) & 15;
|
908 |
if (isset($raslist['manufacturer'][$manufacturer])) {
|
965 |
if (isset($raslist['manufacturer'][$manufacturer])) {
|
909 |
$manuf = ' '.$raslist['manufacturer'][$manufacturer];
|
966 |
$manuf = ' '.$raslist['manufacturer'][$manufacturer];
|
910 |
} else {
|
967 |
} else {
|
911 |
$manuf = '';
|
968 |
$manuf = '';
|
912 |
}
|
969 |
}
|
913 |
$model = ($revidec >> 4) & 255;
|
970 |
$model = ($revidec >> 4) & 255;
|
914 |
if (isset($raslist['model'][$model])) {
|
971 |
if (isset($raslist['model'][$model])) {
|
915 |
$this->sys->setMachine('Raspberry Pi '.$raslist['model'][$model].' (PCB 1.'.($revidec & 15).$manuf.')');
|
972 |
$this->sys->setMachine('Raspberry Pi '.$raslist['model'][$model].' (PCB 1.'.($revidec & 15).$manuf.')'.$oldmachend);
|
916 |
} else {
|
973 |
} else {
|
917 |
$this->sys->setMachine('Raspberry Pi (PCB 1.'.($revidec & 15).$manuf.')');
|
974 |
$this->sys->setMachine('Raspberry Pi (PCB 1.'.($revidec & 15).$manuf.')'.$oldmachend);
|
918 |
}
|
975 |
}
|
919 |
}
|
976 |
}
|
920 |
} else {
|
977 |
} else {
|
921 |
if ($this->sys->getMachine() === '') {
|
978 |
if (($oldmach === '') || ($oldmachend !== '')) {
|
922 |
if (isset($raslist['old'][$revidec & 0x7fffff])) {
|
979 |
if (isset($raslist['old'][$revidec & 0x7fffff])) {
|
923 |
$this->sys->setMachine('Raspberry Pi '.$raslist['old'][$revidec & 0x7fffff]);
|
980 |
$this->sys->setMachine('Raspberry Pi '.$raslist['old'][$revidec & 0x7fffff].$oldmachend);
|
924 |
} else {
|
981 |
} else {
|
925 |
$this->sys->setMachine('Raspberry Pi');
|
982 |
$this->sys->setMachine('Raspberry Pi'.$oldmachend);
|
926 |
}
|
983 |
}
|
927 |
}
|
984 |
}
|
928 |
}
|
985 |
}
|
929 |
}
|
986 |
}
|
930 |
} elseif (($_hard !== null) && ($this->sys->getMachine() === '')) { // other ARM hardware
|
987 |
} elseif (($_hard !== null) && ($this->sys->getMachine() === '')) { // other ARM hardware
|
Line 1117... |
Line 1174... |
1117 |
/**
|
1174 |
/**
|
1118 |
* USB devices
|
1175 |
* USB devices
|
1119 |
*
|
1176 |
*
|
1120 |
* @return void
|
1177 |
* @return void
|
1121 |
*/
|
1178 |
*/
|
1122 |
protected function _usb()
|
1179 |
protected function _usb($bufu = null)
|
1123 |
{
|
1180 |
{
|
1124 |
$usbarray = array();
|
1181 |
$usbarray = array();
|
- |
|
1182 |
if ($nobufu = ($bufu === null)) {
|
1125 |
if (CommonFunctions::executeProgram('lsusb', (PSI_OS != 'Android')?'':'2>/dev/null', $bufr, PSI_DEBUG && (PSI_OS != 'Android'), 5) && ($bufr !== "")) {
|
1183 |
if (CommonFunctions::executeProgram('lsusb', (PSI_OS != 'Android')?'':'2>/dev/null', $bufr, PSI_DEBUG && (PSI_OS != 'Android'), 5) && ($bufr !== "")) {
|
1126 |
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
1184 |
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
1127 |
foreach ($bufe as $buf) {
|
1185 |
foreach ($bufe as $buf) {
|
1128 |
$device = preg_split("/ /", $buf, 7);
|
1186 |
$device = preg_split("/ /", $buf, 7);
|
1129 |
if (((isset($device[6]) && trim($device[6]) != "")) ||
|
1187 |
if (((isset($device[6]) && trim($device[6]) != "")) ||
|
1130 |
((isset($device[5]) && trim($device[5]) != ""))) {
|
1188 |
((isset($device[5]) && trim($device[5]) != ""))) {
|
1131 |
$usbid = intval($device[1]).'-'.intval(trim($device[3], ':')).' '.$device[5];
|
1189 |
$usbid = intval($device[1]).'-'.intval(trim($device[3], ':')).' '.$device[5];
|
1132 |
if ((isset($device[6]) && trim($device[6]) != "")) {
|
1190 |
if ((isset($device[6]) && trim($device[6]) != "")) {
|
1133 |
$usbarray[$usbid]['name'] = trim($device[6]);
|
1191 |
$usbarray[$usbid]['name'] = trim($device[6]);
|
1134 |
} else {
|
1192 |
} else {
|
1135 |
$usbarray[$usbid]['name'] = 'unknown';
|
1193 |
$usbarray[$usbid]['name'] = 'unknown';
|
- |
|
1194 |
}
|
1136 |
}
|
1195 |
}
|
1137 |
}
|
1196 |
}
|
1138 |
}
|
1197 |
}
|
1139 |
}
|
- |
|
1140 |
|
1198 |
|
1141 |
$usbdevices = CommonFunctions::findglob('/sys/bus/usb/devices/*/idProduct', GLOB_NOSORT);
|
1199 |
$usbdevices = CommonFunctions::findglob('/sys/bus/usb/devices/*/idProduct', GLOB_NOSORT);
|
1142 |
if (is_array($usbdevices) && (($total = count($usbdevices)) > 0)) {
|
1200 |
if (is_array($usbdevices) && (($total = count($usbdevices)) > 0)) {
|
1143 |
for ($i = 0; $i < $total; $i++) {
|
1201 |
for ($i = 0; $i < $total; $i++) {
|
1144 |
if (CommonFunctions::rfts($usbdevices[$i], $idproduct, 1, 4096, false) && (($idproduct=trim($idproduct)) != "")) { // is readable
|
1202 |
if (CommonFunctions::rfts($usbdevices[$i], $idproduct, 1, 4096, false) && (($idproduct=trim($idproduct)) != "")) { // is readable
|
1145 |
$busnum = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/busnum');
|
1203 |
$busnum = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/busnum');
|
1146 |
$devnum = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/devnum');
|
1204 |
$devnum = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/devnum');
|
1147 |
$idvendor = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/idVendor');
|
1205 |
$idvendor = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/idVendor');
|
1148 |
if (($busnum!==null) && ($devnum!==null) && ($idvendor!==null)) {
|
1206 |
if (($busnum!==null) && ($devnum!==null) && ($idvendor!==null)) {
|
1149 |
$usbid = intval($busnum).'-'.intval($devnum).' '.$idvendor.':'.$idproduct;
|
1207 |
$usbid = intval($busnum).'-'.intval($devnum).' '.$idvendor.':'.$idproduct;
|
1150 |
$manufacturer = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/manufacturer');
|
1208 |
$manufacturer = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/manufacturer');
|
1151 |
if ($manufacturer!==null) {
|
1209 |
if ($manufacturer!==null) {
|
1152 |
$usbarray[$usbid]['manufacturer'] = $manufacturer;
|
1210 |
$usbarray[$usbid]['manufacturer'] = $manufacturer;
|
1153 |
}
|
1211 |
}
|
1154 |
$product = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/product');
|
1212 |
$product = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/product');
|
1155 |
if ($product!==null) {
|
1213 |
if ($product!==null) {
|
1156 |
$usbarray[$usbid]['product'] = $product;
|
1214 |
$usbarray[$usbid]['product'] = $product;
|
1157 |
}
|
1215 |
}
|
1158 |
$speed = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/speed');
|
1216 |
$speed = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/speed');
|
1159 |
if ($product!==null) {
|
1217 |
if ($product!==null) {
|
1160 |
$usbarray[$usbid]['speed'] = $speed;
|
1218 |
$usbarray[$usbid]['speed'] = $speed;
|
1161 |
}
|
1219 |
}
|
1162 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
|
1220 |
if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
|
1163 |
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
|
1221 |
&& defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
|
1164 |
$serial = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/serial');
|
1222 |
$serial = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/serial');
|
1165 |
if (($serial!==null) && !preg_match('/\W/', $serial)) {
|
1223 |
if (($serial!==null) && !preg_match('/\W/', $serial)) {
|
1166 |
$usbarray[$usbid]['serial'] = $serial;
|
1224 |
$usbarray[$usbid]['serial'] = $serial;
|
- |
|
1225 |
}
|
1167 |
}
|
1226 |
}
|
1168 |
}
|
1227 |
}
|
1169 |
}
|
1228 |
}
|
1170 |
}
|
1229 |
}
|
1171 |
}
|
1230 |
}
|
1172 |
}
|
1231 |
}
|
1173 |
|
1232 |
|
1174 |
if ((count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/usb/devices', $bufr, 0, 4096, false)) { // usb-devices
|
1233 |
if (!$nobufu || ((count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/usb/devices', $bufu, 0, 4096, false))) { // usb-devices
|
1175 |
$devnum = -1;
|
1234 |
$devnum = -1;
|
1176 |
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
1235 |
$bufe = preg_split("/\n/", $bufu, -1, PREG_SPLIT_NO_EMPTY);
|
1177 |
foreach ($bufe as $buf) {
|
1236 |
foreach ($bufe as $buf) {
|
1178 |
if (preg_match('/^T/', $buf)) {
|
1237 |
if (preg_match('/^T/', $buf)) {
|
1179 |
$devnum++;
|
1238 |
$devnum++;
|
1180 |
if (preg_match('/\sSpd=([\d\.]+)/', $buf, $bufr)
|
1239 |
if (preg_match('/\sSpd=([\d\.]+)/', $buf, $bufr)
|
1181 |
&& isset($bufr[1]) && ($bufr[1]!=="")) {
|
1240 |
&& isset($bufr[1]) && ($bufr[1]!=="")) {
|
Line 1200... |
Line 1259... |
1200 |
}
|
1259 |
}
|
1201 |
}
|
1260 |
}
|
1202 |
}
|
1261 |
}
|
1203 |
}
|
1262 |
}
|
1204 |
|
1263 |
|
1205 |
if ((count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/input/devices', $bufr, 0, 4096, false)) {
|
1264 |
if ($nobufu && (count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/input/devices', $bufr, 0, 4096, false)) {
|
1206 |
$devnam = "unknown";
|
1265 |
$devnam = "unknown";
|
1207 |
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
1266 |
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
1208 |
foreach ($bufe as $buf) {
|
1267 |
foreach ($bufe as $buf) {
|
1209 |
if (preg_match('/^I:\s+(.+)/', $buf, $bufr)
|
1268 |
if (preg_match('/^I:\s+(.+)/', $buf, $bufr)
|
1210 |
&& isset($bufr[1]) && (trim($bufr[1])!=="")) {
|
1269 |
&& isset($bufr[1]) && (trim($bufr[1])!=="")) {
|
Line 1373... |
Line 1432... |
1373 |
* Network devices
|
1432 |
* Network devices
|
1374 |
* includes also rx/tx bytes
|
1433 |
* includes also rx/tx bytes
|
1375 |
*
|
1434 |
*
|
1376 |
* @return void
|
1435 |
* @return void
|
1377 |
*/
|
1436 |
*/
|
1378 |
protected function _network()
|
1437 |
protected function _network($bufr = null)
|
1379 |
{
|
1438 |
{
|
1380 |
if (CommonFunctions::rfts('/proc/net/dev', $bufr, 0, 4096, PSI_DEBUG)) {
|
1439 |
if (($bufr === null) && CommonFunctions::rfts('/proc/net/dev', $bufr, 0, 4096, PSI_DEBUG)) {
|
1381 |
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
1440 |
$bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
1382 |
foreach ($bufe as $buf) {
|
1441 |
foreach ($bufe as $buf) {
|
1383 |
if (preg_match('/:/', $buf)) {
|
1442 |
if (preg_match('/:/', $buf)) {
|
1384 |
list($dev_name, $stats_list) = preg_split('/:/', $buf, 2);
|
1443 |
list($dev_name, $stats_list) = preg_split('/:/', $buf, 2);
|
1385 |
$stats = preg_split('/\s+/', trim($stats_list));
|
1444 |
$stats = preg_split('/\s+/', trim($stats_list));
|
Line 1418... |
Line 1477... |
1418 |
} elseif ((preg_match('/^\s+inet\saddr:(\S+)/i', $buf2, $ar_buf2)
|
1477 |
} elseif ((preg_match('/^\s+inet\saddr:(\S+)/i', $buf2, $ar_buf2)
|
1419 |
|| preg_match('/^\s+inet\s+(\S+)\s+netmask/i', $buf2, $ar_buf2)
|
1478 |
|| preg_match('/^\s+inet\s+(\S+)\s+netmask/i', $buf2, $ar_buf2)
|
1420 |
|| preg_match('/^'.trim($dev_name).':\s+ip\s+(\S+)\s+mask/i', $buf2, $ar_buf2)
|
1479 |
|| preg_match('/^'.trim($dev_name).':\s+ip\s+(\S+)\s+mask/i', $buf2, $ar_buf2)
|
1421 |
|| preg_match('/^\s+inet6\saddr:\s([^\/\s]+)(.+)\s+Scope:[GH]/i', $buf2, $ar_buf2)
|
1480 |
|| preg_match('/^\s+inet6\saddr:\s([^\/\s]+)(.+)\s+Scope:[GH]/i', $buf2, $ar_buf2)
|
1422 |
|| preg_match('/^\s+inet6\s+(\S+)\s+prefixlen(.+)((<global>)|(<host>))/i', $buf2, $ar_buf2)
|
1481 |
|| preg_match('/^\s+inet6\s+(\S+)\s+prefixlen(.+)((<global>)|(<host>))/i', $buf2, $ar_buf2)
|
1423 |
|| preg_match('/^\s+inet6?\s+([^\/\s]+).*\s+scope\s((global)|(host))/i', $buf2, $ar_buf2))
|
1482 |
|| preg_match('/^\s+inet6?\s+([^\/\s]+).*\s+scope\s((global)|(host))/i', $buf2, $ar_buf2)
|
- |
|
1483 |
|| preg_match('/^\s+inet\saddr6:\s+(\S+)\s+prefixlen(.+)/i', $buf2, $ar_buf2))
|
1424 |
&& ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1])) {
|
1484 |
&& ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1])) {
|
1425 |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1]));
|
1485 |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1]));
|
1426 |
}
|
1486 |
}
|
1427 |
}
|
1487 |
}
|
1428 |
}
|
1488 |
}
|
Line 1445... |
Line 1505... |
1445 |
}
|
1505 |
}
|
1446 |
}
|
1506 |
}
|
1447 |
$this->sys->setNetDevices($dev);
|
1507 |
$this->sys->setNetDevices($dev);
|
1448 |
}
|
1508 |
}
|
1449 |
}
|
1509 |
}
|
1450 |
} elseif (CommonFunctions::executeProgram('ip', 'addr show', $bufr, PSI_DEBUG) && ($bufr!="")) {
|
1510 |
} elseif (($bufr === null) && CommonFunctions::executeProgram('ip', 'addr show', $bufr, PSI_DEBUG) && ($bufr!="")) {
|
1451 |
$lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
1511 |
$lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
1452 |
$was = false;
|
1512 |
$was = false;
|
1453 |
$macaddr = "";
|
1513 |
$macaddr = "";
|
1454 |
$speedinfo = "";
|
1514 |
$speedinfo = "";
|
1455 |
$dev = null;
|
1515 |
$dev = null;
|
Line 1524... |
Line 1584... |
1524 |
if ($speedinfo != "") {
|
1584 |
if ($speedinfo != "") {
|
1525 |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$speedinfo);
|
1585 |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$speedinfo);
|
1526 |
}
|
1586 |
}
|
1527 |
$this->sys->setNetDevices($dev);
|
1587 |
$this->sys->setNetDevices($dev);
|
1528 |
}
|
1588 |
}
|
1529 |
} elseif (CommonFunctions::executeProgram('ifconfig', '-a', $bufr, PSI_DEBUG)) {
|
1589 |
} elseif (($bufr !== null) || CommonFunctions::executeProgram('ifconfig', '-a', $bufr, PSI_DEBUG)) {
|
1530 |
$lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
1590 |
$lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
|
1531 |
$was = false;
|
1591 |
$was = false;
|
1532 |
$errors = 0;
|
1592 |
$errors = 0;
|
1533 |
$drops = 0;
|
1593 |
$drops = 0;
|
1534 |
$macaddr = "";
|
1594 |
$macaddr = "";
|
Line 1615... |
Line 1675... |
1615 |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
|
1675 |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
|
1616 |
}
|
1676 |
}
|
1617 |
} elseif ((preg_match('/^\s+inet\saddr:(\S+)/i', $line, $ar_buf2)
|
1677 |
} elseif ((preg_match('/^\s+inet\saddr:(\S+)/i', $line, $ar_buf2)
|
1618 |
|| preg_match('/^\s+inet\s+(\S+)\s+netmask/i', $line, $ar_buf2)
|
1678 |
|| preg_match('/^\s+inet\s+(\S+)\s+netmask/i', $line, $ar_buf2)
|
1619 |
|| preg_match('/^\s+inet6\saddr:\s([^\/\s]+)(.+)\s+Scope:[GH]/i', $line, $ar_buf2)
|
1679 |
|| preg_match('/^\s+inet6\saddr:\s([^\/\s]+)(.+)\s+Scope:[GH]/i', $line, $ar_buf2)
|
1620 |
|| preg_match('/^\s+inet6\s+(\S+)\s+prefixlen(.+)((<global>)|(<host>))/i', $line, $ar_buf2))
|
1680 |
|| preg_match('/^\s+inet6\s+(\S+)\s+prefixlen(.+)((<global>)|(<host>))/i', $line, $ar_buf2)
|
- |
|
1681 |
|| preg_match('/^\s+inet\saddr6:\s+(\S+)\s+prefixlen(.+)/i', $line, $ar_buf2))
|
1621 |
&& ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1])) {
|
1682 |
&& ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1])) {
|
1622 |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1]));
|
1683 |
$dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1]));
|
1623 |
}
|
1684 |
}
|
1624 |
}
|
1685 |
}
|
1625 |
}
|
1686 |
}
|
Line 1642... |
Line 1703... |
1642 |
/**
|
1703 |
/**
|
1643 |
* Physical memory information and Swap Space information
|
1704 |
* Physical memory information and Swap Space information
|
1644 |
*
|
1705 |
*
|
1645 |
* @return void
|
1706 |
* @return void
|
1646 |
*/
|
1707 |
*/
|
1647 |
protected function _memory()
|
1708 |
protected function _memory($mbuf = null, $sbuf = null)
|
1648 |
{
|
1709 |
{
|
1649 |
if (CommonFunctions::rfts('/proc/meminfo', $mbuf)) {
|
1710 |
if (($mbuf !== null) || CommonFunctions::rfts('/proc/meminfo', $mbuf)) {
|
1650 |
$swaptotal = null;
|
1711 |
$swaptotal = null;
|
1651 |
$swapfree = null;
|
1712 |
$swapfree = null;
|
1652 |
$bufe = preg_split("/\n/", $mbuf, -1, PREG_SPLIT_NO_EMPTY);
|
1713 |
$bufe = preg_split("/\n/", $mbuf, -1, PREG_SPLIT_NO_EMPTY);
|
1653 |
foreach ($bufe as $buf) {
|
1714 |
foreach ($bufe as $buf) {
|
1654 |
if (preg_match('/^MemTotal:\s+(\d+)\s*kB/i', $buf, $ar_buf)) {
|
1715 |
if (preg_match('/^MemTotal:\s+(\d+)\s*kB/i', $buf, $ar_buf)) {
|
Line 1668... |
Line 1729... |
1668 |
$this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
|
1729 |
$this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
|
1669 |
// values for splitting memory usage
|
1730 |
// values for splitting memory usage
|
1670 |
if (($this->sys->getMemCache() !== null) && ($this->sys->getMemBuffer() !== null)) {
|
1731 |
if (($this->sys->getMemCache() !== null) && ($this->sys->getMemBuffer() !== null)) {
|
1671 |
$this->sys->setMemApplication($this->sys->getMemUsed() - $this->sys->getMemCache() - $this->sys->getMemBuffer());
|
1732 |
$this->sys->setMemApplication($this->sys->getMemUsed() - $this->sys->getMemCache() - $this->sys->getMemBuffer());
|
1672 |
}
|
1733 |
}
|
1673 |
if (CommonFunctions::rfts('/proc/swaps', $sbuf, 0, 4096, false)) {
|
1734 |
if (($sbuf !== null) || CommonFunctions::rfts('/proc/swaps', $sbuf, 0, 4096, false)) {
|
1674 |
$swaps = preg_split("/\n/", $sbuf, -1, PREG_SPLIT_NO_EMPTY);
|
1735 |
$swaps = preg_split("/\n/", $sbuf, -1, PREG_SPLIT_NO_EMPTY);
|
1675 |
unset($swaps[0]);
|
1736 |
unset($swaps[0]);
|
1676 |
foreach ($swaps as $swap) {
|
1737 |
foreach ($swaps as $swap) {
|
1677 |
$ar_buf = preg_split('/\s+/', $swap, 5);
|
1738 |
$ar_buf = preg_split('/\s+/', $swap, 5);
|
1678 |
$dev = new DiskDevice();
|
1739 |
$dev = new DiskDevice();
|
Line 1697... |
Line 1758... |
1697 |
/**
|
1758 |
/**
|
1698 |
* filesystem information
|
1759 |
* filesystem information
|
1699 |
*
|
1760 |
*
|
1700 |
* @return void
|
1761 |
* @return void
|
1701 |
*/
|
1762 |
*/
|
1702 |
private function _filesystems()
|
1763 |
protected function _filesystems()
|
1703 |
{
|
1764 |
{
|
1704 |
$df_args = "";
|
1765 |
$df_args = "";
|
1705 |
$hideFstypes = array();
|
1766 |
$hideFstypes = array();
|
1706 |
if (defined('PSI_HIDE_FS_TYPES') && is_string(PSI_HIDE_FS_TYPES)) {
|
1767 |
if (defined('PSI_HIDE_FS_TYPES') && is_string(PSI_HIDE_FS_TYPES)) {
|
1707 |
if (preg_match(ARRAY_EXP, PSI_HIDE_FS_TYPES)) {
|
1768 |
if (preg_match(ARRAY_EXP, PSI_HIDE_FS_TYPES)) {
|
Line 2037... |
Line 2098... |
2037 |
$this->sys->setDistribution('Debian');
|
2098 |
$this->sys->setDistribution('Debian');
|
2038 |
} else {
|
2099 |
} else {
|
2039 |
$this->sys->setDistribution(trim($buf));
|
2100 |
$this->sys->setDistribution(trim($buf));
|
2040 |
}
|
2101 |
}
|
2041 |
}
|
2102 |
}
|
- |
|
2103 |
} elseif (CommonFunctions::fileexists($filename="/etc/slackware-version")) {
|
- |
|
2104 |
if (!CommonFunctions::rfts($filename, $buf, 1, 4096, false)) {
|
- |
|
2105 |
$buf = "";
|
- |
|
2106 |
}
|
- |
|
2107 |
if (isset($list['Slackware']['Image'])) {
|
- |
|
2108 |
$this->sys->setDistributionIcon($list['Slackware']['Image']);
|
- |
|
2109 |
}
|
- |
|
2110 |
if (isset($list['Slackware']['Name'])) {
|
- |
|
2111 |
if (($buf === null) || (trim($buf) == "")) {
|
- |
|
2112 |
$this->sys->setDistribution($list['Slackware']['Name']);
|
- |
|
2113 |
} else {
|
- |
|
2114 |
$this->sys->setDistribution($list['Slackware']['Name']." ".trim($buf));
|
- |
|
2115 |
}
|
- |
|
2116 |
} else {
|
- |
|
2117 |
if (($buf === null) || (trim($buf) == "")) {
|
- |
|
2118 |
$this->sys->setDistribution('Slackware');
|
- |
|
2119 |
} else {
|
- |
|
2120 |
$this->sys->setDistribution(trim($buf));
|
- |
|
2121 |
}
|
- |
|
2122 |
}
|
2042 |
} elseif (CommonFunctions::fileexists($filename="/etc/config/uLinux.conf")
|
2123 |
} elseif (CommonFunctions::fileexists($filename="/etc/config/uLinux.conf")
|
2043 |
&& CommonFunctions::rfts($filename, $buf, 0, 4096, false)
|
2124 |
&& CommonFunctions::rfts($filename, $buf, 0, 4096, false)
|
2044 |
&& preg_match("/^Rsync\sModel\s*=\s*QNAP/m", $buf)
|
2125 |
&& preg_match("/^Rsync\sModel\s*=\s*QNAP/m", $buf)
|
2045 |
&& preg_match("/^Version\s*=\s*([\d\.]+)\r?\nBuild\sNumber\s*=\s*(\S+)/m", $buf, $ver_buf)) {
|
2126 |
&& preg_match("/^Version\s*=\s*([\d\.]+)\r?\nBuild\sNumber\s*=\s*(\S+)/m", $buf, $ver_buf)) {
|
2046 |
$buf = $ver_buf[1]."-".$ver_buf[2];
|
2127 |
$buf = $ver_buf[1]."-".$ver_buf[2];
|