本文整理汇总了PHP中phodevi::is_solaris方法的典型用法代码示例。如果您正苦于以下问题:PHP phodevi::is_solaris方法的具体用法?PHP phodevi::is_solaris怎么用?PHP phodevi::is_solaris使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phodevi
的用法示例。
在下文中一共展示了phodevi::is_solaris方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: read_sensor
public static function read_sensor()
{
// Determine current percentage for processor usage
if (phodevi::is_linux() || phodevi::is_bsd()) {
$start_load = self::cpu_load_array(-1);
sleep(1);
$end_load = self::cpu_load_array(-1);
for ($i = 0; $i < count($end_load); $i++) {
$end_load[$i] -= $start_load[$i];
}
$percent = ($sum = array_sum($end_load)) == 0 ? 0 : 100 - $end_load[count($end_load) - 1] * 100 / $sum;
} else {
if (phodevi::is_solaris()) {
// TODO: Add support for monitoring load on a per-core basis (through mpstat maybe?)
$info = explode(' ', pts_strings::trim_spaces(pts_arrays::last_element(explode("\n", trim(shell_exec('sar -u 1 1 2>&1'))))));
$percent = $info[1] + $info[2];
} else {
if (phodevi::is_macosx()) {
// CPU usage for user
$top = shell_exec('top -n 1 -l 1 2>&1');
$top = substr($top, strpos($top, 'CPU usage: ') + 11);
$percent = substr($top, 0, strpos($top, '%'));
} else {
$percent = null;
}
}
}
if (!is_numeric($percent) || $percent < 0 || $percent > 100) {
$percent = -1;
}
return pts_math::set_precision($percent, 2);
}
示例2: read_sensor
public static function read_sensor()
{
// Determine the current processor frequency
$cpu_core = 0;
// TODO: for now just monitoring the first core
$info = 0;
if (phodevi::is_linux()) {
// First, the ideal way, with modern CPUs using CnQ or EIST and cpuinfo reporting the current
if (is_file('/sys/devices/system/cpu/cpu' . $cpu_core . '/cpufreq/scaling_cur_freq')) {
$info = pts_file_io::file_get_contents('/sys/devices/system/cpu/cpu' . $cpu_core . '/cpufreq/scaling_cur_freq');
$info = intval($info) / 1000;
} else {
if (is_file('/proc/cpuinfo')) {
$cpu_speeds = phodevi_linux_parser::read_cpuinfo('cpu MHz');
if (isset($cpu_speeds[0])) {
$cpu_core = isset($cpu_speeds[$cpu_core]) ? $cpu_core : 0;
$info = intval($cpu_speeds[$cpu_core]);
}
}
}
} else {
if (phodevi::is_solaris()) {
$info = shell_exec('psrinfo -v | grep MHz');
$info = substr($info, strrpos($info, 'at') + 3);
$info = trim(substr($info, 0, strpos($info, 'MHz')));
} else {
if (phodevi::is_bsd()) {
$info = phodevi_bsd_parser::read_sysctl('dev.cpu.0.freq');
} else {
if (phodevi::is_macosx()) {
$info = phodevi_osx_parser::read_osx_system_profiler('SPHardwareDataType', 'ProcessorSpeed');
if (($cut_point = strpos($info, ' ')) > 0) {
$info = substr($info, 0, $cut_point);
$info = str_replace(',', '.', $info);
}
if ($info < 100) {
$info *= 1000;
}
}
}
}
}
return pts_math::set_precision($info, 2);
}
示例3: read_sensor
public function read_sensor()
{
// Determine current percentage for core usage
// Default core to read is the first one (number 0)
if (phodevi::is_linux() || phodevi::is_bsd()) {
$percent = $this->cpu_usage_linux_bsd();
} else {
if (phodevi::is_solaris()) {
$percent = $this->cpu_usage_solaris();
} else {
if (phodevi::is_macosx()) {
$percent = $this->cpu_usage_macosx();
}
}
}
if (!isset($percent) || !is_numeric($percent) || $percent < 0 || $percent > 100) {
$percent = -1;
}
return pts_math::set_precision($percent, 2);
}
示例4: read_sensor
public function read_sensor()
{
// Determine the current processor frequency
$frequency = 0;
if (phodevi::is_linux()) {
$frequency = $this->cpu_freq_linux();
} else {
if (phodevi::is_solaris()) {
$frequency = $this->cpu_freq_solaris();
} else {
if (phodevi::is_bsd()) {
$frequency = $this->cpu_freq_bsd();
} else {
if (phodevi::is_macosx()) {
$frequency = $this->cpu_freq_macosx();
}
}
}
}
return pts_math::set_precision($frequency, 2);
}
示例5: is_process_running
public static function is_process_running($process)
{
if (phodevi::is_linux()) {
// Checks if process is running on the system
$running = shell_exec('ps -C ' . strtolower($process) . ' 2>&1');
$running = trim(str_replace(array('PID', 'TTY', 'TIME', 'CMD'), '', $running));
} else {
if (phodevi::is_solaris()) {
// Checks if process is running on the system
$ps = shell_exec('ps -ef 2>&1');
$running = strpos($ps, ' ' . strtolower($process)) != false ? 'TRUE' : null;
} else {
if (pts_client::executable_in_path('ps') != false) {
// Checks if process is running on the system
$ps = shell_exec('ps -ax 2>&1');
$running = strpos($ps, ' ' . strtolower($process)) != false ? 'TRUE' : null;
} else {
$running = null;
}
}
}
return !empty($running);
}
示例6: cpu_model
public static function cpu_model()
{
// Returns the processor name / frequency information
$info = null;
if (isset(phodevi::$vfs->cpuinfo)) {
$physical_cpu_ids = phodevi_linux_parser::read_cpuinfo('physical id');
$physical_cpu_count = count(array_unique($physical_cpu_ids));
$cpu_strings = phodevi_linux_parser::read_cpuinfo(array('model name', 'Processor', 'cpu', 'cpu model'));
$cpu_strings_unique = array_unique($cpu_strings);
if ($physical_cpu_count == 1 || empty($physical_cpu_count)) {
// Just one processor
if (isset($cpu_strings[0]) && ($cut = strpos($cpu_strings[0], ' (')) !== false) {
$cpu_strings[0] = substr($cpu_strings[0], 0, $cut);
}
$info = isset($cpu_strings[0]) ? $cpu_strings[0] : null;
if (strpos($info, 'ARM') !== false) {
if (is_dir('/sys/devices/system/exynos-core/') && stripos($info, 'Exynos') === false) {
$info = 'Exynos ' . $info;
}
}
} else {
if ($physical_cpu_count > 1 && count($cpu_strings_unique) == 1) {
// Multiple processors, same model
$info = $physical_cpu_count . ' x ' . $cpu_strings[0];
} else {
if ($physical_cpu_count > 1 && count($cpu_strings_unique) > 1) {
// Multiple processors, different models
$current_id = -1;
$current_string = $cpu_strings[0];
$current_count = 0;
$cpus = array();
for ($i = 0; $i < count($physical_cpu_ids); $i++) {
if ($current_string != $cpu_strings[$i] || $i == count($physical_cpu_ids) - 1) {
array_push($cpus, $current_count . ' x ' . $current_string);
$current_string = $cpu_strings[$i];
$current_count = 0;
}
if ($physical_cpu_ids[$i] != $current_id) {
$current_count++;
$current_id = $physical_cpu_ids[$i];
}
}
$info = implode(', ', $cpus);
}
}
}
} else {
if (phodevi::is_solaris()) {
$dmi_cpu = phodevi_solaris_parser::read_sun_ddu_dmi_info('CPUType', '-C');
if (count($dmi_cpu) == 0) {
$dmi_cpu = phodevi_solaris_parser::read_sun_ddu_dmi_info('ProcessorName');
}
if (count($dmi_cpu) > 0) {
$info = $dmi_cpu[0];
} else {
$info = trim(shell_exec('dmesg 2>&1 | grep cpu0'));
$info = trim(substr($info, strrpos($info, 'cpu0:') + 6));
if (empty($info)) {
$info = array_pop(phodevi_solaris_parser::read_sun_ddu_dmi_info('ProcessorManufacturer'));
}
}
//TODO: Add in proper support for reading multiple CPUs, similar to the code from above
$physical_cpu_count = count(phodevi_solaris_parser::read_sun_ddu_dmi_info('ProcessorSocketType'));
if ($physical_cpu_count > 1 && !empty($info)) {
// TODO: For now assuming when multiple CPUs are installed, that they are of the same type
$info = $physical_cpu_count . ' x ' . $info;
}
} else {
if (phodevi::is_bsd()) {
$info = phodevi_bsd_parser::read_sysctl('hw.model');
} else {
if (phodevi::is_macosx()) {
$info = phodevi_osx_parser::read_osx_system_profiler('SPHardwareDataType', 'ProcessorName');
} else {
if (phodevi::is_windows()) {
$info = phodevi_windows_parser::read_cpuz('Processor 1', 'Name');
if (!$info) {
$info = getenv('PROCESSOR_IDENTIFIER');
}
}
}
}
}
}
if (empty($info)) {
$info = 'Unknown';
} else {
if (($strip_point = strpos($info, '@')) > 0) {
$info = trim(substr($info, 0, $strip_point));
// stripping out the reported freq, since the CPU could be overclocked, etc
}
$info = pts_strings::strip_string($info);
// It seems Intel doesn't report its name when reporting Pentium hardware
if (strpos($info, 'Pentium') !== false && strpos($info, 'Intel') === false) {
$info = 'Intel ' . $info;
}
if (substr($info, 0, 5) == 'Intel') {
$cpu_words = explode(' ', $info);
$cpu_words_count = count($cpu_words);
// Convert strings like 'Intel Core i7 M 620' -> 'Intel Core i7 620M' and 'Intel Core i7 X 990' -> 'Intel Core i7 990X' to better reflect Intel product marketing names
//.........这里部分代码省略.........
示例7: sw_display_server
public static function sw_display_server()
{
$display_servers = array();
if (phodevi::is_windows()) {
// TODO: determine what to do for Windows support
} else {
if (pts_client::is_process_running('weston')) {
$info = 'Wayland Weston';
$vinfo = trim(shell_exec('weston --version 2>&1'));
if (pts_strings::last_in_string($vinfo) && pts_strings::is_version(pts_strings::last_in_string($vinfo))) {
$info .= ' ' . pts_strings::last_in_string($vinfo);
}
array_push($display_servers, $info);
}
if (pts_client::is_process_running('unity-system-compositor')) {
$unity_system_comp = trim(str_replace('unity-system-compositor', null, shell_exec('unity-system-compositor --version 2>&1')));
if (pts_strings::is_version($unity_system_comp)) {
array_push($display_servers, 'Unity-System-Compositor ' . $unity_system_comp);
}
}
if (($x_bin = is_executable('/usr/libexec/Xorg.bin') ? '/usr/libexec/Xorg.bin' : false) || ($x_bin = pts_client::executable_in_path('Xorg')) || ($x_bin = pts_client::executable_in_path('X'))) {
// Find graphics subsystem version
$info = shell_exec($x_bin . ' ' . (phodevi::is_solaris() ? ':0' : '') . ' -version 2>&1');
$pos = ($p = strrpos($info, 'Release Date')) !== false ? $p : strrpos($info, 'Build Date');
$info = trim(substr($info, 0, $pos));
if ($pos === false || getenv('DISPLAY') == false) {
$info = null;
} else {
if (($pos = strrpos($info, '(')) === false) {
$info = trim(substr($info, strrpos($info, ' ')));
} else {
$info = trim(substr($info, strrpos($info, 'Server') + 6));
}
}
if ($info != null) {
array_push($display_servers, 'X Server ' . $info);
}
}
if (pts_client::is_process_running('surfaceflinger')) {
array_push($display_servers, 'SurfaceFlinger');
}
if (pts_client::is_process_running('gnome-shell-wayland')) {
array_push($display_servers, 'GNOME Shell Wayland');
}
}
return implode(' + ', $display_servers);
}
示例8: motherboard_string
public static function motherboard_string()
{
// Returns the motherboard / system model name or number
$info = null;
if (phodevi::is_macosx()) {
$info = phodevi_osx_parser::read_osx_system_profiler('SPHardwareDataType', 'ModelName');
} else {
if (phodevi::is_solaris()) {
$manufacturer = phodevi_solaris_parser::read_sun_ddu_dmi_info(array('MotherBoardInformation,Manufacturer', 'SystemInformation,Manufacturer'));
$product = phodevi_solaris_parser::read_sun_ddu_dmi_info(array('MotherBoardInformation,Product', 'SystemInformation,Product', 'SystemInformation,Model'));
if (count($manufacturer) == 1 && count($product) == 1) {
$info = $manufacturer[0] . ' ' . $product[0];
}
} else {
if (phodevi::is_bsd()) {
$vendor = phodevi_bsd_parser::read_kenv('smbios.system.maker');
$product = phodevi_bsd_parser::read_kenv('smbios.system.product');
$version = phodevi_bsd_parser::read_kenv('smbios.system.version');
// for at least Lenovo ThinkPads this is where it displays ThinkPad model
if ($vendor != null && ($product != null || $version != null)) {
$info = $vendor . ' ' . $product . ' ' . $version;
} else {
if (($vendor = phodevi_bsd_parser::read_sysctl('hw.vendor')) != false && ($version = phodevi_bsd_parser::read_sysctl(array('hw.version', 'hw.product'))) != false) {
$info = trim($vendor . ' ' . $version);
} else {
if (($acpi = phodevi_bsd_parser::read_sysctl('dev.acpi.0.%desc')) != false) {
$info = trim($acpi);
}
}
}
} else {
if (phodevi::is_linux()) {
$vendor = phodevi_linux_parser::read_sys_dmi(array('board_vendor', 'sys_vendor'));
$name = phodevi_linux_parser::read_sys_dmi(array('board_name', 'product_name'));
$version = phodevi_linux_parser::read_sys_dmi(array('board_version', 'product_version'));
if ($vendor != false && $name != false) {
$info = strpos($name . ' ', $vendor . ' ') === false ? $vendor . ' ' : null;
$info .= $name;
if ($version != false && strpos($info, $version) === false && pts_strings::string_only_contains($version, pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DECIMAL)) {
$info .= (substr($version, 0, 1) == 'v' ? ' ' : ' v') . $version;
}
}
if (empty($info)) {
if ($info == null) {
$hw_string = phodevi_linux_parser::read_cpuinfo('Hardware');
if (count($hw_string) == 1) {
$info = $hw_string[0];
}
}
$bios_vendor = phodevi_linux_parser::read_sys_dmi('bios_vendor');
$bios_version = phodevi_linux_parser::read_sys_dmi('bios_version');
if ($bios_vendor != null) {
$info = $bios_vendor . ' ' . $bios_version;
}
if ($info == null) {
$hw_string = phodevi_linux_parser::read_cpuinfo('machine');
if (count($hw_string) == 1) {
$info = $hw_string[0];
}
}
}
if (empty($info)) {
$info = phodevi_linux_parser::read_sys_dmi('product_name');
}
if (empty($info) && is_file('/sys/bus/soc/devices/soc0/machine')) {
$info = pts_file_io::file_get_contents('/sys/bus/soc/devices/soc0/machine');
}
if (empty($info)) {
// Works on the MIPS Creator CI20
$hardware = phodevi_linux_parser::read_cpuinfo('Hardware');
if (!empty($hardware)) {
$info = array_pop($hardware);
}
}
} else {
if (phodevi::is_windows()) {
$info = phodevi_windows_parser::read_cpuz('Mainboard Model', null);
}
}
}
}
}
if ((strpos($info, 'Mac ') !== false || strpos($info, 'MacBook') !== false) && strpos($info, 'Apple') === false) {
$info = 'Apple ' . $info;
}
// ensure words aren't repeated (e.g. VMware VMware Virtual and MSI MSI X58M (MS-7593))
$info = implode(' ', array_unique(explode(' ', $info)));
return $info;
}
示例9: chipset_string
public static function chipset_string()
{
$info = false;
if (phodevi::is_macosx()) {
$sb_vendor = phodevi_osx_parser::read_osx_system_profiler('SPSerialATADataType', 'Vendor');
$sb_product = phodevi_osx_parser::read_osx_system_profiler('SPSerialATADataType', 'Product');
if ($sb_product == 'SSD') {
$sb_product = null;
}
if (($cut_point = strpos($sb_product, ' ')) > 0) {
$sb_product = substr($sb_product, 0, $cut_point);
}
// TODO: Can't find Northbridge
$info = $sb_vendor . ' ' . $sb_product;
} else {
if (phodevi::is_windows()) {
$info = phodevi_windows_parser::read_cpuz('Northbridge', null);
if ($info != null) {
if (($e = strpos($info, 'rev')) !== false) {
$info = substr($info, 0, $e);
}
$info = trim($info);
}
} else {
if (phodevi::is_solaris()) {
// Vendor Detection
$vendor_possible_udis = array('/org/freedesktop/Hal/devices/pci_0_0/pci_ide_3_2_0', '/org/freedesktop/Hal/devices/pci_0_0/pci_ide_1f_1_1');
$info = phodevi_solaris_parser::read_hal_property($vendor_possible_udis, 'info.vendor');
// TODO: Northbridge and Southbridge Detection For Solaris
} else {
if (phodevi::is_linux() || phodevi::is_hurd()) {
$info = phodevi_linux_parser::read_pci(array('RAM memory', 'Host bridge'));
if (count(explode(' ', $info)) == 1) {
$bridge = phodevi_linux_parser::read_pci(array('Bridge', 'PCI bridge'));
if (!empty($bridge)) {
$match = false;
$break_words = array('Ethernet', 'PCI', 'High', 'USB');
for ($i = 0; $i < count($break_words) && !$match; $i++) {
if (($pos = strpos($bridge, $break_words[$i])) > 0) {
$bridge = trim(substr($bridge, 0, $pos));
$info = $bridge;
$match = true;
}
}
}
}
if (!isset($bridge) || !empty($bridge)) {
// Attempt to detect Southbridge (if applicable)
$southbridge = phodevi_linux_parser::read_pci(array('ISA bridge', 'SATA controller'), false);
$southbridge_clean = null;
if (($start_cut = strpos($southbridge, '(')) > 0 && ($end_cut = strpos($southbridge, ')', $start_cut + 1)) > 0) {
$southbridge_extract = substr($southbridge, $start_cut + 1, $end_cut - $start_cut - 1);
if (strpos($southbridge_extract, 'rev') === false) {
$southbridge_extract = explode(' ', $southbridge_extract);
$southbridge_clean = $southbridge_extract[0];
} else {
if (($s = strpos($southbridge, 'ICH')) > 0) {
$southbridge_extract = substr($southbridge, $s);
$southbridge_clean = substr($southbridge_extract, 0, strpos($southbridge_extract, ' '));
}
}
} else {
if (($start_cut = strpos($southbridge, 'SB')) !== false) {
$southbridge_extract = substr($southbridge, $start_cut);
$southbridge_clean = substr($southbridge_extract, 0, strpos($southbridge_extract, ' '));
}
}
if (!empty($southbridge_clean) && $southbridge_clean != 'SB') {
$info .= ' + ' . $southbridge_clean;
}
}
}
}
}
}
return $info;
}
示例10: sys_battery_power
private static function sys_battery_power()
{
// Returns power consumption rate in mW
$rate = -1;
if (phodevi::is_linux()) {
$power_now = phodevi_linux_parser::read_sysfs_node('/sys/class/power_supply/*/power_now', 'POSITIVE_NUMERIC', array('status' => 'Discharging'));
if ($power_now != -1) {
// sysfs power_now seems to be displayed in microWatts
$rate = pts_math::set_precision($power_now / 1000, 2);
}
if ($rate == -1) {
$battery = array('/battery/BAT0/state', '/battery/BAT1/state');
$state = phodevi_linux_parser::read_acpi($battery, 'charging state');
$power = phodevi_linux_parser::read_acpi($battery, 'present rate');
$voltage = phodevi_linux_parser::read_acpi($battery, 'present voltage');
if ($state == 'discharging') {
$power_unit = substr($power, strrpos($power, ' ') + 1);
$power = substr($power, 0, strpos($power, ' '));
if ($power_unit == 'mA') {
$voltage_unit = substr($voltage, strrpos($voltage, ' ') + 1);
$voltage = substr($voltage, 0, strpos($voltage, ' '));
if ($voltage_unit == 'mV') {
$rate = round($power * $voltage / 1000);
}
} else {
if ($power_unit == 'mW') {
$rate = $power;
}
}
}
}
if ($rate == -1 && is_file('/sys/class/power_supply/BAT0/voltage_now') && is_file('/sys/class/power_supply/BAT0/current_now')) {
$voltage_now = pts_file_io::file_get_contents('/sys/class/power_supply/BAT0/voltage_now') / 1000;
$current_now = pts_file_io::file_get_contents('/sys/class/power_supply/BAT0/current_now') / 1000;
$power_now = $voltage_now * $current_now / 1000;
if ($power_now > 1) {
$rate = $power_now;
}
}
if ($rate == -1 && is_file('/sys/class/power_supply/BAT1/voltage_now') && is_file('/sys/class/power_supply/BAT1/current_now')) {
$voltage_now = pts_file_io::file_get_contents('/sys/class/power_supply/BAT1/voltage_now') / 1000;
$current_now = pts_file_io::file_get_contents('/sys/class/power_supply/BAT1/current_now') / 1000;
$power_now = $voltage_now * $current_now / 1000;
if ($power_now > 1) {
$rate = $power_now;
}
}
} else {
if (phodevi::is_macosx()) {
$amperage = abs(phodevi_osx_parser::read_osx_system_profiler('SPPowerDataType', 'Amperage'));
// in mA
$voltage = phodevi_osx_parser::read_osx_system_profiler('SPPowerDataType', 'Voltage');
// in mV
if ($amperage > 0 && $voltage > 0) {
$rate = round($amperage * $voltage / 1000);
} else {
if (pts_client::executable_in_path('ioreg')) {
$ioreg = trim(shell_exec("ioreg -l | grep LegacyBatteryInfo | cut -d '{' -f 2 | tr -d \\} | tr ',' '=' | awk -F'=' '{print (\$2*\$10/10^22)}' 2>&1"));
if (is_numeric($ioreg) && $ioreg > 0) {
$rate = $ioreg;
}
}
}
} else {
if (phodevi::is_solaris()) {
$battery = phodevi_solaris_parser::read_hal_property('/org/freedesktop/Hal/devices/pseudo/acpi_drv_0_battery0_0', 'battery.reporting.rate');
if (is_numeric($battery)) {
$rate = $battery;
}
} else {
if (phodevi::is_bsd()) {
$battery = phodevi_bsd_parser::read_acpiconf('Present rate');
if ($battery && substr($battery, -2) == 'mW') {
$rate = substr($battery, 0, strpos($battery, ' '));
}
}
}
}
}
return $rate;
}
示例11: gpu_model
public static function gpu_model()
{
// Report graphics processor string
$info = phodevi_parser::read_glx_renderer();
$video_ram = phodevi::read_property('gpu', 'memory-capacity');
if (phodevi::is_ati_graphics() && phodevi::is_linux()) {
$crossfire_status = phodevi_linux_parser::read_amd_pcsdb('SYSTEM/Crossfire/chain/*,Enable');
$crossfire_status = pts_arrays::to_array($crossfire_status);
$crossfire_card_count = 0;
for ($i = 0; $i < count($crossfire_status); $i++) {
if ($crossfire_status[$i] == '0x00000001') {
$crossfire_card_count += 2;
// For now assume each chain is 2 cards, but proper way would be NumSlaves + 1
}
}
$adapters = phodevi_linux_parser::read_amd_graphics_adapters();
if (count($adapters) > 0) {
$video_ram = $video_ram > 64 ? ' ' . $video_ram . 'MB' : null;
// assume more than 64MB of vRAM
if ($crossfire_card_count > 1 && $crossfire_card_count <= count($adapters)) {
$unique_adapters = array_unique($adapters);
if (count($unique_adapters) == 1) {
if (strpos($adapters[0], 'X2') > 0 && $crossfire_card_count > 1) {
$crossfire_card_count -= 1;
}
$info = $crossfire_card_count . ' x ' . $adapters[0] . $video_ram . ' CrossFire';
} else {
$info = implode(', ', $unique_adapters) . ' CrossFire';
}
} else {
$info = $adapters[0] . $video_ram;
}
}
} else {
if (phodevi::is_macosx()) {
$system_profiler_info = implode(' + ', phodevi_osx_parser::read_osx_system_profiler('SPDisplaysDataType', 'ChipsetModel', true));
if (!empty($system_profiler_info)) {
$info = $system_profiler_info;
}
} else {
if (phodevi::is_nvidia_graphics()) {
if ($info == null) {
if (pts_client::executable_in_path('nvidia-settings')) {
$nv_gpus = shell_exec('nvidia-settings -q gpus 2>&1');
// TODO: search for more than one GPU
$nv_gpus = substr($nv_gpus, strpos($nv_gpus, '[0]'));
$nv_gpus = substr($nv_gpus, strpos($nv_gpus, '(') + 1);
$nv_gpus = substr($nv_gpus, 0, strpos($nv_gpus, ')'));
if (stripos($nv_gpus, 'GeForce') !== false || stripos($nv_gpus, 'Quadro') !== false) {
$info = $nv_gpus;
}
}
}
$sli_mode = phodevi_parser::read_nvidia_extension('SLIMode');
if (!empty($sli_mode) && $sli_mode != 'Off') {
$info .= ' SLI';
}
} else {
if (phodevi::is_solaris()) {
if (($cut = strpos($info, 'DRI ')) !== false) {
$info = substr($info, $cut + 4);
}
if (($cut = strpos($info, ' Chipset')) !== false) {
$info = substr($info, 0, $cut);
}
if ($info == false && isset(phodevi::$vfs->xorg_log)) {
$xorg_log = phodevi::$vfs->xorg_log;
if (($x = strpos($xorg_log, '(0): Chipset: ')) !== false) {
$xorg_log = substr($xorg_log, $x + 14);
$xorg_log = str_replace(array('(R)', '"'), null, substr($xorg_log, 0, strpos($xorg_log, PHP_EOL)));
if (($c = strpos($xorg_log, '[')) || ($c = strpos($xorg_log, '('))) {
$xorg_log = substr($xorg_log, 0, $c);
}
if (phodevi::is_product_string($xorg_log)) {
$info = $xorg_log;
}
}
}
} else {
if (phodevi::is_bsd()) {
$drm_info = phodevi_bsd_parser::read_sysctl('dev.drm.0.%desc');
if (!$drm_info) {
$drm_info = phodevi_bsd_parser::read_sysctl('dev.nvidia.0.%desc');
}
if (!$drm_info) {
$agp_info = phodevi_bsd_parser::read_sysctl('dev.agp.0.%desc');
if ($agp_info != false) {
$info = $agp_info;
}
} else {
$info = $drm_info;
}
if ($info == null && isset(phodevi::$vfs->xorg_log)) {
$xorg_log = phodevi::$vfs->xorg_log;
if (($e = strpos($xorg_log, ' at 01@00:00:0')) !== false) {
$xorg_log = substr($xorg_log, 0, $e);
$info = substr($xorg_log, strrpos($xorg_log, 'Found ') + 6);
}
}
} else {
//.........这里部分代码省略.........
示例12: memory_capacity
public static function memory_capacity()
{
// Returns physical memory capacity
if (isset(phodevi::$vfs->meminfo)) {
$info = phodevi::$vfs->meminfo;
$info = substr($info, strpos($info, 'MemTotal:') + 9);
$info = intval(trim(substr($info, 0, strpos($info, 'kB'))));
$info = floor($info / 1024);
if (is_numeric($info) && $info > 950) {
if ($info > 4608) {
$info = ceil($info / 1024) * 1024;
} else {
if ($info > 1536) {
$info = ceil($info / 512) * 512;
} else {
$info = ceil($info / 256) * 256;
}
}
}
} else {
if (phodevi::is_solaris()) {
$info = shell_exec('prtconf 2>&1 | grep Memory');
$info = substr($info, strpos($info, ':') + 2);
$info = substr($info, 0, strpos($info, 'Megabytes'));
} else {
if (phodevi::is_bsd()) {
$mem_size = phodevi_bsd_parser::read_sysctl('hw.physmem');
if ($mem_size == false) {
$mem_size = phodevi_bsd_parser::read_sysctl('hw.realmem');
}
$info = ceil(floor($mem_size / 1048576) / 256) * 256;
} else {
if (phodevi::is_macosx()) {
$info = phodevi_osx_parser::read_osx_system_profiler('SPHardwareDataType', 'Memory');
$info = explode(' ', $info);
$info = isset($info[1]) && $info[1] == 'GB' ? $info[0] * 1024 : $info[0];
} else {
if (phodevi::is_windows()) {
$info = phodevi_windows_parser::read_cpuz('Memory Size', null);
if ($info != null) {
if (($e = strpos($info, ' MBytes')) !== false) {
$info = substr($info, 0, $e);
}
$info = trim($info);
}
} else {
$info = null;
}
}
}
}
}
return $info;
}
示例13: hdd_string
public static function hdd_string()
{
$disks = array();
if (phodevi::is_macosx()) {
// TODO: Support reading non-SATA drives and more than one drive
$capacity = phodevi_osx_parser::read_osx_system_profiler('SPSerialATADataType', 'Capacity');
$model = phodevi_osx_parser::read_osx_system_profiler('SPSerialATADataType', 'Model');
if (($cut = strpos($capacity, ' (')) !== false) {
$capacity = substr($capacity, 0, $cut);
}
if (($cut = strpos($capacity, ' ')) !== false) {
if (is_numeric(substr($capacity, 0, $cut))) {
$capacity = floor(substr($capacity, 0, $cut)) . substr($capacity, $cut);
}
}
$capacity = str_replace(' GB', 'GB', $capacity);
if (!empty($capacity) && !empty($model)) {
$disks = array($capacity . ' ' . $model);
}
} else {
if (phodevi::is_bsd()) {
$i = 0;
do {
$disk = phodevi_bsd_parser::read_sysctl('dev.ad.' . $i . '.%desc');
if ($disk != false && strpos($disk, 'DVD') === false && strpos($disk, 'ATAPI') === false) {
array_push($disks, $disk);
}
$i++;
} while (($disk != false || $i < 9) && $i < 128);
// On some systems, the first drive seems to be at dev.ad.8 rather than starting at dev.ad.0
if (empty($disks) && pts_client::executable_in_path('camcontrol')) {
$camcontrol = trim(shell_exec('camcontrol devlist 2>&1'));
foreach (explode(PHP_EOL, $camcontrol) as $line) {
if (substr($line, 0, 1) == '<' && ($model_end = strpos($line, '>')) !== false && strpos($line, 'DVD') === false && strpos($line, 'ATAPI') === false) {
$disk = self::prepend_disk_vendor(substr($line, 1, $model_end - 1));
array_push($disks, $disk);
}
}
}
} else {
if (phodevi::is_solaris()) {
if (is_executable('/usr/ddu/bin/i386/hd_detect')) {
$hd_detect = explode(PHP_EOL, trim(shell_exec('/usr/ddu/bin/i386/hd_detect -l 2>&1')));
foreach ($hd_detect as $hd_line) {
if (isset($hd_line) && ($hd_pos = strpos($hd_line, ':/')) != false) {
$disk = trim(substr($hd_line, 0, $hd_pos));
$disk = self::prepend_disk_vendor($disk);
if ($disk != 'blkdev') {
array_push($disks, $disk);
}
}
}
}
} else {
if (phodevi::is_linux()) {
$disks_formatted = array();
$disks = array();
foreach (array_merge(pts_file_io::glob('/sys/block/sd*'), pts_file_io::glob('/sys/block/mmcblk*')) as $sdx) {
if (strpos($sdx, 'boot') !== false) {
// Don't include devices like /sys/block/mmcblk0boot[0,1] as it's repeat of /sys/block/mmcblk0
continue;
}
if ((is_file($sdx . '/device/name') || is_file($sdx . '/device/model')) && is_file($sdx . '/size')) {
$disk_size = pts_file_io::file_get_contents($sdx . '/size');
$disk_model = pts_file_io::file_get_contents($sdx . (is_file($sdx . '/device/model') ? '/device/model' : '/device/name'));
$disk_removable = pts_file_io::file_get_contents($sdx . '/removable');
if ($disk_removable == '1') {
// Don't count removable disks
continue;
}
$disk_size = round($disk_size * 512 / 1000000000) . 'GB';
$disk_model = self::prepend_disk_vendor($disk_model);
if (strpos($disk_model, $disk_size . ' ') === false && strpos($disk_model, ' ' . $disk_size) === false && $disk_size != '1GB') {
$disk_model = $disk_size . ' ' . $disk_model;
}
if ($disk_size > 0) {
array_push($disks_formatted, $disk_model);
}
}
}
for ($i = 0; $i < count($disks_formatted); $i++) {
if (!empty($disks_formatted[$i])) {
$times_found = 1;
for ($j = $i + 1; $j < count($disks_formatted); $j++) {
if ($disks_formatted[$i] == $disks_formatted[$j]) {
$times_found++;
$disks_formatted[$j] = '';
}
}
$disk = ($times_found > 1 ? $times_found . ' x ' : null) . $disks_formatted[$i];
array_push($disks, $disk);
}
}
}
}
}
}
if (count($disks) == 0) {
$root_disk_size = ceil(disk_total_space('/') / 1073741824);
$pts_disk_size = ceil(disk_total_space(pts_client::test_install_root_path()) / 1073741824);
//.........这里部分代码省略.........