Subversion Repositories ALCASAR

Rev

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

Rev 3037 Rev 3100
Line 230... Line 230...
230
     * @return void
230
     * @return void
231
     */
231
     */
232
    protected function kernel()
232
    protected function kernel()
233
    {
233
    {
234
        $s = $this->grabkey('kern.version');
234
        $s = $this->grabkey('kern.version');
235
        $a = preg_split('/:/', $s);
235
        $a = preg_split('/:/', $s, 4);
236
        if (isset($a[2])) {
236
        if (isset($a[3])) {
-
 
237
            if (preg_match('/^(\d{2} [A-Z]{3});/', $a[3], $abuf) // eg. 19:58 GMT;...
-
 
238
               || preg_match('/^(\d{2} [A-Z]{3} \d{4})/', $a[3], $abuf)) { // eg. 26:31 PDT 2019...
-
 
239
                $this->sys->setKernel($a[0].$a[1].':'.$a[2].':'.$abuf[1]);
-
 
240
            } else {
-
 
241
                $this->sys->setKernel($a[0].$a[1].':'.$a[2]);
-
 
242
            }
-
 
243
        } elseif (isset($a[2])) {
237
            $this->sys->setKernel($a[0].$a[1].':'.$a[2]);
244
            $this->sys->setKernel($a[0].$a[1].':'.$a[2]);
238
        } else {
245
        } else {
239
            $this->sys->setKernel($s);
246
            $this->sys->setKernel($s);
240
        }
247
        }
241
    }
248
    }
Line 303... Line 310...
303
                    $pslines = preg_split("/\n/", $pstable, -1, PREG_SPLIT_NO_EMPTY);
310
                    $pslines = preg_split("/\n/", $pstable, -1, PREG_SPLIT_NO_EMPTY);
304
                    if (!empty($pslines) && (count($pslines)>1) && (trim($pslines[0])==="%CPU")) {
311
                    if (!empty($pslines) && (count($pslines)>1) && (trim($pslines[0])==="%CPU")) {
305
                        array_shift($pslines);
312
                        array_shift($pslines);
306
                        $sum = 0;
313
                        $sum = 0;
307
                        foreach ($pslines as $psline) {
314
                        foreach ($pslines as $psline) {
308
                            $sum+=trim($psline);
315
                            $sum+=str_replace(',', '.', trim($psline));
309
                        }
316
                        }
310
                        $this->_cpu_loads['cpu'] = min($sum/$ncpu, 100);
317
                        $this->_cpu_loads['cpu'] = min($sum/$ncpu, 100);
311
                    }
318
                    }
312
                }
319
                }
313
            }
320
            }
Line 329... Line 336...
329
    protected function loadavg()
336
    protected function loadavg()
330
    {
337
    {
331
        $s = $this->grabkey('vm.loadavg');
338
        $s = $this->grabkey('vm.loadavg');
332
        $s = preg_replace('/{ /', '', $s);
339
        $s = preg_replace('/{ /', '', $s);
333
        $s = preg_replace('/ }/', '', $s);
340
        $s = preg_replace('/ }/', '', $s);
-
 
341
        $s = str_replace(',', '.', $s);
334
        $this->sys->setLoad($s);
342
        $this->sys->setLoad($s);
335
 
343
 
336
        if (PSI_LOAD_BAR) {
344
        if (PSI_LOAD_BAR) {
337
            $this->sys->setLoadPercent($this->cpuusage());
345
            $this->sys->setLoadPercent($this->cpuusage());
338
        }
346
        }
Line 356... Line 364...
356
        foreach ($this->readdmesg() as $line) {
364
        foreach ($this->readdmesg() as $line) {
357
            if ($notwas) {
365
            if ($notwas) {
358
               $regexps = preg_split("/\n/", $this->_CPURegExp1, -1, PREG_SPLIT_NO_EMPTY); // multiple regexp separated by \n
366
               $regexps = preg_split("/\n/", $this->_CPURegExp1, -1, PREG_SPLIT_NO_EMPTY); // multiple regexp separated by \n
359
               foreach ($regexps as $regexp) {
367
               foreach ($regexps as $regexp) {
360
                   if (preg_match($regexp, $line, $ar_buf) && (sizeof($ar_buf) > 2)) {
368
                   if (preg_match($regexp, $line, $ar_buf) && (sizeof($ar_buf) > 2)) {
361
                        if ($dev->getCpuSpeed() === 0) {
369
                        if ($dev->getCpuSpeed() == 0) {
362
                            $dev->setCpuSpeed(round($ar_buf[2]));
370
                            $dev->setCpuSpeed(round($ar_buf[2]));
363
                        }
371
                        }
364
                        $notwas = false;
372
                        $notwas = false;
365
                        break;
373
                        break;
366
                    }
374
                    }