public static function network_device_string() { $network = array(); if (phodevi::is_macosx()) { // TODO: implement } else { if (phodevi::is_bsd()) { foreach (array('dev.em.0.%desc', 'dev.wpi.0.%desc', 'dev.mskc.0.%desc') as $controller) { $pci = phodevi_bsd_parser::read_sysctl($controller); if (!empty($pci)) { array_push($network, $pci); } } } else { if (phodevi::is_windows()) { // TODO: implement } else { if (phodevi::is_linux()) { foreach (array('Ethernet controller', 'Network controller') as $controller) { $pci = phodevi_linux_parser::read_pci($controller); if (!empty($pci)) { array_push($network, $pci); } } } } } } return implode(' + ', $network); }
public static function __pre_run_process() { self::$error_count = 0; self::$error_pointer = 0; self::$error_analysis = array(); // Store the video resolution // Access the xrandr resolution directly to ensure it's not polling the FB size or one of the KMS modes self::$start_video_resolution = phodevi_gpu::gpu_xrandr_resolution(); if (phodevi::is_linux() && phodevi::is_ati_graphics()) { $vsync_val = phodevi_linux_parser::read_amd_pcsdb('AMDPCSROOT/SYSTEM/BUSID-*/OpenGL,VSyncControl'); // Check for vSync if ($vsync_val == '0x00000002' || $vsync_val == '0x00000003') { self::$driver_forced_vsync = true; } //$catalyst_ai_val = phodevi_linux_parser::read_amd_pcsdb('AMDPCSROOT/SYSTEM/BUSID-*/OpenGL,CatalystAI'); // Check for Catalyst AI //if($catalyst_ai_val == '0x00000001' || $catalyst_ai_val == '0x00000002') // echo '\nCatalyst AI is enabled, which will use driver-specific optimizations in some tests that may offer extra performance enhancements.\n'; } else { if (phodevi::is_nvidia_graphics()) { self::$error_pointer = self::nvidia_gpu_error_count(); // Set the error pointer if (phodevi_parser::read_nvidia_extension('SyncToVBlank') == '1') { shell_exec('nvidia-settings -a SyncToVBlank=0 2>&1'); self::$driver_forced_vsync = true; } } } if (self::$driver_forced_vsync == true) { // echo '\nYour video driver is forcing vertical sync to be enabled. This will limit the system's frame-rate performance potential in any graphical tests!\n'; } // vblank_mode=0 has long been set within pts-core, but put it here too just since there's these other checks here putenv('vblank_mode=0'); }
public function read_sensor() { $voltage = -1; if (phodevi::is_linux()) { $voltage = $this->cpu_voltage_linux(); } return $voltage; }
public function read_sensor() { $fan_speed = -1; if (phodevi::is_linux()) { $fan_speed = $this->sys_fanspeed_linux(); } return $fan_speed; }
public function read_sensor() { $swap_usage = -1; if (phodevi::is_linux()) { $swap_usage = self::swap_usage_linux(); } return $swap_usage; }
public function read_sensor() { $temp = -1; if (phodevi::is_linux()) { $temp = $this->hdd_temp_linux(); } return pts_math::set_precision($temp, 2); }
public function read_sensor() { $write_speed = -1; if (phodevi::is_linux()) { $write_speed = $this->hdd_write_speed_linux(); } return pts_math::set_precision($write_speed, 2); }
public function read_sensor() { $iowait = -1; if (phodevi::is_linux()) { $iowait = $this->sys_iowait_linux(); } return $iowait; }
private function mem_usage() { if (phodevi::is_linux()) { return self::mem_usage_linux(); } elseif (phodevi::is_macosx() || phodevi::is_bsd()) { return self::mem_usage_bsd('MEMORY', 'USED'); } }
public function read_sensor() { if (phodevi::is_linux()) { return $this->cpu_power_linux(); } return -1; // TODO make -1 a named constant }
public static function read_sensor() { // Read the processor temperature $temp_c = -1; if (phodevi::is_bsd()) { $cpu_temp = phodevi_bsd_parser::read_sysctl(array('hw.sensors.acpi_tz0.temp0', 'dev.cpu.0.temperature', 'hw.sensors.cpu0.temp0')); if ($cpu_temp != false) { if (($end = strpos($cpu_temp, 'degC')) || ($end = strpos($cpu_temp, 'C')) > 0) { $cpu_temp = substr($cpu_temp, 0, $end); } if (is_numeric($cpu_temp)) { $temp_c = $cpu_temp; } } else { $acpi = phodevi_bsd_parser::read_sysctl('hw.acpi.thermal.tz0.temperature'); if (($end = strpos($acpi, 'C')) > 0) { $acpi = substr($acpi, 0, $end); } if (is_numeric($acpi)) { $temp_c = $acpi; } } } else { if (phodevi::is_linux()) { // Try hwmon interface $raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp1_input', 'POSITIVE_NUMERIC', array('name' => 'coretemp')); if ($raw_temp == -1) { $raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp1_input', 'POSITIVE_NUMERIC', array('name' => 'k10temp')); } if ($raw_temp == -1) { // Try ACPI thermal // Assuming the system thermal sensor comes 2nd to the ACPI CPU temperature // It appears that way on a ThinkPad T60, but TODO find a better way to validate $raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/thermal/thermal_zone*/temp', 'POSITIVE_NUMERIC', null, 2); } if ($raw_temp != -1) { if ($raw_temp > 1000) { $raw_temp = $raw_temp / 1000; } $temp_c = pts_math::set_precision($raw_temp, 2); } if ($temp_c == -1) { // Try LM_Sensors $sensors = phodevi_linux_parser::read_sensors(array('CPU Temp', 'Core 0', 'Core0 Temp', 'Core1 Temp')); if ($sensors != false && is_numeric($sensors) && $sensors > 0) { $temp_c = $sensors; } } if (pts_client::executable_in_path('ipmitool')) { $ipmi = phodevi_linux_parser::read_ipmitool_sensor('Temp 0'); if ($ipmi > 0 && is_numeric($ipmi)) { $temp_c = $ipmi; } } } } return $temp_c; }
public static function read_sensor() { if (phodevi::is_linux()) { $sensor = phodevi_linux_parser::read_sensors('VCore'); } else { $sensor = -1; } return $sensor; }
public static function read_sensor() { if (phodevi::is_linux()) { $sensor = phodevi_linux_parser::read_sensors(array('V5', '+5V')); } else { $sensor = -1; } return $sensor; }
public function read_sensor() { $sys_temp = -1; if (phodevi::is_linux()) { $sys_temp = $this->sys_temp_linux(); } elseif (phodevi::is_bsd()) { $sys_temp = $this->sys_temp_bsd(); } return $sys_temp; }
public static function __run_manager_setup(&$test_run_manager) { // Verify LINUX_PERF is set, `perf` can be found, and is Linux if (getenv('LINUX_PERF') == 0 || !pts_client::executable_in_path('perf') || !phodevi::is_linux()) { return pts_module::MODULE_UNLOAD; // This module doesn't have anything else to do } echo PHP_EOL . 'Linux PERF Monitoring Enabled.' . PHP_EOL . PHP_EOL; // This module won't be too useful if you're not saving the results to see the graphs $test_run_manager->force_results_save(); }
public static function support_check() { if (phodevi::is_ati_graphics() && phodevi::is_linux()) { $gpu_usage = self::ati_overdrive_core_usage(); if (is_numeric($gpu_usage)) { self::$probe_ati_overdrive = true; return true; } } else { if (phodevi::is_mesa_graphics()) { if (pts_client::executable_in_path('radeontop')) { $test = self::radeontop_gpu_usage(); if (is_numeric($test) && $test >= 0) { self::$probe_radeontop = true; return true; } } else { if (is_readable('/sys/kernel/debug/dri/0/radeon_fence_info')) { $fence_speed = self::radeon_fence_speed(); if (is_numeric($fence_speed) && $fence_speed >= 0) { self::$probe_radeon_fences = true; return true; } } else { if (is_readable('/sys/kernel/debug/dri/0/i915_gem_seqno')) { $commands = self::intel_command_speed(); if (is_numeric($commands) && $commands > 0) { self::$probe_intel_commands = true; return true; } } } } } else { if (phodevi::is_nvidia_graphics()) { $util = self::read_nvidia_settings_gpu_utilization(); if ($util !== false) { self::$probe_nvidia_settings = true; return true; } else { if (pts_client::executable_in_path('nvidia-smi')) { $usage = self::nvidia_core_usage(); if (is_numeric($usage) && $usage >= 0 && $usage <= 100) { self::$probe_nvidia_smi = true; return true; } } } } } } return false; }
public static function read_sensor() { // Reads the system's temperature $temp_c = -1; if (phodevi::is_linux()) { $raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp3_input', 'POSITIVE_NUMERIC', array('name' => '!coretemp,!radeon,!nouveau')); if ($raw_temp == -1) { $raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp2_input', 'POSITIVE_NUMERIC', array('name' => '!coretemp,!radeon,!nouveau')); } if ($raw_temp == -1) { $raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp1_input', 'POSITIVE_NUMERIC', array('name' => '!coretemp,!radeon,!nouveau')); } if ($raw_temp == -1) { $raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/temp1_input', 'POSITIVE_NUMERIC'); } if ($raw_temp != -1) { if ($raw_temp > 1000) { $raw_temp = $raw_temp / 1000; } $temp_c = pts_math::set_precision($raw_temp, 2); } if ($temp_c == -1) { $acpi = phodevi_linux_parser::read_acpi(array('/thermal_zone/THM1/temperature', '/thermal_zone/TZ00/temperature', '/thermal_zone/TZ01/temperature'), 'temperature'); if (($end = strpos($acpi, ' ')) > 0) { $temp_c = substr($acpi, 0, $end); } } if ($temp_c == -1) { $sensors = phodevi_linux_parser::read_sensors(array('Sys Temp', 'Board Temp')); if ($sensors != false && is_numeric($sensors)) { $temp_c = $sensors; } } if ($temp_c == -1 && is_file('/sys/class/thermal/thermal_zone0/temp')) { $temp_c = pts_file_io::file_get_contents('/sys/class/thermal/thermal_zone0/temp'); if ($temp_c > 1000) { $temp_c = pts_math::set_precision($temp_c / 1000, 1); } } } else { if (phodevi::is_bsd()) { $acpi = phodevi_bsd_parser::read_sysctl(array('hw.sensors.acpi_tz1.temp0', 'hw.acpi.thermal.tz1.temperature')); if (($end = strpos($acpi, ' degC')) > 0 || ($end = strpos($acpi, 'C')) > 0) { $acpi = substr($acpi, 0, $end); if (is_numeric($acpi)) { $temp_c = $acpi; } } } } return $temp_c; }
public function read_sensor() { // Read the processor temperature $temp_c = -1; if (phodevi::is_bsd()) { $temp_c = $this->cpu_temp_bsd(); } else { if (phodevi::is_linux()) { $temp_c = $this->cpu_temp_linux(); } } return $temp_c; }
public static function read_sensor() { $fan_speed = -1; if (phodevi::is_linux()) { $raw_fan = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/fan1_input', 'POSITIVE_NUMERIC'); if ($raw_fan == -1) { $raw_fan = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/fan1_input', 'POSITIVE_NUMERIC'); } if ($raw_fan != -1) { $fan_speed = $raw_fan; } } return $fan_speed; }
public function read_sensor() { $sensor = -1; if (phodevi::is_linux()) { if ($this->voltage_to_monitor == '12v') { $sensor = phodevi_linux_parser::read_sensors(array('V12', '+12V')); } elseif ($this->voltage_to_monitor == '5v') { $sensor = phodevi_linux_parser::read_sensors(array('V5', '+5V')); } elseif ($this->voltage_to_monitor == '3v') { $sensor = phodevi_linux_parser::read_sensors(array('V3.3', '+3.3V')); } } return $sensor; }
public static function cpu_core_count() { $info = null; if (getenv('PTS_NPROC') && is_numeric(getenv('PTS_NPROC'))) { $info = getenv('PTS_NPROC'); } else { if (getenv('NUMBER_OF_PROCESSORS') && is_numeric(getenv('NUMBER_OF_PROCESSORS'))) { // Should be used by Windows they have NUMBER_OF_PROCESSORS set and use this as an easy way to override CPUs exposed $info = getenv('NUMBER_OF_PROCESSORS'); } else { if (phodevi::is_linux()) { if (is_file('/sys/devices/system/cpu/online')) { $present = pts_file_io::file_get_contents('/sys/devices/system/cpu/online'); if (isset($present[2]) && substr($present, 0, 2) == '0-') { $present = substr($present, 2); if (is_numeric($present)) { $info = $present + 1; } } } } else { if (phodevi::is_solaris()) { $info = count(explode(PHP_EOL, trim(shell_exec('psrinfo')))); } else { if (phodevi::is_bsd()) { $info = intval(phodevi_bsd_parser::read_sysctl(array('hw.ncpufound', 'hw.ncpu'))); } else { if (phodevi::is_macosx()) { $info = intval(phodevi_bsd_parser::read_sysctl(array('hw.ncpu'))); if (empty($info)) { $info = phodevi_osx_parser::read_osx_system_profiler('SPHardwareDataType', 'TotalNumberOfCores'); } } else { if (phodevi::is_windows()) { // Should be hit by the first NUMBER_OF_PROCESSORS env check... //$info = getenv('NUMBER_OF_PROCESSORS'); } } } } } } } if ($info == null && isset(phodevi::$vfs->cpuinfo)) { $info = self::cpuinfo_core_count(); } return is_numeric($info) && $info > 0 ? $info : 1; }
public function read_sensor() { // Report graphics processor fan speed as a percent $fan_speed = -1; if (phodevi::is_nvidia_graphics()) { // NVIDIA fan speed reading support in NVIDIA 190.xx and newer // TODO: support for multiple fans, also for reading GPUFanTarget to get appropriate fan // nvidia-settings --describe GPUFanTarget $fan_speed = phodevi_parser::read_nvidia_extension('[fan:0]/GPUCurrentFanSpeed'); } else { if (phodevi::is_ati_graphics() && phodevi::is_linux()) { $fan_speed = phodevi_linux_parser::read_ati_overdrive('FanSpeed'); } } return $fan_speed; }
public static function get_supported_devices() { if (phodevi::is_linux()) { //TODO write network_usage_linux function // $iface_list = shell_exec("ls -1 /sys/class/net | grep -v lo"); // $iface_array = explode("\n", $iface_list); // // return $iface_array; return NULL; } if (phodevi::is_bsd() || phodevi::is_macosx()) { $iface_list = shell_exec("ifconfig -lu | tr ' ' '\n' | grep -v 'lo0'"); $iface_array = pts_strings::trim_explode(" ", $iface_list); return $iface_array; } return NULL; }
public static function read_sensor() { $iowait = -1; if (phodevi::is_linux() && is_file('/proc/stat')) { $start_stat = pts_file_io::file_get_contents('/proc/stat'); sleep(1); $end_stat = pts_file_io::file_get_contents('/proc/stat'); $start_stat = explode(' ', substr($start_stat, 0, strpos($start_stat, "\n"))); $end_stat = explode(' ', substr($end_stat, 0, strpos($end_stat, "\n"))); for ($i = 2, $diff_cpu_total = 0; $i < 9; $i++) { $diff_cpu_total += $end_stat[$i] - $start_stat[$i]; } $diff_iowait = $end_stat[6] - $start_stat[6]; $iowait = pts_math::set_precision(1000 * $diff_iowait / $diff_cpu_total / 10, 2); } return $iowait; }
public static function audio_processor_string() { $audio = null; if (phodevi::is_macosx()) { // TODO: implement } else { if (phodevi::is_bsd()) { foreach (array('dev.hdac.0.%desc') as $dev) { $dev = phodevi_bsd_parser::read_sysctl($dev); if (!empty($dev)) { $audio = $dev; } } } else { if (phodevi::is_windows()) { // TODO: implement } else { if (phodevi::is_linux()) { foreach (pts_file_io::glob('/sys/class/sound/card*/hwC0D*/vendor_name') as $vendor_name) { $card_dir = dirname($vendor_name) . '/'; if (!is_readable($card_dir . 'chip_name')) { continue; } $vendor_name = pts_file_io::file_get_contents($vendor_name); $chip_name = pts_file_io::file_get_contents($card_dir . 'chip_name'); $audio = $vendor_name . ' ' . $chip_name; if (strpos($chip_name, 'HDMI') !== false || strpos($chip_name, 'DP') !== false) { // If HDMI is in the audio string, likely the GPU-provided audio, so try to find the mainboard otherwise $audio = null; } else { break; } } if ($audio == null) { $audio = phodevi_linux_parser::read_pci('Multimedia audio controller'); } if ($audio == null) { $audio = phodevi_linux_parser::read_pci('Audio device'); } } } } } return $audio; }
public static function read_sensor() { // Read the processor power consumption (not the overall system power consumption exposed by sys.power sensor) $cpu_watts = -1; if (phodevi::is_linux()) { // Try hwmon interface for AMD 15h (Bulldozer FX CPUs) where this support was introduced for AMD CPUs and exposed by the fam15h_power hwmon driver // The fam15h_power driver doesn't expose the power consumption on a per-core/per-package basis but only an average $hwmon_watts = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/power1_input', 'POSITIVE_NUMERIC', array('name' => 'fam15h_power')); if ($hwmon_watts != -1) { if ($hwmon_watts > 1000000) { // convert to Watts $hwmon_watts = $hwmon_watts / 1000000; } $cpu_watts = pts_math::set_precision($hwmon_watts, 2); } } return $cpu_watts; }
public static function read_sensor() { // speed in MB/s $speed = -1; if (phodevi::is_linux()) { static $sys_disk = null; if ($sys_disk == null) { foreach (pts_file_io::glob('/sys/class/block/sd*/stat') as $check_disk) { if (pts_file_io::file_get_contents($check_disk) != null) { $sys_disk = $check_disk; break; } } } $speed = phodevi_linux_parser::read_sys_disk_speed($sys_disk, 'READ'); } return $speed; }
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); }
public static function read_sensor() { // Report graphics processor temperature $temp_c = -1; if (phodevi::is_nvidia_graphics()) { $temp_c = phodevi_parser::read_nvidia_extension('GPUCoreTemp'); } else { if (phodevi::is_ati_graphics() && phodevi::is_linux()) { $temp_c = phodevi_linux_parser::read_ati_overdrive('Temperature'); } else { foreach (array_merge(array('/sys/class/drm/card0/device/temp1_input'), pts_file_io::glob('/sys/class/drm/card0/device/hwmon/hwmon*/temp1_input')) as $temp_input) { // This works for at least Nouveau driver with Linux 2.6.37 era DRM if (is_readable($temp_input) == false) { continue; } $temp_input = pts_file_io::file_get_contents($temp_input); if (is_numeric($temp_input)) { if ($temp_input > 1000) { $temp_input /= 1000; } $temp_c = $temp_input; break; } } if ($temp_c == -1 && is_readable('/sys/kernel/debug/dri/0/i915_emon_status')) { // Intel thermal $i915_emon_status = file_get_contents('/sys/kernel/debug/dri/0/i915_emon_status'); $temp = strpos($i915_emon_status, 'GMCH temp: '); if ($temp !== false) { $temp = substr($i915_emon_status, $temp + 11); $temp = substr($temp, 0, strpos($temp, PHP_EOL)); if (is_numeric($temp) && $temp > 0) { $temp_c = $temp; } } } } } if ($temp_c > 1000 || $temp_c < 9) { // Invalid data return -1; } return $temp_c; }
private function set_probe_mode() { if (phodevi::is_ati_graphics() && phodevi::is_linux()) { $this->probe_ati_overdrive = true; } else { if (phodevi::is_mesa_graphics() && pts_client::executable_in_path('radeontop')) { $this->probe_radeontop = true; } else { if (phodevi::is_nvidia_graphics()) { $util = $this->read_nvidia_settings_gpu_utilization(); if ($util !== false) { $this->probe_nvidia_settings = true; } else { if (pts_client::executable_in_path('nvidia-smi')) { $this->probe_nvidia_smi = true; } } } } } }