Subversion Repositories ALCASAR

Rev

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

Rev 2770 Rev 2976
Line 323... Line 323...
323
 
323
 
324
            if (CommonFunctions::executeProgram('sysctl', 'vm.swapusage | colrm 1 22', $swapBuff, PSI_DEBUG)) {
324
            if (CommonFunctions::executeProgram('sysctl', 'vm.swapusage | colrm 1 22', $swapBuff, PSI_DEBUG)) {
325
                $swap1 = preg_split('/M/', $swapBuff);
325
                $swap1 = preg_split('/M/', $swapBuff);
326
                $swap2 = preg_split('/=/', $swap1[1]);
326
                $swap2 = preg_split('/=/', $swap1[1]);
327
                $swap3 = preg_split('/=/', $swap1[2]);
327
                $swap3 = preg_split('/=/', $swap1[2]);
-
 
328
                if (($swap=trim($swap1[0])) > 0) {
328
                $dev = new DiskDevice();
329
                    $dev = new DiskDevice();
329
                $dev->setName('SWAP');
330
                    $dev->setName('SWAP');
330
                $dev->setMountPoint('SWAP');
331
                    $dev->setMountPoint('SWAP');
331
                $dev->setFsType('swap');
332
                    $dev->setFsType('swap');
332
                $dev->setTotal($swap1[0] * 1024 * 1024);
333
                    $dev->setTotal($swap * 1024 * 1024);
333
                $dev->setUsed($swap2[1] * 1024 * 1024);
334
                    $dev->setUsed(trim($swap2[1]) * 1024 * 1024);
334
                $dev->setFree($swap3[1] * 1024 * 1024);
335
                    $dev->setFree(trim($swap3[1]) * 1024 * 1024);
335
                $this->sys->setSwapDevices($dev);
336
                    $this->sys->setSwapDevices($dev);
-
 
337
                }
336
            }
338
            }
337
        }
339
        }
338
    }
340
    }
339
 
341
 
340
    /**
342
    /**
Line 411... Line 413...
411
     * @return void
413
     * @return void
412
     */
414
     */
413
    protected function distro()
415
    protected function distro()
414
    {
416
    {
415
        $this->sys->setDistributionIcon('Darwin.png');
417
        $this->sys->setDistributionIcon('Darwin.png');
416
        if (!CommonFunctions::executeProgram('system_profiler', 'SPSoftwareDataType', $buffer, PSI_DEBUG)) {
418
        if ((!CommonFunctions::executeProgram('system_profiler', 'SPSoftwareDataType', $buffer, PSI_DEBUG) || !preg_match('/\n\s*System Version:/', $buffer))
-
 
419
           && (!CommonFunctions::executeProgram('sw_vers', '', $buffer, PSI_DEBUG) || !preg_match('/^ProductName:/', $buffer))) {
417
            parent::distro();
420
            parent::distro();
418
        } else {
421
        } else {
419
            $arrBuff = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
422
            $distro_tmp = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
420
            foreach ($arrBuff as $line) {
423
            foreach ($distro_tmp as $info) {
421
                $arrLine = preg_split("/:/", $line, -1, PREG_SPLIT_NO_EMPTY);
424
                $info_tmp = preg_split('/:/', $info, 2);
-
 
425
                if (isset($distro_tmp[0]) && !is_null($distro_tmp[0]) && (trim($distro_tmp[0]) != "") &&
-
 
426
                     isset($distro_tmp[1]) && !is_null($distro_tmp[1]) && (trim($distro_tmp[1]) != "")) {
-
 
427
                    $distro_arr[trim($info_tmp[0])] = trim($info_tmp[1]);
-
 
428
                }
-
 
429
            }
-
 
430
            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'].')';
-
 
432
            }
422
                if (trim($arrLine[0]) === "System Version") {
433
            if (isset($distro_arr['System Version'])) {
423
                    $distro = trim($arrLine[1]);
434
                $distro = $distro_arr['System Version'];
424
 
-
 
425
                    if (preg_match('/^Mac OS|^OS X|^macOS/', $distro)) {
435
                if (preg_match('/^Mac OS|^OS X|^macOS/', $distro)) {
426
                        $this->sys->setDistributionIcon('Apple.png');
436
                    $this->sys->setDistributionIcon('Apple.png');
427
                        if (preg_match('/(^Mac OS X Server|^Mac OS X|^OS X Server|^OS X|^macOS Server|^macOS) (\d+\.\d+)/', $distro, $ver)
437
                    if (preg_match('/(^Mac OS X Server|^Mac OS X|^OS X Server|^OS X|^macOS Server|^macOS) ((\d+)\.\d+)/', $distro, $ver)
428
                            && ($list = @parse_ini_file(PSI_APP_ROOT."/data/osnames.ini", true))
438
                        && ($list = @parse_ini_file(PSI_APP_ROOT."/data/osnames.ini", true))) {
429
                            && isset($list['OS X'][$ver[2]])) {
439
                        if (isset($list['macOS'][$ver[2]])) {
430
                            $distro.=' '.$list['OS X'][$ver[2]];
440
                            $distro.=' '.$list['macOS'][$ver[2]];
-
 
441
                        } elseif (isset($list['macOS'][$ver[3]])) {
-
 
442
                            $distro.=' '.$list['macOS'][$ver[3]];
431
                        }
443
                        }
432
                    }
444
                    }
433
 
-
 
434
                    $this->sys->setDistribution($distro);
-
 
435
 
-
 
436
                    return;
-
 
437
                }
445
                }
-
 
446
                $this->sys->setDistribution($distro);
-
 
447
            } else {
-
 
448
                parent::distro();
438
            }
449
            }
439
        }
450
        }
440
    }
451
    }
441
 
452
 
442
    /**
453
    /**