function findOperatingSystem($type = null) { if (windowsOs()) { $ret['os'] = 'windows'; try { $obj = new COM("Winmgmts://./root/cimv2"); } catch (exception $e) { //throw new lxException("com_failed", ''); return null; } $list = $obj->execQuery("select Caption from Win32_OperatingSystem"); foreach ($list as $l) { $ret['version'] = $l->Caption; $ret['pointversion'] = $l->Caption; } return $ret; } if (file_exists("/etc/fedora-release")) { $ret['os'] = 'fedora'; $ret['version'] = file_get_contents("/etc/fedora-release"); $ret['pointversion'] = find_os_pointversion(); } else { if (file_exists("/etc/redhat-release")) { $ret['os'] = 'rhel'; $ret['version'] = file_get_contents("/etc/redhat-release"); $ret['pointversion'] = find_os_pointversion(); } } /* -- not work because no driver for centos inside /usr/local/lxlabs/kloxo/file/conf $ret['os'] = find_os_distro(); $ret['version'] = find_os_release(); $ret['pointversion'] = find_os_pointversion(); */ if (lxfile_exists("__path_program_etc/install_xen") || lxfile_exists("/proc/xen")) { $ret['vpstype'] = "xen"; $ret['xenlocation'] = vg_complete(); } if ($type) { return $ret[$type]; } return $ret; }
static function pserverInfo() { global $gbl, $sgbl, $login, $ghtml; $osdet = findOperatingSystem(); $path = "/proc/meminfo"; $data = lfile($path); $res = self::parse_data($data); $unit = 1024; $ret['priv_s_memory'] = $res['memtotal'] / $unit; $ret['used_s_memory'] = ($res['memtotal'] - $res['memfree']) / $unit; $ret['priv_s_swap'] = $res['swaptotal'] / $unit; $ret['used_s_swap'] = ($res['swaptotal'] - $res['swapfree']) / $unit; $ret['used_s_membuffers'] = $res['buffers'] / $unit; $ret['used_s_memcached'] = $res['cached'] / $unit; // This is a hack to show the actual non-kloxo memory on openvz. if ($sgbl->isKloxo()) { if (lxfile_exists("/proc/user_beancounters")) { $ret['used_s_memory'] -= 20; } } foreach ($ret as &$vvv) { $vvv = round($vvv); } $path = "/proc/cpuinfo"; $data = lfile($path); $processornum = 0; foreach ($data as $v) { if (!trim($v)) { continue; } $d = explode(':', $v); $d[0] = trim($d[0]); $d[1] = trim($d[1]); if ($d[0] === 'processor') { $processornum = $d[1]; continue; } if ($d[0] === 'model name') { $cpu[$processornum]['used_s_cpumodel'] = $d[1]; } if ($d[0] === 'cpu MHz') { $cpu[$processornum]['used_s_cpuspeed'] = round($d[1] / 100) / 10 . "GHz"; } if ($d[0] === 'cache size') { $cpu[$processornum]['used_s_cpucache'] = $d[1]; } } $ret['disk'] = diskusage__linux::getDiskUsage(); $ret['lvm'] = vg_complete(); $ret['cpu'] = $cpu; $ret['osdet'] = $osdet; return $ret; }