Subversion Repositories ALCASAR

Rev

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

Rev 2976 Rev 3037
Line 39... Line 39...
39
        $this->setPCIRegExp1("/(.*) at pci[0-9]+ .* \"(.*)\"/");
39
        $this->setPCIRegExp1("/(.*) at pci[0-9]+ .* \"(.*)\"/");
40
        $this->setPCIRegExp2("/\"(.*)\" (.*).* at [.0-9]+ irq/");
40
        $this->setPCIRegExp2("/\"(.*)\" (.*).* at [.0-9]+ irq/");
41
    }
41
    }
42
 
42
 
43
    /**
43
    /**
44
     * UpTime
-
 
45
     * time the system is running
-
 
46
     *
-
 
47
     * @return void
-
 
48
     */
-
 
49
    private function _uptime()
-
 
50
    {
-
 
51
        $a = $this->grabkey('kern.boottime');
-
 
52
        $this->sys->setUptime(time() - $a);
-
 
53
    }
-
 
54
 
-
 
55
    /**
-
 
56
     * get network information
44
     * get network information
57
     *
45
     *
58
     * @return void
46
     * @return void
59
     */
47
     */
60
    private function _network()
48
    private function _network()
Line 138... Line 126...
138
     *
126
     *
139
     * @return void
127
     * @return void
140
     */
128
     */
141
    protected function cpuinfo()
129
    protected function cpuinfo()
142
    {
130
    {
143
        $dev = new CpuDevice();
-
 
144
        $dev->setModel($this->grabkey('hw.model'));
-
 
145
        $dev->setCpuSpeed($this->grabkey('hw.cpuspeed'));
-
 
146
        $was = false;
131
        $was = false;
-
 
132
        $cpuarray = array();
147
        foreach ($this->readdmesg() as $line) {
133
        foreach ($this->readdmesg() as $line) {
148
            if (preg_match("/^cpu[0-9]+: (.*)/", $line, $ar_buf)) {
134
            if (preg_match("/^cpu([0-9])+: (.*)/", $line, $ar_buf)) {
149
                $was = true;
135
                $was = true;
-
 
136
                $ar_buf[2] = trim($ar_buf[2]);
-
 
137
                if (preg_match("/^(.+), ([\d\.]+) MHz/", $ar_buf[2], $ar_buf2)) {
-
 
138
                    if (($model = trim($ar_buf2[1])) !== "") {
-
 
139
                        $cpuarray[$ar_buf[1]]['model'] = $model;
-
 
140
                    }
-
 
141
                    if (($speed = trim($ar_buf2[2])) > 0) {
-
 
142
                        $cpuarray[$ar_buf[1]]['speed'] = $speed;
-
 
143
                    }
150
                if (preg_match("/^cpu[0-9]+: (\d+)([KM])B (.*) L2 cache/", $line, $ar_buf2)) {
144
                } elseif (preg_match("/(\d+)([KM])B \S+ \S+ L[23] cache$/", $ar_buf[2], $ar_buf2)) {
151
                    if ($ar_buf2[2]=="M") {
145
                    if ($ar_buf2[2]=="M") {
152
                        $dev->setCache($ar_buf2[1]*1024*1024);
146
                        $cpuarray[$ar_buf[1]]['cache'] = $ar_buf2[1]*1024*1024;
153
                    } elseif ($ar_buf2[2]=="K") {
147
                    } elseif ($ar_buf2[2]=="K") {
154
                        $dev->setCache($ar_buf2[1]*1024);
148
                        $cpuarray[$ar_buf[1]]['cache'] = $ar_buf2[1]*1024;
155
                    }
149
                    }
156
                } else {
150
                } else {
157
                    $feats = preg_split("/,/", strtolower(trim($ar_buf[1])), -1, PREG_SPLIT_NO_EMPTY);
151
                    $feats = preg_split("/,/", strtolower($ar_buf[2]), -1, PREG_SPLIT_NO_EMPTY);
158
                    foreach ($feats as $feat) {
152
                    foreach ($feats as $feat) {
159
                        if (($feat=="vmx") || ($feat=="svm")) {
153
                        if (($feat=="vmx") || ($feat=="svm")) {
-
 
154
                            $cpuarray[$ar_buf[1]]['virt'] = $feat;
160
                            $dev->setVirt($feat);
155
                        } elseif ($feat=="hv") {
-
 
156
                            if (!isset($cpuarray[$ar_buf[1]]['virt'])) {
-
 
157
                                $cpuarray[$ar_buf[1]]['virt'] = 'hypervisor';
-
 
158
                            }
-
 
159
                            if (defined('PSI_SHOW_VIRTUALIZER_INFO') && PSI_SHOW_VIRTUALIZER_INFO) {
-
 
160
                                $this->sys->setVirtualizer("hypervisor", false);
-
 
161
                            }
161
                        }
162
                        }
162
                    }
163
                    }
163
                }
164
                }
164
            } elseif ($was) {
165
            } elseif (!preg_match("/^cpu[0-9]+|^mtrr: |^acpitimer[0-9]+: /", $line) && $was) {
165
                break;
166
                break;
166
            }
167
            }
167
        }
168
        }
-
 
169
 
168
        $ncpu = $this->grabkey('hw.ncpu');
170
        $ncpu = $this->grabkey('hw.ncpu');
169
        if (is_null($ncpu) || (trim($ncpu) == "") || (!($ncpu >= 1)))
171
        if (($ncpu === "") || !($ncpu >= 1)) {
170
            $ncpu = 1;
172
            $ncpu = 1;
-
 
173
        }
-
 
174
        $ncpu = max($ncpu, count($cpuarray));
-
 
175
 
-
 
176
        $model = $this->grabkey('hw.model');
-
 
177
        $speed = $this->grabkey('hw.cpuspeed');
-
 
178
        $vendor = $this->grabkey('machdep.cpuvendor');
-
 
179
 
171
        for ($ncpu ; $ncpu > 0 ; $ncpu--) {
180
        for ($cpu = 0 ; $cpu < $ncpu ; $cpu++) {
-
 
181
            $dev = new CpuDevice();
-
 
182
 
-
 
183
            if (isset($cpuarray[$cpu]['model'])) {
-
 
184
                $dev->setModel($cpuarray[$cpu]['model']);
-
 
185
            } elseif ($model !== "") {
-
 
186
                $dev->setModel($model);
-
 
187
            }
-
 
188
            if (isset($cpuarray[$cpu]['speed'])) {
-
 
189
                $dev->setCpuSpeed($cpuarray[$cpu]['speed']);
-
 
190
            } elseif ($speed !== "") {
-
 
191
                $dev->setCpuSpeed($speed);
-
 
192
            }
-
 
193
            if (isset($cpuarray[$cpu]['cache'])) {
-
 
194
                $dev->setCache($cpuarray[$cpu]['cache']);
-
 
195
            }
-
 
196
            if (isset($cpuarray[$cpu]['virt'])) {
-
 
197
                $dev->setVirt($cpuarray[$cpu]['virt']);
-
 
198
            }
-
 
199
            if ($vendor !== "") {
-
 
200
                $dev->setVendorId($vendor);
-
 
201
            }
-
 
202
            if (($ncpu == 1) && PSI_LOAD_BAR) {
-
 
203
                $dev->setLoad($this->cpuusage());
-
 
204
            }
-
 
205
 
172
            $this->sys->setCpus($dev);
206
            $this->sys->setCpus($dev);
173
        }
207
        }
174
    }
208
    }
175
 
209
 
176
    /**
210
    /**
Line 214... Line 248...
214
    /**
248
    /**
215
     * get the information
249
     * get the information
216
     *
250
     *
217
     * @see BSDCommon::build()
251
     * @see BSDCommon::build()
218
     *
252
     *
219
     * @return Void
253
     * @return void
220
     */
254
     */
221
    public function build()
255
    public function build()
222
    {
256
    {
223
        parent::build();
257
        parent::build();
224
        if (!$this->blockname || $this->blockname==='vitals') {
258
        if (!$this->blockname || $this->blockname==='vitals') {
225
            $this->_distroicon();
259
            $this->_distroicon();
226
            $this->_uptime();
-
 
227
            $this->_processes();
260
            $this->_processes();
228
        }
261
        }
229
        if (!$this->blockname || $this->blockname==='network') {
262
        if (!$this->blockname || $this->blockname==='network') {
230
            $this->_network();
263
            $this->_network();
231
        }
264
        }