Subversion Repositories ALCASAR

Rev

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

Rev 3037 Rev 3100
Line 95... Line 95...
95
     * @return void
95
     * @return void
96
     */
96
     */
97
    protected function cpuinfo()
97
    protected function cpuinfo()
98
    {
98
    {
99
        $dev = new CpuDevice();
99
        $dev = new CpuDevice();
100
        if (CommonFunctions::executeProgram('hostinfo', '| grep "Processor type"', $buf, PSI_DEBUG)) {
100
        if (CommonFunctions::executeProgram('hostinfo', '', $buf, PSI_DEBUG) && ($buf !== '') && preg_match('/^Processor type:[ ]+(.+)$/m', $buf, $proc) && (($proc[1] = trim($proc[1])) !== '')) {
101
            $dev->setModel(preg_replace('/Processor type: /', '', $buf));
101
            $dev->setModel($proc[1]);
102
            $buf=$this->grabkey('hw.model');
102
            $buf=$this->grabkey('hw.model');
103
            if (($buf !== null) && (trim($buf) != "")) {
103
            if (($buf !== null) && (trim($buf) != "")) {
104
                $this->sys->setMachine(trim($buf));
104
                $this->sys->setMachine(trim($buf));
105
                if (CommonFunctions::rftsdata('ModelTranslation.txt', $buffer)) {
105
                if (CommonFunctions::rftsdata('ModelTranslation.txt', $buffer)) {
106
                    $buffer = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
106
                    $buffer = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
Line 262... Line 262...
262
     *
262
     *
263
     * @return void
263
     * @return void
264
     */
264
     */
265
    protected function memory()
265
    protected function memory()
266
    {
266
    {
267
        $s = $this->grabkey('hw.memsize');
267
        if (($s = $this->grabkey('hw.memsize')) > 0) {
-
 
268
            $this->sys->setMemTotal($s);
268
        if (CommonFunctions::executeProgram('vm_stat', '', $pstat, PSI_DEBUG)) {
269
            if (CommonFunctions::executeProgram('vm_stat', '', $pstat, PSI_DEBUG)) {
269
            // calculate free memory from page sizes (each page = 4096)
270
                // calculate free memory from page sizes (each page = 4096)
270
            if (preg_match('/^Pages free:\s+(\S+)/m', $pstat, $free_buf)) {
271
                if (preg_match('/^Pages free:\s+(\S+)/m', $pstat, $free_buf)) {
271
                if (preg_match('/^Anonymous pages:\s+(\S+)/m', $pstat, $anon_buf)
272
                    if (preg_match('/^Anonymous pages:\s+(\S+)/m', $pstat, $anon_buf)
272
                   && preg_match('/^Pages wired down:\s+(\S+)/m', $pstat, $wire_buf)
273
                       && preg_match('/^Pages wired down:\s+(\S+)/m', $pstat, $wire_buf)
273
                   && preg_match('/^File-backed pages:\s+(\S+)/m', $pstat, $fileb_buf)) {
274
                       && preg_match('/^File-backed pages:\s+(\S+)/m', $pstat, $fileb_buf)) {
274
                        // OS X 10.9 or never
275
                            // OS X 10.9 or never
275
                        $this->sys->setMemFree($free_buf[1] * 4 * 1024);
276
                            $this->sys->setMemFree($free_buf[1] * 4 * 1024);
276
                        $this->sys->setMemApplication(($anon_buf[1]+$wire_buf[1]) * 4 * 1024);
277
                            $this->sys->setMemApplication(($anon_buf[1]+$wire_buf[1]) * 4 * 1024);
277
                        $this->sys->setMemCache($fileb_buf[1] * 4 * 1024);
278
                            $this->sys->setMemCache($fileb_buf[1] * 4 * 1024);
278
                        if (preg_match('/^Pages occupied by compressor:\s+(\S+)/m', $pstat, $compr_buf)) {
279
                            if (preg_match('/^Pages occupied by compressor:\s+(\S+)/m', $pstat, $compr_buf)) {
279
                            $this->sys->setMemBuffer($compr_buf[1] * 4 * 1024);
280
                                $this->sys->setMemBuffer($compr_buf[1] * 4 * 1024);
280
                        }
281
                            }
281
                } else {
-
 
282
                    if (preg_match('/^Pages speculative:\s+(\S+)/m', $pstat, $spec_buf)) {
-
 
283
                        $this->sys->setMemFree(($free_buf[1]+$spec_buf[1]) * 4 * 1024);
-
 
284
                    } else {
282
                    } else {
-
 
283
                        if (preg_match('/^Pages speculative:\s+(\S+)/m', $pstat, $spec_buf)) {
-
 
284
                            $this->sys->setMemFree(($free_buf[1]+$spec_buf[1]) * 4 * 1024);
-
 
285
                        } else {
285
                        $this->sys->setMemFree($free_buf[1] * 4 * 1024);
286
                            $this->sys->setMemFree($free_buf[1] * 4 * 1024);
286
                    }
287
                        }
287
                    $appMemory = 0;
288
                        $appMemory = 0;
288
                    if (preg_match('/^Pages wired down:\s+(\S+)/m', $pstat, $wire_buf)) {
289
                        if (preg_match('/^Pages wired down:\s+(\S+)/m', $pstat, $wire_buf)) {
289
                        $appMemory += $wire_buf[1] * 4 * 1024;
290
                            $appMemory += $wire_buf[1] * 4 * 1024;
290
                    }
291
                        }
291
                    if (preg_match('/^Pages active:\s+(\S+)/m', $pstat, $active_buf)) {
292
                        if (preg_match('/^Pages active:\s+(\S+)/m', $pstat, $active_buf)) {
292
                        $appMemory += $active_buf[1] * 4 * 1024;
293
                            $appMemory += $active_buf[1] * 4 * 1024;
293
                    }
294
                        }
294
                    $this->sys->setMemApplication($appMemory);
295
                        $this->sys->setMemApplication($appMemory);
295
 
296
 
296
                    if (preg_match('/^Pages inactive:\s+(\S+)/m', $pstat, $inactive_buf)) {
297
                        if (preg_match('/^Pages inactive:\s+(\S+)/m', $pstat, $inactive_buf)) {
297
                        $this->sys->setMemCache($inactive_buf[1] * 4 * 1024);
298
                            $this->sys->setMemCache($inactive_buf[1] * 4 * 1024);
-
 
299
                        }
298
                    }
300
                    }
-
 
301
                } else {
-
 
302
                    $lines = preg_split("/\n/", $pstat, -1, PREG_SPLIT_NO_EMPTY);
-
 
303
                    $ar_buf = preg_split("/\s+/", $lines[1], 19);
-
 
304
                    $this->sys->setMemFree($ar_buf[2] * 4 * 1024);
299
                }
305
                }
300
            } else {
-
 
301
                $lines = preg_split("/\n/", $pstat, -1, PREG_SPLIT_NO_EMPTY);
-
 
302
                $ar_buf = preg_split("/\s+/", $lines[1], 19);
-
 
303
                $this->sys->setMemFree($ar_buf[2] * 4 * 1024);
306
                $this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
304
            }
307
            }
305
 
308
 
306
            $this->sys->setMemTotal($s);
309
            if (($swap = $this->grabkey("vm.swapusage")) > 0) {
307
            $this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
310
                $swap0 = preg_split('/M/', $swapBuff);
308
 
-
 
309
            if (CommonFunctions::executeProgram('sysctl', 'vm.swapusage | colrm 1 22', $swapBuff, PSI_DEBUG)) {
-
 
310
                $swap1 = preg_split('/M/', $swapBuff);
311
                $swap1 = preg_split('/=/', $swap0[0]);
311
                $swap2 = preg_split('/=/', $swap1[1]);
312
                $swap2 = preg_split('/=/', $swap0[1]);
312
                $swap3 = preg_split('/=/', $swap1[2]);
313
                $swap3 = preg_split('/=/', $swap0[2]);
313
                if (($swap=trim($swap1[0])) > 0) {
314
                if (($swap=str_replace(',', '.', trim($swap1[1]))) > 0) {
314
                    $dev = new DiskDevice();
315
                    $dev = new DiskDevice();
315
                    $dev->setName('SWAP');
316
                    $dev->setName('SWAP');
316
                    $dev->setMountPoint('SWAP');
317
                    $dev->setMountPoint('SWAP');
317
                    $dev->setFsType('swap');
318
                    $dev->setFsType('swap');
318
                    $dev->setTotal($swap * 1024 * 1024);
319
                    $dev->setTotal($swap * 1024 * 1024);
319
                    $dev->setUsed(trim($swap2[1]) * 1024 * 1024);
320
                    $dev->setUsed(str_replace(',', '.', trim($swap2[1])) * 1024 * 1024);
320
                    $dev->setFree(trim($swap3[1]) * 1024 * 1024);
321
                    $dev->setFree(str_replace(',', '.', trim($swap3[1])) * 1024 * 1024);
321
                    $this->sys->setSwapDevices($dev);
322
                    $this->sys->setSwapDevices($dev);
322
                }
323
                }
323
            }
324
            }
324
        }
325
        }
325
    }
326
    }
Line 415... Line 416...
415
            if (isset($distro_arr['ProductName']) && isset($distro_arr['ProductVersion']) && isset($distro_arr['BuildVersion'])) {
416
            if (isset($distro_arr['ProductName']) && isset($distro_arr['ProductVersion']) && isset($distro_arr['BuildVersion'])) {
416
                $distro_arr['System Version'] = $distro_arr['ProductName'].' '.$distro_arr['ProductVersion'].' ('.$distro_arr['BuildVersion'].')';
417
                $distro_arr['System Version'] = $distro_arr['ProductName'].' '.$distro_arr['ProductVersion'].' ('.$distro_arr['BuildVersion'].')';
417
            }
418
            }
418
            if (isset($distro_arr['System Version'])) {
419
            if (isset($distro_arr['System Version'])) {
419
                $distro = $distro_arr['System Version'];
420
                $distro = $distro_arr['System Version'];
420
                if (preg_match('/^Mac OS|^OS X|^macOS/', $distro)) {
421
                if (preg_match('/^Mac OS |^OS X |^macOS |^iPhone OS |^Mac OS$|^OS X$|^macOS$|^iPhone OS$/', $distro)) {
421
                    $this->sys->setDistributionIcon('Apple.png');
422
                    $this->sys->setDistributionIcon('Apple.png');
422
                    if (preg_match('/(^Mac OS X Server|^Mac OS X|^OS X Server|^OS X|^macOS Server|^macOS) ((\d+)\.\d+)/', $distro, $ver)
423
                    if (preg_match('/(^Mac OS X Server|^Mac OS X|^OS X Server|^OS X|^macOS Server|^macOS) ((\d+)\.\d+)/', $distro, $ver)
423
                        && ($list = @parse_ini_file(PSI_APP_ROOT."/data/osnames.ini", true))) {
424
                        && ($list = @parse_ini_file(PSI_APP_ROOT."/data/osnames.ini", true))) {
424
                        if (isset($list['macOS'][$ver[2]])) {
425
                        if (isset($list['macOS'][$ver[2]])) {
425
                            $distro.=' '.$list['macOS'][$ver[2]];
426
                            $distro.=' '.$list['macOS'][$ver[2]];