Subversion Repositories ALCASAR

Rev

Rev 2976 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2976 Rev 3037
Line 88... Line 88...
88
            return '';
88
            return '';
89
        }
89
        }
90
    }
90
    }
91
 
91
 
92
    /**
92
    /**
93
     * UpTime
-
 
94
     * time the system is running
-
 
95
     *
-
 
96
     * @return void
-
 
97
     */
-
 
98
    private function _uptime()
-
 
99
    {
-
 
100
        if (CommonFunctions::executeProgram('sysctl', '-n kern.boottime', $a, PSI_DEBUG)) {
-
 
101
            $tmp = explode(" ", $a);
-
 
102
            if ($tmp[0]=="{") { /* kern.boottime= { sec = 1096732600, usec = 885425 } Sat Oct 2 10:56:40 2004 */
-
 
103
              $data = trim($tmp[3], ",");
-
 
104
              $this->sys->setUptime(time() - $data);
-
 
105
            } else { /* kern.boottime= 1096732600 */
-
 
106
              $this->sys->setUptime(time() - $a);
-
 
107
            }
-
 
108
        }
-
 
109
    }
-
 
110
 
-
 
111
    /**
-
 
112
     * get CPU information
93
     * get CPU information
113
     *
94
     *
114
     * @return void
95
     * @return void
115
     */
96
     */
116
    protected function cpuinfo()
97
    protected function cpuinfo()
117
    {
98
    {
118
        $dev = new CpuDevice();
99
        $dev = new CpuDevice();
119
        if (CommonFunctions::executeProgram('hostinfo', '| grep "Processor type"', $buf, PSI_DEBUG)) {
100
        if (CommonFunctions::executeProgram('hostinfo', '| grep "Processor type"', $buf, PSI_DEBUG)) {
120
            $dev->setModel(preg_replace('/Processor type: /', '', $buf));
101
            $dev->setModel(preg_replace('/Processor type: /', '', $buf));
121
            $buf=$this->grabkey('hw.model');
102
            $buf=$this->grabkey('hw.model');
122
            if (!is_null($buf) && (trim($buf) != "")) {
103
            if (($buf !== null) && (trim($buf) != "")) {
123
                $this->sys->setMachine(trim($buf));
104
                $this->sys->setMachine(trim($buf));
124
                if (CommonFunctions::rfts(PSI_APP_ROOT.'/data/ModelTranslation.txt', $buffer)) {
105
                if (CommonFunctions::rftsdata('ModelTranslation.txt', $buffer)) {
125
                    $buffer = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
106
                    $buffer = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
126
                    foreach ($buffer as $line) {
107
                    foreach ($buffer as $line) {
127
                        $ar_buf = preg_split("/:/", $line, 3);
108
                        $ar_buf = preg_split("/:/", $line, 3);
128
                        if (trim($buf) === trim($ar_buf[0])) {
109
                        if (trim($buf) === trim($ar_buf[0])) {
129
                            $dev->setModel(trim($ar_buf[2]));
110
                            $dev->setModel(trim($ar_buf[2]));
Line 132... Line 113...
132
                        }
113
                        }
133
                    }
114
                    }
134
                }
115
                }
135
            }
116
            }
136
            $buf=$this->grabkey('machdep.cpu.brand_string');
117
            $buf=$this->grabkey('machdep.cpu.brand_string');
137
            if (!is_null($buf) && (trim($buf) != "") &&
118
            if (($buf !== null) && (trim($buf) != "") &&
138
                 ((trim($buf) != "i486 (Intel 80486)") || ($dev->getModel() == ""))) {
119
                 ((trim($buf) != "i486 (Intel 80486)") || ($dev->getModel() == ""))) {
139
                $dev->setModel(trim($buf));
120
                $dev->setModel(trim($buf));
140
            }
121
            }
141
            $buf=$this->grabkey('machdep.cpu.features');
122
            $buf=$this->grabkey('machdep.cpu.features');
142
            if (!is_null($buf) && (trim($buf) != "")) {
123
            if (($buf !== null) && (trim($buf) != "")) {
143
                if (preg_match("/ VMX/", $buf)) {
124
                if (preg_match("/ VMX/", $buf)) {
144
                    $dev->setVirt("vmx");
125
                    $dev->setVirt("vmx");
145
                } elseif (preg_match("/ SVM/", $buf)) {
126
                } elseif (preg_match("/ SVM/", $buf)) {
146
                    $dev->setVirt("svm");
127
                    $dev->setVirt("svm");
147
                }
128
                }
Line 149... Line 130...
149
        }
130
        }
150
        $dev->setCpuSpeed(round($this->grabkey('hw.cpufrequency') / 1000000));
131
        $dev->setCpuSpeed(round($this->grabkey('hw.cpufrequency') / 1000000));
151
        $dev->setBusSpeed(round($this->grabkey('hw.busfrequency') / 1000000));
132
        $dev->setBusSpeed(round($this->grabkey('hw.busfrequency') / 1000000));
152
        $bufn=$this->grabkey('hw.cpufrequency_min');
133
        $bufn=$this->grabkey('hw.cpufrequency_min');
153
        $bufx=$this->grabkey('hw.cpufrequency_max');
134
        $bufx=$this->grabkey('hw.cpufrequency_max');
154
        if (!is_null($bufn) && (trim($bufn) != "") && !is_null($bufx) && (trim($bufx) != "") && ($bufn != $bufx)) {
135
        if (($bufn !== null) && (trim($bufn) != "") && ($bufx !== null) && (trim($bufx) != "") && ($bufn != $bufx)) {
155
            $dev->setCpuSpeedMin(round($bufn / 1000000));
136
            $dev->setCpuSpeedMin(round($bufn / 1000000));
156
            $dev->setCpuSpeedMax(round($bufx / 1000000));
137
            $dev->setCpuSpeedMax(round($bufx / 1000000));
157
        }
138
        }
158
        $buf=$this->grabkey('hw.l2cachesize');
139
        $buf=$this->grabkey('hw.l2cachesize');
159
        if (!is_null($buf) && (trim($buf) != "")) {
140
        if ($buf !== "") {
160
            $dev->setCache(round($buf));
141
            $dev->setCache(round($buf));
161
        }
142
        }
162
        $ncpu = $this->grabkey('hw.ncpu');
143
        $ncpu = $this->grabkey('hw.ncpu');
163
        if (is_null($ncpu) || (trim($ncpu) == "") || (!($ncpu >= 1)))
144
        if (($ncpu === "") || !($ncpu >= 1)) {
164
            $ncpu = 1;
145
            $ncpu = 1;
-
 
146
        }
-
 
147
        if (($ncpu == 1) && PSI_LOAD_BAR) {
-
 
148
            $dev->setLoad($this->cpuusage());
-
 
149
        }
165
        for ($ncpu ; $ncpu > 0 ; $ncpu--) {
150
        for ($ncpu ; $ncpu > 0 ; $ncpu--) {
166
            $this->sys->setCpus($dev);
151
            $this->sys->setCpus($dev);
167
        }
152
        }
168
    }
153
    }
169
 
154
 
Line 420... Line 405...
420
            parent::distro();
405
            parent::distro();
421
        } else {
406
        } else {
422
            $distro_tmp = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
407
            $distro_tmp = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
423
            foreach ($distro_tmp as $info) {
408
            foreach ($distro_tmp as $info) {
424
                $info_tmp = preg_split('/:/', $info, 2);
409
                $info_tmp = preg_split('/:/', $info, 2);
425
                if (isset($distro_tmp[0]) && !is_null($distro_tmp[0]) && (trim($distro_tmp[0]) != "") &&
410
                if (isset($distro_tmp[0]) && ($distro_tmp[0] !== null) && (trim($distro_tmp[0]) != "") &&
426
                     isset($distro_tmp[1]) && !is_null($distro_tmp[1]) && (trim($distro_tmp[1]) != "")) {
411
                     isset($distro_tmp[1]) && ($distro_tmp[1] !== null) && (trim($distro_tmp[1]) != "")) {
427
                    $distro_arr[trim($info_tmp[0])] = trim($info_tmp[1]);
412
                    $distro_arr[trim($info_tmp[0])] = trim($info_tmp[1]);
428
                }
413
                }
429
            }
414
            }
430
            if (isset($distro_arr['ProductName']) && isset($distro_arr['ProductVersion']) && isset($distro_arr['BuildVersion'])) {
415
            if (isset($distro_arr['ProductName']) && isset($distro_arr['ProductVersion']) && isset($distro_arr['BuildVersion'])) {
431
                $distro_arr['System Version'] = $distro_arr['ProductName'].' '.$distro_arr['ProductVersion'].' ('.$distro_arr['BuildVersion'].')';
416
                $distro_arr['System Version'] = $distro_arr['ProductName'].' '.$distro_arr['ProductVersion'].' ('.$distro_arr['BuildVersion'].')';
Line 483... Line 468...
483
    /**
468
    /**
484
     * get the information
469
     * get the information
485
     *
470
     *
486
     * @see PSI_Interface_OS::build()
471
     * @see PSI_Interface_OS::build()
487
     *
472
     *
488
     * @return Void
473
     * @return void
489
     */
474
     */
490
    public function build()
475
    public function build()
491
    {
476
    {
492
        parent::build();
477
        parent::build();
493
        if (!$this->blockname || $this->blockname==='vitals') {
478
        if (!$this->blockname || $this->blockname==='vitals') {
494
            $this->_uptime();
-
 
495
            $this->_processes();
479
            $this->_processes();
496
        }
480
        }
497
        if (!$this->blockname || $this->blockname==='hardware') {
481
        if (!$this->blockname || $this->blockname==='hardware') {
498
            $this->_tb();
482
            $this->_tb();
499
        }
483
        }