From df3b67867982dfd7f4a0a0d7a7a05d1d8c916b1b Mon Sep 17 00:00:00 2001 From: Michael Larabel Date: Mon, 23 Jun 2008 11:08:04 -0400 Subject: Move all sensor monitoring code from pts-core to system_monitor module. --- pts-core/functions/pts-functions-run.php | 4 - pts-core/functions/pts-functions.php | 68 +---- pts-core/functions/pts-functions_modules.php | 5 + pts-core/functions/pts-functions_monitor.php | 287 ------------------ pts-core/modules/system_monitor.php | 431 +++++++++++++++++++++++++++ pts-core/objects/pts_module_interface.php | 22 +- pts-core/pts-run-benchmark.php | 1 - pts-core/pts-run-cmd.php | 10 +- 8 files changed, 453 insertions(+), 375 deletions(-) create mode 100644 pts-core/modules/system_monitor.php diff --git a/pts-core/functions/pts-functions-run.php b/pts-core/functions/pts-functions-run.php index 38b6503..99a8929 100644 --- a/pts-core/functions/pts-functions-run.php +++ b/pts-core/functions/pts-functions-run.php @@ -374,8 +374,6 @@ function pts_run_benchmark($benchmark_identifier, $extra_arguments = "", $argume pts_debug_message("cd $to_execute && ./$execute_binary $PTS_BENCHMARK_ARGUMENTS"); for($i = 0; $i < $times_to_run; $i++) { - pts_monitor_update(); // Update sensors, etc - echo pts_string_header($benchmark_title . " (Run " . ($i + 1) . " of " . $times_to_run . ")"); $result_output = array(); @@ -395,8 +393,6 @@ function pts_run_benchmark($benchmark_identifier, $extra_arguments = "", $argume pts_module_process("__interim_test_run"); } - pts_monitor_update(); // Update sensors, etc - if(is_file(TEST_RESOURCE_DIR . $benchmark_identifier . "/post.sh")) { pts_exec("sh " . TEST_RESOURCE_DIR . $benchmark_identifier . "/post.sh " . BENCHMARK_ENV_DIR . $benchmark_identifier); diff --git a/pts-core/functions/pts-functions.php b/pts-core/functions/pts-functions.php index a9cd2ed..59bb0e3 100644 --- a/pts-core/functions/pts-functions.php +++ b/pts-core/functions/pts-functions.php @@ -102,77 +102,11 @@ $PTS_GLOBAL_ID = 1; $PTS_MODULES = array(); $PTS_MODULE_CURRENT = FALSE; +pts_auto_modules_ready($PTS_MODULES); pts_load_modules($PTS_MODULES); pts_module_process("__startup"); register_shutdown_function("pts_module_process", "__shutdown"); -if(($to_show = getenv("MONITOR"))) -{ - $to_show = explode(',', $to_show); - $monitor_all = in_array("all", $to_show); - $monitor_temp = in_array("all.temp", $to_show) || $monitor_all; - $monitor_power = in_array("all.power", $to_show) || $monitor_all; - $monitor_voltage = in_array("all.voltage", $to_show) || $monitor_all; - $monitor_freq = in_array("all.freq", $to_show) || $monitor_all; - $monitor_usage = in_array("all.usage", $to_show) || $monitor_all; - define("PTS_START_TIME", time()); - - if(in_array("gpu.temp", $to_show) || $monitor_temp) - { - define("MONITOR_GPU_TEMP", 1); - $GPU_TEMPERATURE = array(); - } - if(in_array("cpu.temp", $to_show) || $monitor_temp) - { - define("MONITOR_CPU_TEMP", 1); - $CPU_TEMPERATURE = array(); - } - if(in_array("sys.temp", $to_show) || $monitor_temp) - { - define("MONITOR_SYS_TEMP", 1); - $SYS_TEMPERATURE = array(); - } - if(in_array("battery.power", $to_show) || $monitor_power) - { - define("MONITOR_BATTERY_POWER", 1); - $BATTERY_POWER = array(); - } - if(in_array("cpu.voltage", $to_show) || $monitor_voltage) - { - define("MONITOR_CPU_VOLTAGE", 1); - $CPU_VOLTAGE = array(); - } - if(in_array("v3.voltage", $to_show) || $monitor_voltage) - { - define("MONITOR_V3_VOLTAGE", 1); - $V3_VOLTAGE = array(); - } - if(in_array("v5.voltage", $to_show) || $monitor_voltage) - { - - define("MONITOR_V5_VOLTAGE", 1); - $V5_VOLTAGE = array(); - } - if(in_array("v12.voltage", $to_show) || $monitor_voltage) - { - - define("MONITOR_V12_VOLTAGE", 1); - $V12_VOLTAGE = array(); - } - if(in_array("cpu.freq", $to_show) || $monitor_freq) - { - define("MONITOR_CPU_FREQ", 1); - $CPU_FREQ = array(); - } - if(in_array("gpu.usage", $to_show) || $monitor_usage) - { - define("MONITOR_GPU_USAGE", 1); - $GPU_USAGE = array(); - } - - register_shutdown_function("pts_monitor_statistics"); -} - // Phoronix Test Suite - Functions function pts_benchmark_names_to_array() { diff --git a/pts-core/functions/pts-functions_modules.php b/pts-core/functions/pts-functions_modules.php index f542109..5f09fd6 100644 --- a/pts-core/functions/pts-functions_modules.php +++ b/pts-core/functions/pts-functions_modules.php @@ -28,7 +28,12 @@ function pts_auto_modules_ready(&$modules_list) foreach($modules_assoc as $env_var => $module) if(!in_array($module, $modules_list) && ($e = getenv($env_var)) != FALSE && !empty($e)) + { + if(defined("PTS_DEBUG_MODE")) + echo "Attempting To Add Module: " . $module . "\n"; + array_push($modules_list, $module); + } } function pts_load_modules(&$modules_list) { diff --git a/pts-core/functions/pts-functions_monitor.php b/pts-core/functions/pts-functions_monitor.php index 2e445e1..9260acd 100644 --- a/pts-core/functions/pts-functions_monitor.php +++ b/pts-core/functions/pts-functions_monitor.php @@ -21,292 +21,5 @@ along with this program. If not, see . */ -function pts_monitor_update() -{ - if(defined("MONITOR_GPU_TEMP")) - pts_record_gpu_temperature(); - if(defined("MONITOR_CPU_TEMP")) - pts_record_cpu_temperature(); - if(defined("MONITOR_SYS_TEMP")) - pts_record_sys_temperature(); - if(defined("MONITOR_BATTERY_POWER")) - pts_record_battery_power(); - if(defined("MONITOR_CPU_VOLTAGE")) - pts_record_cpu_voltage(); - if(defined("MONITOR_V3_VOLTAGE")) - pts_record_v3_voltage(); - if(defined("MONITOR_V5_VOLTAGE")) - pts_record_v5_voltage(); - if(defined("MONITOR_V12_VOLTAGE")) - pts_record_v12_voltage(); - if(defined("MONITOR_CPU_FREQ")) - pts_record_cpu_frequency(); - if(defined("MONITOR_GPU_USAGE")) - pts_record_gpu_usage(); -} -function pts_monitor_arguments() -{ - return array("all", "all.temp", "all.power", "all.voltage", "all.freq", "all.usage", "gpu.temp", "cpu.temp", "sys.temp", "battery.power", "cpu.voltage", "v3.voltage", "v5.voltage", "v12.voltage", "cpu.freq", "gpu.usage"); -} -function pts_monitor_statistics() -{ - if(defined("PTS_EXIT")) - return; - - define("PTS_END_TIME", time()); - - $device = array(); - $type = array(); - $unit = array(); - $m_array = array(); - $type_index = array(); - $type_index["THERMAL"] = array(); - $type_index["POWER"] = array(); - $type_index["VOLTAGE"] = array(); - $type_index["FREQUENCY"] = array(); - $type_index["USAGE"] = array(); - - if(isset($GLOBALS["GPU_TEMPERATURE"])) - { - $this_array = $GLOBALS["GPU_TEMPERATURE"]; - - if(is_array($this_array) && !empty($this_array[0])) - { - array_push($device, "GPU"); - array_push($type, "Thermal"); - array_push($unit, "°C"); - array_push($m_array, $this_array); - array_push($type_index["THERMAL"], count($m_array) - 1); - } - } - if(isset($GLOBALS["CPU_TEMPERATURE"])) - { - $this_array = $GLOBALS["CPU_TEMPERATURE"]; - - if(is_array($this_array) && !empty($this_array[0])) - { - array_push($device, "CPU"); - array_push($type, "Thermal"); - array_push($unit, "°C"); - array_push($m_array, $this_array); - array_push($type_index["THERMAL"], count($m_array) - 1); - } - } - if(isset($GLOBALS["SYS_TEMPERATURE"])) - { - $this_array = $GLOBALS["SYS_TEMPERATURE"]; - - if(is_array($this_array) && !empty($this_array[0])) - { - array_push($device, "System"); - array_push($type, "Thermal"); - array_push($unit, "°C"); - array_push($m_array, $this_array); - array_push($type_index["THERMAL"], count($m_array) - 1); - } - } - if(isset($GLOBALS["BATTERY_POWER"])) - { - $this_array = $GLOBALS["BATTERY_POWER"]; - - if(is_array($this_array) && !empty($this_array[0])) - { - array_push($device, "Battery"); - array_push($type, "Power"); - array_push($unit, "Milliwatts"); - array_push($m_array, $this_array); - array_push($type_index["POWER"], count($m_array) - 1); - } - } - if(isset($GLOBALS["CPU_VOLTAGE"])) - { - $this_array = $GLOBALS["CPU_VOLTAGE"]; - - if(is_array($this_array) && !empty($this_array[0])) - { - array_push($device, "CPU"); - array_push($type, "Voltage"); - array_push($unit, "Volts"); - array_push($m_array, $this_array); - array_push($type_index["VOLTAGE"], count($m_array) - 1); - } - } - if(isset($GLOBALS["V3_VOLTAGE"])) - { - $this_array = $GLOBALS["V3_VOLTAGE"]; - - if(is_array($this_array) && !empty($this_array[0])) - { - array_push($device, "+3.33V"); - array_push($type, "Voltage"); - array_push($unit, "Volts"); - array_push($m_array, $this_array); - array_push($type_index["VOLTAGE"], count($m_array) - 1); - } - } - if(isset($GLOBALS["V5_VOLTAGE"])) - { - $this_array = $GLOBALS["V5_VOLTAGE"]; - - if(is_array($this_array) && !empty($this_array[0])) - { - array_push($device, "+5.00V"); - array_push($type, "Voltage"); - array_push($unit, "Volts"); - array_push($m_array, $this_array); - array_push($type_index["VOLTAGE"], count($m_array) - 1); - } - } - if(isset($GLOBALS["V12_VOLTAGE"])) - { - $this_array = $GLOBALS["V12_VOLTAGE"]; - - if(is_array($this_array) && !empty($this_array[0])) - { - array_push($device, "+12.00V"); - array_push($type, "Voltage"); - array_push($unit, "Volts"); - array_push($m_array, $this_array); - array_push($type_index["VOLTAGE"], count($m_array) - 1); - } - } - if(isset($GLOBALS["CPU_FREQ"])) - { - $this_array = $GLOBALS["CPU_FREQ"]; - - if(is_array($this_array) && !empty($this_array[0])) - { - array_push($device, "CPU"); - array_push($type, "Frequency"); - array_push($unit, "MHz"); - array_push($m_array, $this_array); - array_push($type_index["FREQUENCY"], count($m_array) - 1); - } - } - if(isset($GLOBALS["GPU_USAGE"])) - { - $this_array = $GLOBALS["GPU_USAGE"]; - - if(is_array($this_array) && !empty($this_array[0])) - { - array_push($device, "GPU"); - array_push($type, "Usage"); - array_push($unit, "Percent"); - array_push($m_array, $this_array); - array_push($type_index["USAGE"], count($m_array) - 1); - } - } - - $info_report = ""; - - if(count($m_array[0]) == 1) - { - $info_report .= "Current Sensor Readings:\n\n"; - for($i = 0; $i < count($m_array); $i++) - { - $info_report .= $device[$i] . " " . $type[$i] . " Monitor: " . $m_array[$i][0] . " " . $unit[$i]; - - if($i < (count($m_array) - 1)) - $info_report .= "\n"; - } - } - else - { - for($i = 0; $i < count($m_array); $i++) - { - // Calculate statistics - - if($i > 0) - $info_report .= "\n\n"; - - $low = 0; - $high = 0; - $total = 0; - - foreach($m_array[$i] as $temp) - { - if($temp < $low || $low == 0) - $low = $temp; - else if($temp > $high) - $high = $temp; - - $total += $temp; - } - $avg = $total / count($m_array[$i]); - - $info_report .= $device[$i] . " " . $type[$i] . " Statistics:\n\nLow: " . pts_trim_double($low) . ' ' . $unit[$i] . "\nHigh: " . pts_trim_double($high) . ' ' . $unit[$i] . "\nAverage: " . pts_trim_double($avg) . ' ' . $unit[$i]; - } - - if(trim($info_report) != "") - { - if(pts_gd_available()) - { - $image_list = array(); - pts_save_user_file(); - pts_save_user_file(null, null, "/pts-monitor-viewer/"); - pts_copy(RESULTS_VIEWER_DIR . "pts-monitor-viewer.html", PTS_MONITOR_DIR . "pts-monitor-viewer.html"); - pts_copy(RESULTS_VIEWER_DIR . "pts.js", PTS_MONITOR_DIR . "pts-monitor-viewer/pts.js"); - pts_copy(RESULTS_VIEWER_DIR . "pts-viewer.css", PTS_MONITOR_DIR . "pts-monitor-viewer/pts-viewer.css"); - - $image_count = 0; - foreach($type_index as $key => $sub_array) - { - if(count($sub_array) > 0) - { - $graph_title = $type[$sub_array[0]] . " Monitor"; - $graph_unit = $unit[$sub_array[0]]; - $graph_unit = str_replace("°C", "Degrees Celsius", $graph_unit); - $sub_title = date("F j, Y") . " - "; - - if(isset($GLOBALS["TO_RUN"])) - $sub_title .= $GLOBALS["TO_RUN"]; - else - $sub_title .= date("g:i A"); - - $t = new pts_LineGraph($graph_title, $sub_title, $graph_unit); - - $first_run = true; - foreach($sub_array as $id_point) - { - $t->loadGraphValues($m_array[$id_point], $device[$id_point]); - - if($first_run) - { - $t->loadGraphIdentifiers($m_array[$id_point]); - $t->hideGraphIdentifiers(); - $first_run = false; - } - } - - $t->loadGraphVersion(PTS_VERSION); - $t->save_graph(PTS_MONITOR_DIR . THIS_RUN_TIME . '-' . $image_count . ".png"); - $t->renderGraph(); - - array_push($image_list, THIS_RUN_TIME . '-' . $image_count . ".png"); - $image_count++; - } - } - $url = implode($image_list, ","); - } - } - } - - // Elapsed time - $time_diff = PTS_END_TIME - PTS_START_TIME; - - if($time_diff > 10 && count($m_array) > 0) - $info_report .= "\n\nElapsed Time: " . pts_format_time_string($time_diff); - - // terminal output - if(!empty($info_report)) - echo pts_string_header($info_report); - - if(count($m_array[0]) > 1 && !empty($url)) - { - file_put_contents(PTS_MONITOR_DIR . "link-latest.html", "Phoronix Test Suite -"); - display_web_browser(PTS_MONITOR_DIR . "link-latest.html"); - } -} ?> diff --git a/pts-core/modules/system_monitor.php b/pts-core/modules/system_monitor.php new file mode 100644 index 0000000..01882ca --- /dev/null +++ b/pts-core/modules/system_monitor.php @@ -0,0 +1,431 @@ +. +*/ + +class system_monitor extends pts_module_interface +{ + const module_name = "System Monitor"; + const module_version = "1.0.0"; + const module_description = "This module contains the sensor monitoring support for the Phoronix Test Suite."; + const module_author = "Module Creator"; + + // + // General Functions + // + + public static function __startup($obj = NULL) + { + $to_show = getenv("MONITOR"); + + $to_show = explode(',', $to_show); + $monitor_all = in_array("all", $to_show); + $monitor_temp = in_array("all.temp", $to_show) || $monitor_all; + $monitor_power = in_array("all.power", $to_show) || $monitor_all; + $monitor_voltage = in_array("all.voltage", $to_show) || $monitor_all; + $monitor_freq = in_array("all.freq", $to_show) || $monitor_all; + $monitor_usage = in_array("all.usage", $to_show) || $monitor_all; + define("PTS_START_TIME", time()); + + if(in_array("gpu.temp", $to_show) || $monitor_temp) + { + define("MONITOR_GPU_TEMP", 1); + $GLOBALS["GPU_TEMPERATURE"] = array(); + } + if(in_array("cpu.temp", $to_show) || $monitor_temp) + { + define("MONITOR_CPU_TEMP", 1); + $GLOBALS["CPU_TEMPERATURE"] = array(); + } + if(in_array("sys.temp", $to_show) || $monitor_temp) + { + define("MONITOR_SYS_TEMP", 1); + $GLOBALS["SYS_TEMPERATURE"] = array(); + } + if(in_array("battery.power", $to_show) || $monitor_power) + { + define("MONITOR_BATTERY_POWER", 1); + $GLOBALS["BATTERY_POWER"] = array(); + } + if(in_array("cpu.voltage", $to_show) || $monitor_voltage) + { + define("MONITOR_CPU_VOLTAGE", 1); + $GLOBALS["CPU_VOLTAGE"] = array(); + } + if(in_array("v3.voltage", $to_show) || $monitor_voltage) + { + define("MONITOR_V3_VOLTAGE", 1); + $GLOBALS["V3_VOLTAGE"] = array(); + } + if(in_array("v5.voltage", $to_show) || $monitor_voltage) + { + define("MONITOR_V5_VOLTAGE", 1); + $GLOBALS["V5_VOLTAGE"] = array(); + } + if(in_array("v12.voltage", $to_show) || $monitor_voltage) + { + define("MONITOR_V12_VOLTAGE", 1); + $GLOBALS["V12_VOLTAGE"] = array(); + } + if(in_array("cpu.freq", $to_show) || $monitor_freq) + { + define("MONITOR_CPU_FREQ", 1); + $GLOBALS["CPU_FREQ"] = array(); + } + if(in_array("gpu.usage", $to_show) || $monitor_usage) + { + define("MONITOR_GPU_USAGE", 1); + $GLOBALS["GPU_USAGE"] = array(); + } + } + public static function __shutdown($obj = NULL) + { + if(defined("PTS_EXIT")) + return; + + define("PTS_END_TIME", time()); + + $device = array(); + $type = array(); + $unit = array(); + $m_array = array(); + $type_index = array(); + $type_index["THERMAL"] = array(); + $type_index["POWER"] = array(); + $type_index["VOLTAGE"] = array(); + $type_index["FREQUENCY"] = array(); + $type_index["USAGE"] = array(); + + if(isset($GLOBALS["GPU_TEMPERATURE"])) + { + $this_array = $GLOBALS["GPU_TEMPERATURE"]; + + if(is_array($this_array) && !empty($this_array[0])) + { + array_push($device, "GPU"); + array_push($type, "Thermal"); + array_push($unit, "°C"); + array_push($m_array, $this_array); + array_push($type_index["THERMAL"], count($m_array) - 1); + } + } + if(isset($GLOBALS["CPU_TEMPERATURE"])) + { + $this_array = $GLOBALS["CPU_TEMPERATURE"]; + + if(is_array($this_array) && !empty($this_array[0])) + { + array_push($device, "CPU"); + array_push($type, "Thermal"); + array_push($unit, "°C"); + array_push($m_array, $this_array); + array_push($type_index["THERMAL"], count($m_array) - 1); + } + } + if(isset($GLOBALS["SYS_TEMPERATURE"])) + { + $this_array = $GLOBALS["SYS_TEMPERATURE"]; + + if(is_array($this_array) && !empty($this_array[0])) + { + array_push($device, "System"); + array_push($type, "Thermal"); + array_push($unit, "°C"); + array_push($m_array, $this_array); + array_push($type_index["THERMAL"], count($m_array) - 1); + } + } + if(isset($GLOBALS["BATTERY_POWER"])) + { + $this_array = $GLOBALS["BATTERY_POWER"]; + + if(is_array($this_array) && !empty($this_array[0])) + { + array_push($device, "Battery"); + array_push($type, "Power"); + array_push($unit, "Milliwatts"); + array_push($m_array, $this_array); + array_push($type_index["POWER"], count($m_array) - 1); + } + } + if(isset($GLOBALS["CPU_VOLTAGE"])) + { + $this_array = $GLOBALS["CPU_VOLTAGE"]; + + if(is_array($this_array) && !empty($this_array[0])) + { + array_push($device, "CPU"); + array_push($type, "Voltage"); + array_push($unit, "Volts"); + array_push($m_array, $this_array); + array_push($type_index["VOLTAGE"], count($m_array) - 1); + } + } + if(isset($GLOBALS["V3_VOLTAGE"])) + { + $this_array = $GLOBALS["V3_VOLTAGE"]; + + if(is_array($this_array) && !empty($this_array[0])) + { + array_push($device, "+3.33V"); + array_push($type, "Voltage"); + array_push($unit, "Volts"); + array_push($m_array, $this_array); + array_push($type_index["VOLTAGE"], count($m_array) - 1); + } + } + if(isset($GLOBALS["V5_VOLTAGE"])) + { + $this_array = $GLOBALS["V5_VOLTAGE"]; + + if(is_array($this_array) && !empty($this_array[0])) + { + array_push($device, "+5.00V"); + array_push($type, "Voltage"); + array_push($unit, "Volts"); + array_push($m_array, $this_array); + array_push($type_index["VOLTAGE"], count($m_array) - 1); + } + } + if(isset($GLOBALS["V12_VOLTAGE"])) + { + $this_array = $GLOBALS["V12_VOLTAGE"]; + + if(is_array($this_array) && !empty($this_array[0])) + { + array_push($device, "+12.00V"); + array_push($type, "Voltage"); + array_push($unit, "Volts"); + array_push($m_array, $this_array); + array_push($type_index["VOLTAGE"], count($m_array) - 1); + } + } + if(isset($GLOBALS["CPU_FREQ"])) + { + $this_array = $GLOBALS["CPU_FREQ"]; + + if(is_array($this_array) && !empty($this_array[0])) + { + array_push($device, "CPU"); + array_push($type, "Frequency"); + array_push($unit, "MHz"); + array_push($m_array, $this_array); + array_push($type_index["FREQUENCY"], count($m_array) - 1); + } + } + if(isset($GLOBALS["GPU_USAGE"])) + { + $this_array = $GLOBALS["GPU_USAGE"]; + + if(is_array($this_array) && !empty($this_array[0])) + { + array_push($device, "GPU"); + array_push($type, "Usage"); + array_push($unit, "Percent"); + array_push($m_array, $this_array); + array_push($type_index["USAGE"], count($m_array) - 1); + } + } + + $info_report = ""; + + if(count($m_array[0]) == 1) + { + $info_report .= "Current Sensor Readings:\n\n"; + for($i = 0; $i < count($m_array); $i++) + { + $info_report .= $device[$i] . " " . $type[$i] . " Monitor: " . $m_array[$i][0] . " " . $unit[$i]; + + if($i < (count($m_array) - 1)) + $info_report .= "\n"; + } + } + else + { + for($i = 0; $i < count($m_array); $i++) + { + // Calculate statistics + + if($i > 0) + $info_report .= "\n\n"; + + $low = 0; + $high = 0; + $total = 0; + + foreach($m_array[$i] as $temp) + { + if($temp < $low || $low == 0) + $low = $temp; + else if($temp > $high) + $high = $temp; + + $total += $temp; + } + $avg = $total / count($m_array[$i]); + + $info_report .= $device[$i] . " " . $type[$i] . " Statistics:\n\nLow: " . pts_trim_double($low) . ' ' . $unit[$i] . "\nHigh: " . pts_trim_double($high) . ' ' . $unit[$i] . "\nAverage: " . pts_trim_double($avg) . ' ' . $unit[$i]; + } + + if(trim($info_report) != "") + { + if(pts_gd_available()) + { + $image_list = array(); + pts_save_user_file(); + pts_save_user_file(null, null, "/pts-monitor-viewer/"); + pts_copy(RESULTS_VIEWER_DIR . "pts-monitor-viewer.html", PTS_MONITOR_DIR . "pts-monitor-viewer.html"); + pts_copy(RESULTS_VIEWER_DIR . "pts.js", PTS_MONITOR_DIR . "pts-monitor-viewer/pts.js"); + pts_copy(RESULTS_VIEWER_DIR . "pts-viewer.css", PTS_MONITOR_DIR . "pts-monitor-viewer/pts-viewer.css"); + + $image_count = 0; + foreach($type_index as $key => $sub_array) + { + if(count($sub_array) > 0) + { + $graph_title = $type[$sub_array[0]] . " Monitor"; + $graph_unit = $unit[$sub_array[0]]; + $graph_unit = str_replace("°C", "Degrees Celsius", $graph_unit); + $sub_title = date("F j, Y") . " - "; + + if(isset($GLOBALS["TO_RUN"])) + $sub_title .= $GLOBALS["TO_RUN"]; + else + $sub_title .= date("g:i A"); + + $t = new pts_LineGraph($graph_title, $sub_title, $graph_unit); + + $first_run = true; + foreach($sub_array as $id_point) + { + $t->loadGraphValues($m_array[$id_point], $device[$id_point]); + + if($first_run) + { + $t->loadGraphIdentifiers($m_array[$id_point]); + $t->hideGraphIdentifiers(); + $first_run = false; + } + } + + $t->loadGraphVersion(PTS_VERSION); + $t->save_graph(PTS_MONITOR_DIR . THIS_RUN_TIME . '-' . $image_count . ".png"); + $t->renderGraph(); + + array_push($image_list, THIS_RUN_TIME . '-' . $image_count . ".png"); + $image_count++; + } + } + $url = implode($image_list, ","); + } + } + } + + // Elapsed time + $time_diff = PTS_END_TIME - PTS_START_TIME; + + if($time_diff > 10 && count($m_array) > 0) + $info_report .= "\n\nElapsed Time: " . pts_format_time_string($time_diff); + + // terminal output + if(!empty($info_report)) + echo pts_string_header($info_report); + + if(count($m_array[0]) > 1 && !empty($url)) + { + file_put_contents(PTS_MONITOR_DIR . "link-latest.html", "Phoronix Test Suite + "); + display_web_browser(PTS_MONITOR_DIR . "link-latest.html"); + } + } + + // + // Installation Functions + // + + public static function __pre_install_process($obj = NULL) + { + return; + } + public static function __pre_test_install($obj = NULL) + { + return; + } + public static function __post_test_install($obj = NULL) + { + return; + } + public static function __post_install_process($obj = NULL) + { + return; + } + + // + // Run Functions + // + + public static function __pre_run_process($obj = NULL) + { + self::pts_monitor_update(); + } + public static function __interim_test_run($obj = NULL) + { + self::pts_monitor_update(); + } + public static function __post_run_process($obj = NULL) + { + self::pts_monitor_update(); + } + + // + // Extra Functions + // + + private function pts_monitor_update() + { + if(defined("MONITOR_GPU_TEMP")) + pts_record_gpu_temperature(); + if(defined("MONITOR_CPU_TEMP")) + pts_record_cpu_temperature(); + if(defined("MONITOR_SYS_TEMP")) + pts_record_sys_temperature(); + if(defined("MONITOR_BATTERY_POWER")) + pts_record_battery_power(); + if(defined("MONITOR_CPU_VOLTAGE")) + pts_record_cpu_voltage(); + if(defined("MONITOR_V3_VOLTAGE")) + pts_record_v3_voltage(); + if(defined("MONITOR_V5_VOLTAGE")) + pts_record_v5_voltage(); + if(defined("MONITOR_V12_VOLTAGE")) + pts_record_v12_voltage(); + if(defined("MONITOR_CPU_FREQ")) + pts_record_cpu_frequency(); + if(defined("MONITOR_GPU_USAGE")) + pts_record_gpu_usage(); + } + private function pts_monitor_arguments() + { + return array("all", "all.temp", "all.power", "all.voltage", "all.freq", "all.usage", "gpu.temp", "cpu.temp", "sys.temp", "battery.power", "cpu.voltage", "v3.voltage", "v5.voltage", "v12.voltage", "cpu.freq", "gpu.usage"); + } +} + +?> diff --git a/pts-core/objects/pts_module_interface.php b/pts-core/objects/pts_module_interface.php index 1538e2d..83f4b21 100644 --- a/pts-core/objects/pts_module_interface.php +++ b/pts-core/objects/pts_module_interface.php @@ -32,11 +32,11 @@ class pts_module_interface // General Functions // - public static function __startup($obj) + public static function __startup($obj = NULL) { return; } - public static function __shutdown($obj) + public static function __shutdown($obj = NULL) { return; } @@ -45,19 +45,19 @@ class pts_module_interface // Installation Functions // - public static function __pre_install_process($obj) + public static function __pre_install_process($obj = NULL) { return; } - public static function __pre_test_install($obj) + public static function __pre_test_install($obj = NULL) { return; } - public static function __post_test_install($obj) + public static function __post_test_install($obj = NULL) { return; } - public static function __post_install_process($obj) + public static function __post_install_process($obj = NULL) { return; } @@ -66,23 +66,23 @@ class pts_module_interface // Run Functions // - public static function __pre_run_process($obj) + public static function __pre_run_process($obj = NULL) { return; } - public static function __pre_test_run($obj) + public static function __pre_test_run($obj = NULL) { return; } - public static function __interim_test_run($obj) + public static function __interim_test_run($obj = NULL) { return; } - public static function __post_test_run($obj) + public static function __post_test_run($obj = NULL) { return; } - public static function __post_run_process($obj) + public static function __post_run_process($obj = NULL) { return; } diff --git a/pts-core/pts-run-benchmark.php b/pts-core/pts-run-benchmark.php index 94a7bb8..2e3da98 100644 --- a/pts-core/pts-run-benchmark.php +++ b/pts-core/pts-run-benchmark.php @@ -42,7 +42,6 @@ if(empty($TO_RUN)) // Make sure tests are installed pts_verify_test_installation($TO_RUN); -pts_monitor_update(); // Update sensors, etc if(!$TO_RUN_TYPE) { diff --git a/pts-core/pts-run-cmd.php b/pts-core/pts-run-cmd.php index 1dfe7b9..25358d5 100644 --- a/pts-core/pts-run-cmd.php +++ b/pts-core/pts-run-cmd.php @@ -504,15 +504,15 @@ switch($COMMAND) } break; case "SENSORS": - pts_monitor_update(); + echo "\nThis option was dropped in Phoronix Test Suite 1.2. For more information, view the latest documentation.\n\n"; break; case "SENSOR_OPTIONS": //echo "\nThe Phoronix Test Suite supports monitoring various system hardware sensors through the LM_Sensors and ACPI interfaces. The Phoronix Test Suite will automatically monitor the selected sensors while each test is running and at the end will then provide the low and high thresholds for each sensor as well as the average. In addition, the sensor results are then plotted on line graphs and can be viewed through the PTS Results Viewer.\n"; echo "\nMonitoring these sensors are as easy as running your normal Phoronix Test Suite commands but at the beginning of the command add: MONITOR= (example: MONITOR=cpu.temp,cpu.voltage phoronix-test-suite benchmark universe). Below are all of the sensors supported by this version of the Phoronix Test Suite.\n\n"; - echo "Supported Options:\n"; - foreach(pts_monitor_arguments() as $arg) - echo " - " . $arg . "\n"; - echo "\n"; + //echo "Supported Options:\n"; + //foreach(pts_monitor_arguments() as $arg) + // echo " - " . $arg . "\n"; + //echo "\n"; break; case "VERSION": echo "\nPhoronix Test Suite v" . PTS_VERSION . " (" . PTS_CODENAME . ")\n\n"; -- cgit