Subversion Repositories ALCASAR

Rev

Rev 3179 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3179 Rev 3287
Line 45... Line 45...
45
     * Array of info from Bios.
45
     * Array of info from Bios.
46
     */
46
     */
47
    private $_machine_info = null;
47
    private $_machine_info = null;
48
 
48
 
49
    /**
49
    /**
50
     * Array of info from dmesg.
50
     * Content of dmesg file.
51
     */
51
     */
52
    private $_dmesg_info = null;
52
    private $_dmesg_f = null;
-
 
53
 
-
 
54
    /**
-
 
55
     * Result of executing dmesg command.
-
 
56
     */
-
 
57
    private $_dmesg_c = null;
53
 
58
 
54
    /**
59
    /**
55
     * Result of systemd-detect-virt.
60
     * Result of systemd-detect-virt.
56
     */
61
     */
57
    private $system_detect_virt = null;
62
    private $system_detect_virt = null;
58
 
63
 
59
     /**
64
     /**
60
      * Get info from dmesg
65
      * Read contents of the dmesg file.
61
      *
66
      *
62
      * @return array
67
      * @return string
63
      */
68
      */
64
    private function _get_dmesg_info()
69
    private function _get_dmesg_f()
65
    {
70
    {
66
        if ($this->_dmesg_info === null) {
71
        if ($this->_dmesg_f === null) {
67
            $this->_dmesg_info = array();
72
            $this->_dmesg_f = "";
68
            if (CommonFunctions::rfts('/var/log/dmesg', $result, 0, 4096, false)) {
73
            if (CommonFunctions::rfts('/var/log/dmesg', $result, 0, 4096, false)) {
69
                if (preg_match('/^[\s\[\]\.\d]*DMI:\s*(.+)/m', $result, $ar_buf)) {
-
 
70
                    $this->_dmesg_info['dmi'] = trim($ar_buf[1]);
74
                $this->_dmesg_f = trim($result);
71
                }
-
 
72
                if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null) && preg_match('/^[\s\[\]\.\d]*Hypervisor detected:\s*(.+)/m', $result, $ar_buf)) {
-
 
73
                    $this->_dmesg_info['hypervisor'] = trim($ar_buf[1]);
-
 
74
                }
-
 
75
            }
75
            }
76
            if ((count($this->_dmesg_info) < ((defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null))?2:1)) && CommonFunctions::executeProgram('dmesg', '', $result, false)) {
-
 
-
 
76
        }
-
 
77
 
77
                if (!isset($this->_dmesg_info['dmi']) && preg_match('/^[\s\[\]\.\d]*DMI:\s*(.+)/m', $result, $ar_buf)) {
78
        return $this->_dmesg_f;
-
 
79
    }
-
 
80
 
-
 
81
     /**
78
                    $this->_dmesg_info['dmi'] = trim($ar_buf[1]);
82
      * Save output of the dmesg command.
-
 
83
      *
79
                }
84
      * @return string
-
 
85
      */
80
                if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null) && !isset($this->_dmesg_info['hypervisor']) && preg_match('/^[\s\[\]\.\d]*Hypervisor detected:\s*(.+)/m', $result, $ar_buf)) {
86
    private function _get_dmesg_c()
-
 
87
    {
81
                    $this->_dmesg_info['hypervisor'] = trim($ar_buf[1]);
88
        if ($this->_dmesg_c === null) {
82
                }
89
            $this->_dmesg_c = "";
-
 
90
            if (CommonFunctions::executeProgram('dmesg', '', $result, false)) {
-
 
91
                $this->_dmesg_c = trim($result);
83
            }
92
            }
84
        }
93
        }
85
 
94
 
86
        return $this->_dmesg_info;
95
        return $this->_dmesg_c;
87
    }
96
    }
88
 
97
 
89
    /**
98
    /**
90
     * Get machine info
99
     * Get machine info
91
     *
100
     *
Line 99... Line 108...
99
                if (CommonFunctions::executeProgram('systemd-detect-virt', '-v', $resultv, false)) {
108
                if (CommonFunctions::executeProgram('systemd-detect-virt', '-v', $resultv, false)) {
100
                    $this->system_detect_virt = $resultv;
109
                    $this->system_detect_virt = $resultv;
101
                }
110
                }
102
            }
111
            }
103
            $vendor_array = array();
112
            $vendor_array = array();
104
            if ((($dmesg = $this->_get_dmesg_info()) !== null) && isset($dmesg['dmi'])) {
113
            if (((($dmesg = $this->_get_dmesg_f()) !== null) && preg_match('/^[\s\[\]\.\d]*DMI:\s*(.+)/m', $dmesg, $ar_buf)) ||
-
 
114
                ((($dmesg = $this->_get_dmesg_c()) !== null) && preg_match('/^[\s\[\]\.\d]*DMI:\s*(.+)/m', $dmesg, $ar_buf))) {
105
                $this->_machine_info['machine'] = $dmesg['dmi'];
115
                $this->_machine_info['machine'] = trim($ar_buf[1]);
106
                if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null)) {
116
                if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null)) {
107
                    /* Test this before sys_vendor to detect KVM over QEMU */
117
                    /* Test this before sys_vendor to detect KVM over QEMU */
108
                    if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/product_name', $buf, 1, 4096, false) && (trim($buf)!="")) {
118
                    if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/product_name', $buf, 1, 4096, false) && (trim($buf)!="")) {
109
                        $vendor_array[] = $product_name = trim($buf);
119
                        $vendor_array[] = $product_name = trim($buf);
110
                    } else {
120
                    } else {
Line 118... Line 128...
118
                            $vendor_array[] = trim($buf)." ".$product_name;
128
                            $vendor_array[] = trim($buf)." ".$product_name;
119
                        } else {
129
                        } else {
120
                            $vendor_array[] = trim($buf);
130
                            $vendor_array[] = trim($buf);
121
                        }
131
                        }
122
                    } else {
132
                    } else {
123
                        $vendor_array[] = $dmesg['dmi'];
133
                        $vendor_array[] = $this->_machine_info['machine'];
124
                    }
134
                    }
125
                    if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/bios_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
135
                    if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/bios_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
126
                        $vendor_array[] = trim($buf);
136
                        $vendor_array[] = trim($buf);
127
                    }
137
                    }
128
                    if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/product_version', $buf, 1, 4096, false) && (trim($buf)!="")) {
138
                    if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/product_version', $buf, 1, 4096, false) && (trim($buf)!="")) {
Line 214... Line 224...
214
     */
224
     */
215
    private function _get_kernel_string()
225
    private function _get_kernel_string()
216
    {
226
    {
217
        if ($this->_kernel_string === null) {
227
        if ($this->_kernel_string === null) {
218
            $this->_kernel_string = "";
228
            $this->_kernel_string = "";
219
            if ($this->sys->getOS() == 'SSH') {
229
            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
            }
-
 
226
            if ((CommonFunctions::executeProgram($uname="uptrack-uname", '-r', $strBuf, false) && ($strBuf !== '')) || // show effective kernel if ksplice uptrack is installed
230
                if ((CommonFunctions::executeProgram($uname="uptrack-uname", '-r', $strBuf, false) && ($strBuf !== '')) || // show effective kernel if ksplice uptrack is installed
227
                (CommonFunctions::executeProgram($uname="uname", '-r', $strBuf, PSI_DEBUG) && ($strBuf !== ''))) {
231
                    (CommonFunctions::executeProgram($uname="uname", '-r', $strBuf, PSI_DEBUG) && ($strBuf !== ''))) {
228
                $this->_kernel_string = $strBuf;
232
                    $this->_kernel_string = $strBuf;
229
                if (CommonFunctions::executeProgram($uname, '-v', $strBuf, PSI_DEBUG) && ($strBuf !== '')) {
233
                    if (CommonFunctions::executeProgram($uname, '-v', $strBuf, PSI_DEBUG) && ($strBuf !== '')) {
230
                    if (preg_match('/ SMP /', $strBuf)) {
234
                        if (preg_match('/ SMP /', $strBuf)) {
231
                        $this->_kernel_string .= ' (SMP)';
235
                            $this->_kernel_string .= ' (SMP)';
232
                    }
236
                        }
233
                }
237
                    }
234
                if (CommonFunctions::executeProgram($uname, '-m', $strBuf, PSI_DEBUG) && ($strBuf !== '')) {
238
                    if (CommonFunctions::executeProgram($uname, '-m', $strBuf, PSI_DEBUG) && ($strBuf !== '')) {
235
                    $this->_kernel_string .= ' '.$strBuf;
239
                        $this->_kernel_string .= ' '.$strBuf;
236
                }
240
                    }
237
            } elseif (CommonFunctions::rfts('/proc/version', $strBuf, 1)) {
241
                } elseif (CommonFunctions::rfts('/proc/version', $strBuf, 1)) {
238
                if (preg_match('/\/Hurd-([^\)]+)/', $strBuf, $ar_buf)) {
242
                    if (preg_match('/\/Hurd-([^\)]+)/', $strBuf, $ar_buf)) {
239
                    $this->_kernel_string = $ar_buf[1];
243
                        $this->_kernel_string = $ar_buf[1];
240
                } elseif (preg_match('/version\s+(\S+)/', $strBuf, $ar_buf)) {
244
                    } elseif (preg_match('/version\s+(\S+)/', $strBuf, $ar_buf)) {
241
                    $this->_kernel_string = $ar_buf[1];
245
                        $this->_kernel_string = $ar_buf[1];
242
                    if (preg_match('/ SMP /', $strBuf)) {
246
                        if (preg_match('/ SMP /', $strBuf)) {
243
                        $this->_kernel_string .= ' (SMP)';
247
                            $this->_kernel_string .= ' (SMP)';
-
 
248
                        }
244
                    }
249
                    }
245
                }
250
                }
246
            }
251
            }
247
        }
252
        }
248
 
253
 
Line 253... Line 258...
253
     * check OS type
258
     * check OS type
254
     */
259
     */
255
    public function __construct($blockname = false)
260
    public function __construct($blockname = false)
256
    {
261
    {
257
        parent::__construct($blockname);
262
        parent::__construct($blockname);
-
 
263
 
-
 
264
        if (($this->sys->getOS() == 'SSH') && CommonFunctions::executeProgram('uname', '-s', $strBuf, false) && ($strBuf !== '')) {
258
        $this->_get_kernel_string();
265
            $this->sys->setOS($strBuf);
-
 
266
        }
259
    }
267
    }
260
 
268
 
261
    /**
269
    /**
262
     * Machine
270
     * Machine
263
     *
271
     *
Line 302... Line 310...
302
        } else {
310
        } else {
303
            if (CommonFunctions::rfts('/proc/sys/kernel/hostname', $result, 1, 4096, PSI_DEBUG && (PSI_OS != 'Android'))) {
311
            if (CommonFunctions::rfts('/proc/sys/kernel/hostname', $result, 1, 4096, PSI_DEBUG && (PSI_OS != 'Android'))) {
304
                $result = trim($result);
312
                $result = trim($result);
305
                $ip = gethostbyname($result);
313
                $ip = gethostbyname($result);
306
                if ($ip != $result) {
314
                if ($ip != $result) {
307
                    $this->sys->setHostname(gethostbyaddr($ip));
315
                    $this->sys->setHostname(trim(gethostbyaddr($ip), "."));
308
                }
316
                }
309
            } elseif (CommonFunctions::executeProgram('hostname', '', $ret, false)) {
317
            } elseif (CommonFunctions::executeProgram('hostname', '', $ret, false)) {
310
                $this->sys->setHostname($ret);
318
                $this->sys->setHostname($ret);
311
            } elseif (CommonFunctions::executeProgram('uname', '-n', $ret, false)) {
319
            } elseif (CommonFunctions::executeProgram('uname', '-n', $ret, false)) {
312
                $this->sys->setHostname($ret);
320
                $this->sys->setHostname($ret);
Line 462... Line 470...
462
                }
470
                }
463
                $novm = false;
471
                $novm = false;
464
            }
472
            }
465
 
473
 
466
            // Additional tests outside of the systemd-detect-virt source code
474
            // Additional tests outside of the systemd-detect-virt source code
-
 
475
            if ($novm && (
467
            if ($novm && (($dmesg = $this->_get_dmesg_info()) !== null) && isset($dmesg['hypervisor'])) {
476
                ((($dmesg = $this->_get_dmesg_f()) !== null) && preg_match('/^[\s\[\]\.\d]*Hypervisor detected:\s*(.+)/m', $dmesg, $ar_buf)) ||
-
 
477
                ((($dmesg = $this->_get_dmesg_c()) !== null) && preg_match('/^[\s\[\]\.\d]*Hypervisor detected:\s*(.+)/m', $dmesg, $ar_buf)))) {
468
                switch ($dmesg['hypervisor']) {
478
                switch (trim($ar_buf[1])) {
469
                case 'VMware':
479
                case 'VMware':
470
                    $this->sys->setVirtualizer('vmware'); // VMware
480
                    $this->sys->setVirtualizer('vmware'); // VMware
471
                    $novm = false;
481
                    $novm = false;
472
                    break;
482
                    break;
473
                case 'KVM':
483
                case 'KVM':
Line 713... Line 723...
713
            $_revi = null;
723
            $_revi = null;
714
            $_cpus = null;
724
            $_cpus = null;
715
            $_buss = null;
725
            $_buss = null;
716
            $_bogo = null;
726
            $_bogo = null;
717
            $_vend = null;
727
            $_vend = null;
-
 
728
            $_system = null;
718
            $procname = null;
729
            $procname = null;
719
            foreach ($processors as $processor) if (!preg_match('/^\s*processor\s*:/mi', $processor)) {
730
            foreach ($processors as $processor) if (!preg_match('/^\s*processor\s*:/mi', $processor)) {
720
                $details = preg_split("/\n/", $processor, -1, PREG_SPLIT_NO_EMPTY);
731
                $details = preg_split("/\n/", $processor, -1, PREG_SPLIT_NO_EMPTY);
721
                foreach ($details as $detail) {
732
                foreach ($details as $detail) {
722
                    $arrBuff = preg_split('/\s*:\s*/', trim($detail));
-
 
723
                    if ((count($arrBuff) == 2) && (($arrBuff1 = trim($arrBuff[1])) !== '')) {
733
                    if (preg_match('/^([^:]+):(.+)$/', trim($detail) , $arrBuff) && (($arrBuff2 = trim($arrBuff[2])) !== '')) {
724
                        switch (strtolower($arrBuff[0])) {
734
                        switch (strtolower(trim($arrBuff[1]))) {
725
                        case 'cpu architecture':
735
                        case 'cpu architecture':
726
                            $_arch = $arrBuff1;
736
                            $_arch = $arrBuff2;
727
                            break;
737
                            break;
728
                        case 'cpu implementer':
738
                        case 'cpu implementer':
729
                            $_impl = $arrBuff1;
739
                            $_impl = $arrBuff2;
730
                            break;
740
                            break;
731
                        case 'cpu part':
741
                        case 'cpu part':
732
                            $_part = $arrBuff1;
742
                            $_part = $arrBuff2;
733
                            break;
743
                            break;
734
                        case 'cpu variant':
744
                        case 'cpu variant':
735
                            $_vari = $arrBuff1;
745
                            $_vari = $arrBuff2;
-
 
746
                            break;
-
 
747
                        case 'system type':
-
 
748
                            $_system = $arrBuff2;
736
                            break;
749
                            break;
737
                        case 'machine':
750
                        case 'machine':
738
                        case 'hardware':
751
                        case 'hardware':
739
                            $_hard = $arrBuff1;
752
                            $_hard = $arrBuff2;
740
                            break;
753
                            break;
741
                        case 'revision':
754
                        case 'revision':
742
                            $_revi = $arrBuff1;
755
                            $_revi = $arrBuff2;
743
                            break;
756
                            break;
744
                        case 'cpu frequency':
757
                        case 'cpu frequency':
745
                            if (preg_match('/^(\d+)\s+Hz/i', $arrBuff1, $bufr2)) {
758
                            if (preg_match('/^(\d+)\s+Hz/i', $arrBuff2, $bufr2)) {
746
                                $_cpus = round($bufr2[1]/1000000);
759
                                $_cpus = round($bufr2[1]/1000000);
747
                            } elseif (preg_match('/^(\d+)\s+MHz/i', $arrBuff1, $bufr2)) {
760
                            } elseif (preg_match('/^(\d+)\s+MHz/i', $arrBuff2, $bufr2)) {
748
                                $_cpus = $bufr2[1];
761
                                $_cpus = $bufr2[1];
749
                            }
762
                            }
750
                            break;
763
                            break;
751
                        case 'system bus frequency':
764
                        case 'system bus frequency':
752
                            if (preg_match('/^(\d+)\s+Hz/i', $arrBuff1, $bufr2)) {
765
                            if (preg_match('/^(\d+)\s+Hz/i', $arrBuff2, $bufr2)) {
753
                                $_buss = round($bufr2[1]/1000000);
766
                                $_buss = round($bufr2[1]/1000000);
754
                            } elseif (preg_match('/^(\d+)\s+MHz/i', $arrBuff1, $bufr2)) {
767
                            } elseif (preg_match('/^(\d+)\s+MHz/i', $arrBuff2, $bufr2)) {
755
                                $_buss = $bufr2[1];
768
                                $_buss = $bufr2[1];
756
                            }
769
                            }
757
                            break;
770
                            break;
758
                        case 'bogomips per cpu':
771
                        case 'bogomips per cpu':
759
                            $_bogo = round($arrBuff1);
772
                            $_bogo = round($arrBuff2);
760
                            break;
773
                            break;
761
                        case 'vendor_id':
774
                        case 'vendor_id':
762
                            $_vend = $arrBuff1;
775
                            $_vend = $arrBuff2;
763
                            break;
776
                            break;
764
                        case 'cpu':
777
                        case 'cpu':
765
                            $procname = $arrBuff1;
778
                            $procname = $arrBuff2;
766
                        }
779
                        }
767
                    }
780
                    }
768
                }
781
                }
769
            }
782
            }
770
 
783
 
Line 778... Line 791...
778
                $part = null;
791
                $part = null;
779
                $vari = null;
792
                $vari = null;
780
                $dev = new CpuDevice();
793
                $dev = new CpuDevice();
781
                $details = preg_split("/\n/", $processor, -1, PREG_SPLIT_NO_EMPTY);
794
                $details = preg_split("/\n/", $processor, -1, PREG_SPLIT_NO_EMPTY);
782
                foreach ($details as $detail) {
795
                foreach ($details as $detail) {
783
                    $arrBuff = preg_split('/\s*:\s*/', trim($detail));
-
 
784
                    if ((count($arrBuff) == 2) && (($arrBuff1 = trim($arrBuff[1])) !== '')) {
796
                    if (preg_match('/^([^:]+):(.+)$/', trim($detail) , $arrBuff) && (($arrBuff2 = trim($arrBuff[2])) !== '')) {
785
                        switch (strtolower($arrBuff[0])) {
797
                        switch (strtolower(trim($arrBuff[1]))) {
786
                        case 'processor':
798
                        case 'processor':
787
                            $proc = $arrBuff1;
799
                            $proc = $arrBuff2;
788
                            if (is_numeric($proc)) {
800
                            if (is_numeric($proc)) {
789
                                if (($procname !== null) && (strlen($procname) > 0)) {
801
                                if (($procname !== null) && (strlen($procname) > 0)) {
790
                                    $dev->setModel($procname);
802
                                    $dev->setModel($procname);
791
                                }
803
                                }
792
                            } else {
804
                            } else {
Line 796... Line 808...
796
                            break;
808
                            break;
797
                        case 'model name':
809
                        case 'model name':
798
                        case 'cpu model':
810
                        case 'cpu model':
799
                        case 'cpu type':
811
                        case 'cpu type':
800
                        case 'cpu':
812
                        case 'cpu':
801
                            $dev->setModel($arrBuff1);
813
                            $dev->setModel($arrBuff2);
802
                            break;
814
                            break;
803
                        case 'cpu frequency':
815
                        case 'cpu frequency':
804
                            if (preg_match('/^(\d+)\s+Hz/i', $arrBuff1, $bufr2)) {
816
                            if (preg_match('/^(\d+)\s+Hz/i', $arrBuff2, $bufr2)) {
805
                                if (($tmpsp = round($bufr2[1]/1000000)) > 0) {
817
                                if (($tmpsp = round($bufr2[1]/1000000)) > 0) {
806
                                    $dev->setCpuSpeed($tmpsp);
818
                                    $dev->setCpuSpeed($tmpsp);
807
                                    $speedset = true;
819
                                    $speedset = true;
808
                                }
820
                                }
809
                            } elseif (preg_match('/^(\d+)\s+MHz/i', $arrBuff1, $bufr2)) {
821
                            } elseif (preg_match('/^(\d+)\s+MHz/i', $arrBuff2, $bufr2)) {
810
                                if ($bufr2[1] > 0) {
822
                                if ($bufr2[1] > 0) {
811
                                    $dev->setCpuSpeed($bufr2[1]);
823
                                    $dev->setCpuSpeed($bufr2[1]);
812
                                    $speedset = true;
824
                                    $speedset = true;
813
                                }
825
                                }
814
                            }
826
                            }
815
                            break;
827
                            break;
816
                        case 'cpu mhz':
828
                        case 'cpu mhz':
817
                        case 'clock':
829
                        case 'clock':
818
                            if ($arrBuff1 > 0) {
830
                            if ($arrBuff2 > 0) {
819
                                $dev->setCpuSpeed($arrBuff1);
831
                                $dev->setCpuSpeed($arrBuff2);
820
                                $speedset = true;
832
                                $speedset = true;
821
                            }
833
                            }
822
                            break;
834
                            break;
823
                        case 'cpu mhz static':
835
                        case 'cpu mhz static':
824
                            $dev->setCpuSpeedMax($arrBuff1);
836
                            $dev->setCpuSpeedMax($arrBuff2);
825
                            break;
837
                            break;
826
                        case 'cycle frequency [hz]':
838
                        case 'cycle frequency [hz]':
827
                            if (($tmpsp = round($arrBuff1/1000000)) > 0) {
839
                            if (($tmpsp = round($arrBuff2/1000000)) > 0) {
828
                                $dev->setCpuSpeed($tmpsp);
840
                                $dev->setCpuSpeed($tmpsp);
829
                                $speedset = true;
841
                                $speedset = true;
830
                            }
842
                            }
831
                            break;
843
                            break;
832
                        case 'cpu0clktck': // Linux sparc64
844
                        case 'cpu0clktck': // Linux sparc64
833
                            if (($tmpsp = round(hexdec($arrBuff1)/1000000)) > 0) {
845
                            if (($tmpsp = round(hexdec($arrBuff2)/1000000)) > 0) {
834
                                $dev->setCpuSpeed($tmpsp);
846
                                $dev->setCpuSpeed($tmpsp);
835
                                $speedset = true;
847
                                $speedset = true;
836
                            }
848
                            }
837
                            break;
849
                            break;
838
                        case 'l3 cache':
850
                        case 'l3 cache':
839
                        case 'cache size':
851
                        case 'cache size':
840
                            $dev->setCache(trim(preg_replace("/[a-zA-Z]/", "", $arrBuff1)) * 1024);
852
                            $dev->setCache(trim(preg_replace("/[a-zA-Z]/", "", $arrBuff2)) * 1024);
841
                            break;
853
                            break;
842
                        case 'initial bogomips':
854
                        case 'initial bogomips':
843
                        case 'bogomips':
855
                        case 'bogomips':
844
                        case 'cpu0bogo':
856
                        case 'cpu0bogo':
845
                            $dev->setBogomips(round($arrBuff1));
857
                            $dev->setBogomips(round($arrBuff2));
846
                            break;
858
                            break;
847
                        case 'flags':
859
                        case 'flags':
848
                            if (preg_match("/ vmx/", $arrBuff1)) {
860
                            if (preg_match("/ vmx/", $arrBuff2)) {
849
                                $dev->setVirt("vmx");
861
                                $dev->setVirt("vmx");
850
                            } elseif (preg_match("/ svm/", $arrBuff1)) {
862
                            } elseif (preg_match("/ svm/", $arrBuff2)) {
851
                                $dev->setVirt("svm");
863
                                $dev->setVirt("svm");
852
                            }
864
                            }
853
                            if (preg_match("/ hypervisor/", $arrBuff1)) {
865
                            if (preg_match("/ hypervisor/", $arrBuff2)) {
854
                                if ($dev->getVirt() === null) {
866
                                if ($dev->getVirt() === null) {
855
                                    $dev->setVirt("hypervisor");
867
                                    $dev->setVirt("hypervisor");
856
                                }
868
                                }
857
                                if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null)) {
869
                                if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null)) {
858
                                    $this->sys->setVirtualizer("hypervisor", false);
870
                                    $this->sys->setVirtualizer("hypervisor", false);
Line 860... Line 872...
860
                            }
872
                            }
861
                            break;
873
                            break;
862
                        case 'i size':
874
                        case 'i size':
863
                        case 'd size':
875
                        case 'd size':
864
                            if ($dev->getCache() === null) {
876
                            if ($dev->getCache() === null) {
865
                                $dev->setCache($arrBuff1 * 1024);
877
                                $dev->setCache($arrBuff2 * 1024);
866
                            } else {
878
                            } else {
867
                                $dev->setCache($dev->getCache() + ($arrBuff1 * 1024));
879
                                $dev->setCache($dev->getCache() + ($arrBuff2 * 1024));
868
                            }
880
                            }
869
                            break;
881
                            break;
870
                        case 'cpu architecture':
882
                        case 'cpu architecture':
871
                            $arch = $arrBuff1;
883
                            $arch = $arrBuff2;
872
                            break;
884
                            break;
873
                        case 'cpu implementer':
885
                        case 'cpu implementer':
874
                            $impl = $arrBuff1;
886
                            $impl = $arrBuff2;
875
                            break;
887
                            break;
876
                        case 'cpu part':
888
                        case 'cpu part':
877
                            $part = $arrBuff1;
889
                            $part = $arrBuff2;
878
                            break;
890
                            break;
879
                        case 'cpu variant':
891
                        case 'cpu variant':
880
                            $vari = $arrBuff1;
892
                            $vari = $arrBuff2;
881
                            break;
893
                            break;
882
                        case 'vendor_id':
894
                        case 'vendor_id':
883
                            $dev->setVendorId($arrBuff1);
895
                            $dev->setVendorId($arrBuff2);
884
                            if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && preg_match('/^User Mode Linux/', $arrBuff1)) {
896
                            if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && preg_match('/^User Mode Linux/', $arrBuff2)) {
885
                                $this->sys->setVirtualizer("cpuid:UserModeLinux", false);
897
                                $this->sys->setVirtualizer("cpuid:UserModeLinux", false);
886
                            }
898
                            }
887
                        }
899
                        }
888
                    }
900
                    }
889
                }
901
                }
Line 958... Line 970...
958
                        $dev->setTemp(value[1]);
970
                        $dev->setTemp(value[1]);
959
                    }
971
                    }
960
*/
972
*/
961
                    if (($arch !== null) && ($impl !== null) && ($part !== null)) {
973
                    if (($arch !== null) && ($impl !== null) && ($part !== null)) {
962
                        if (($impl === '0x41')
974
                        if (($impl === '0x41')
963
                           && (($_hard === 'BCM2708') || ($_hard === 'BCM2835') || ($_hard === 'BCM2709') || ($_hard === 'BCM2836') || ($_hard === 'BCM2710') || ($_hard === 'BCM2837') || ($_hard === 'BCM2711') || ($_hard === 'BCM2838'))
975
                           && (($_hard === 'BCM2708') || ($_hard === 'BCM2709') || ($_hard === 'BCM2710') || ($_hard === 'BCM2711') || ($_hard === 'BCM2712') || ($_hard === 'BCM2835') || ($_hard === 'BCM2836') || ($_hard === 'BCM2837') || ($_hard === 'BCM2838'))
964
                           && ($_revi !== null)) { // Raspberry Pi detection (instead of 'cat /proc/device-tree/model')
976
                           && ($_revi !== null)) { // Raspberry Pi detection (instead of 'cat /proc/device-tree/model')
965
                            if ($raslist === null) $raslist = @parse_ini_file(PSI_APP_ROOT."/data/raspberry.ini", true);
977
                            if ($raslist === null) $raslist = @parse_ini_file(PSI_APP_ROOT."/data/raspberry.ini", true);
966
                            $oldmach = $this->sys->getMachine();
978
                            $oldmach = $this->sys->getMachine();
967
                            if (($oldmach !== '') && preg_match("/^raspberrypi rpi(,.+)/", $oldmach, $machbuf)) {
979
                            if (($oldmach !== '') && preg_match("/^raspberrypi rpi(,.+)/", $oldmach, $machbuf)) {
968
                                $oldmachend = $machbuf[1];
980
                                $oldmachend = $machbuf[1];
Line 993... Line 1005...
993
                                            $this->sys->setMachine('Raspberry Pi'.$oldmachend);
1005
                                            $this->sys->setMachine('Raspberry Pi'.$oldmachend);
994
                                        }
1006
                                        }
995
                                    }
1007
                                    }
996
                                }
1008
                                }
997
                            }
1009
                            }
998
                        } elseif (($_hard !== null) && ($this->sys->getMachine() === '')) { // other ARM hardware
1010
                        } elseif ($this->sys->getMachine() === '') { // other ARM hardware
-
 
1011
                            if ($_hard !== null) {
-
 
1012
                                if ($_system !== null) {
-
 
1013
                                    $this->sys->setMachine($_hard." - ".$_system);
-
 
1014
                                } else {
999
                            $this->sys->setMachine($_hard);
1015
                                    $this->sys->setMachine($_hard);
-
 
1016
                                }
-
 
1017
                            } elseif ($_system !== null) {
-
 
1018
                                $this->sys->setMachine($_system);
-
 
1019
                            }
1000
                        }
1020
                        }
1001
                        if ($cpulist === null) $cpulist = @parse_ini_file(PSI_APP_ROOT."/data/cpus.ini", true);
1021
                        if ($cpulist === null) $cpulist = @parse_ini_file(PSI_APP_ROOT."/data/cpus.ini", true);
1002
                        if ($cpulist && (((($vari !== null) && isset($cpulist['cpu'][$cpufromlist = strtolower($impl.','.$part.','.$vari)]))
1022
                        if ($cpulist && (((($vari !== null) && isset($cpulist['cpu'][$cpufromlist = strtolower($impl.','.$part.','.$vari)]))
1003
                           || isset($cpulist['cpu'][$cpufromlist = strtolower($impl.','.$part)])))) {
1023
                           || isset($cpulist['cpu'][$cpufromlist = strtolower($impl.','.$part)])))) {
1004
                            if (($cpumodel = $dev->getModel()) !== '') {
1024
                            if (($cpumodel = $dev->getModel()) !== '') {
1005
                                $dev->setModel($cpumodel.' - '.$cpulist['cpu'][$cpufromlist]);
1025
                                $dev->setModel($cpumodel.' - '.$cpulist['cpu'][$cpufromlist]);
1006
                            } else {
1026
                            } else {
1007
                                $dev->setModel($cpulist['cpu'][$cpufromlist]);
1027
                                $dev->setModel($cpulist['cpu'][$cpufromlist]);
1008
                            }
1028
                            }
1009
                        }
1029
                        }
1010
                    } elseif (($_hard !== null) && ($this->sys->getMachine() === '')) { // other hardware
1030
                    } elseif ($this->sys->getMachine() === '') { // other hardware
-
 
1031
                        if ($_hard !== null) {
-
 
1032
                            if ($_system !== null) {
-
 
1033
                                $this->sys->setMachine($_hard." - ".$_system);
-
 
1034
                            } else {
1011
                        $this->sys->setMachine($_hard);
1035
                                $this->sys->setMachine($_hard);
-
 
1036
                            }
-
 
1037
                        } elseif ($_system !== null) {
-
 
1038
                            $this->sys->setMachine($_system);
-
 
1039
                        }
1012
                    }
1040
                    }
1013
 
1041
 
1014
                    $cpumodel = $dev->getModel();
1042
                    $cpumodel = $dev->getModel();
1015
                    if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null) && preg_match('/^QEMU Virtual CPU version /', $cpumodel)) {
1043
                    if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO && ($this->system_detect_virt === null) && preg_match('/^QEMU Virtual CPU version /', $cpumodel)) {
1016
                        $this->sys->setVirtualizer("cpuid:QEMU", false);
1044
                        $this->sys->setVirtualizer("cpuid:QEMU", false);
Line 1025... Line 1053...
1025
                    $cpucount++;
1053
                    $cpucount++;
1026
                    $this->sys->setCpus($dev);
1054
                    $this->sys->setCpus($dev);
1027
                }
1055
                }
1028
            }
1056
            }
1029
 
1057
 
1030
            $cpudevices = CommonFunctions::findglob('/sys/devices/system/cpu/cpu*/uevent', GLOB_NOSORT);
1058
            $cpudevices = CommonFunctions::findglob('/sys/devices/system/cpu/cpu[0-9]*/uevent', GLOB_NOSORT);
1031
            if (is_array($cpudevices) && (($cpustopped = count($cpudevices)-$cpucount) > 0)) {
1059
            if (is_array($cpudevices) && (($cpustopped = count($cpudevices)-$cpucount) > 0)) {
1032
                for (; $cpustopped > 0; $cpustopped--) {
1060
                for (; $cpustopped > 0; $cpustopped--) {
1033
                    $dev = new CpuDevice();
1061
                    $dev = new CpuDevice();
1034
                    $dev->setModel("stopped");
1062
                    $dev->setModel("stopped");
1035
                    if ($speedset) {
1063
                    if ($speedset) {
Line 1098... Line 1126...
1098
                            $dev->setName("unknown");
1126
                            $dev->setName("unknown");
1099
                        }
1127
                        }
1100
                        $this->sys->setPciDevices($dev);
1128
                        $this->sys->setPciDevices($dev);
1101
                    }
1129
                    }
1102
                }
1130
                }
-
 
1131
            } elseif (($dmesg = $this->_get_dmesg_c()) !== null) {
-
 
1132
                $arrBuf = preg_split("/\n/", $dmesg, -1, PREG_SPLIT_NO_EMPTY);
-
 
1133
                foreach ($arrBuf as $strLine) {
-
 
1134
                    if (preg_match('/^[\s\[\]\.\d]*pci\s+\d\d\d\d:\d\d:\d\d.\d: (\[[^\]]+\].*)/', $strLine, $ar_buf)) {
-
 
1135
                        $dev = new HWDevice();
-
 
1136
                        $dev->setName(trim($ar_buf[1]));
-
 
1137
                        $this->sys->setPciDevices($dev);
-
 
1138
                    }
-
 
1139
                }
1103
            }
1140
            }
1104
        }
1141
        }
1105
    }
1142
    }
1106
 
1143
 
1107
    /**
1144
    /**
Line 1956... Line 1993...
1956
            error_reporting(E_ERROR);
1993
            error_reporting(E_ERROR);
1957
 
1994
 
1958
            // Fall back in case 'lsb_release' does not exist but exist /etc/lsb-release
1995
            // Fall back in case 'lsb_release' does not exist but exist /etc/lsb-release
1959
            if (CommonFunctions::fileexists($filename="/etc/lsb-release")
1996
            if (CommonFunctions::fileexists($filename="/etc/lsb-release")
1960
               && CommonFunctions::rfts($filename, $buf, 0, 4096, false)
1997
               && CommonFunctions::rfts($filename, $buf, 0, 4096, false)
1961
               && (preg_match('/^DISTRIB_ID="?([^"\r\n]+)/m', $buf, $id_buf) || preg_match('/^DISTRIB_DESCRIPTION="?([^"\r\n]+)/m', $buf, $id_buf))) {
1998
               && (preg_match('/^DISTRIB_ID="?([^"\r\n]+)/m', $buf, $id_buf) || preg_match('/^DISTRIB_DESCRIPTION="?([^"\r\n]+)/m', $buf, $id_buf) 
-
 
1999
                   || preg_match('/^NAME="?([^"\r\n]+)/m', $buf, $nm_buf))) {
-
 
2000
                if (empty($id_buf) && preg_match('/^PRETTY_NAME=["\']?([^"\'\r\n]+)/m', $buf, $desc_buf)) {
-
 
2001
                    if (isset($list[strtolower($nm_buf[1])]['Image'])) {
-
 
2002
                        $this->sys->setDistributionIcon($list[strtolower($nm_buf[1])]['Image']);
-
 
2003
                    }
-
 
2004
                    $this->sys->setDistribution(trim($desc_buf[1]));
1962
                if (preg_match('/^DISTRIB_DESCRIPTION="?([^"\r\n]+)/m', $buf, $desc_buf)
2005
                } elseif (preg_match('/^DISTRIB_DESCRIPTION="?([^"\r\n]+)/m', $buf, $desc_buf)
1963
                   && (trim($desc_buf[1])!=trim($id_buf[1]))) {
2006
                   && (trim($desc_buf[1])!=trim($id_buf[1]))) {
1964
                    if ($desc_buf[1]==="Rolling Release") {
2007
                    if ($desc_buf[1]==="Rolling Release") {
1965
                        $desc_buf[1] = $id_buf[1]." ".$desc_buf[1];
2008
                        $desc_buf[1] = $id_buf[1]." ".$desc_buf[1];
1966
                    }
2009
                    }
1967
                    $this->sys->setDistribution(preg_replace("/ - Version:| Build:| Release| version| build| based in Ubuntu/i", "", trim($desc_buf[1])));
2010
                    $this->sys->setDistribution(preg_replace("/ - Version:| Build:| Release| version| build| based in Ubuntu/i", "", trim($desc_buf[1])));
Line 2020... Line 2063...
2020
                                if (isset($distribution['Mode'])&&(strtolower($distribution['Mode'])=="detection")) {
2063
                                if (isset($distribution['Mode'])&&(strtolower($distribution['Mode'])=="detection")) {
2021
                                    $buf = "";
2064
                                    $buf = "";
2022
                                } elseif (isset($distribution['Mode'])&&(strtolower($distribution['Mode'])=="execute")) {
2065
                                } elseif (isset($distribution['Mode'])&&(strtolower($distribution['Mode'])=="execute")) {
2023
                                    if (!CommonFunctions::executeProgram($filename, '2>/dev/null', $buf, PSI_DEBUG)) {
2066
                                    if (!CommonFunctions::executeProgram($filename, '2>/dev/null', $buf, PSI_DEBUG)) {
2024
                                        $buf = "";
2067
                                        $buf = "";
-
 
2068
                                    } elseif (preg_match('/^pve-manager\/([\d.]+)\//', $buf, $vers_buf)) { // Proxmox version
-
 
2069
                                        $buf = $vers_buf[1];
2025
                                    }
2070
                                    }
2026
                                } else {
2071
                                } else {
2027
                                    if (!CommonFunctions::rfts($filename, $buf, 1, 4096, false)) {
2072
                                    if (!CommonFunctions::rfts($filename, $buf, 1, 4096, false)) {
2028
                                        $buf = "";
2073
                                        $buf = "";
2029
                                        if (isset($distribution['Mode'])&&(strtolower($distribution['Mode'])=="analyse")) {
2074
                                        if (isset($distribution['Mode'])&&(strtolower($distribution['Mode'])=="analyse")) {