public static function __startup() { $user_key = pts_module::read_variable('PUSHOVER_NET_USER'); if ($user_key == null) { echo PHP_EOL . 'Your Pushover.net user key must be passed via the PUSHOVER_NET_USER environment variable.' . PHP_EOL; return pts_module::MODULE_UNLOAD; } if (function_exists('curl_setopt_array') == false || function_exists('curl_init') == false) { echo PHP_EOL . 'PHP5 CURL support must be installed to use this module.' . PHP_EOL; return pts_module::MODULE_UNLOAD; } self::$pushover_net_user_key = $user_key; return true; }
public static function __startup() { // Make sure the file is removed to avoid potential problems if it was leftover from earlier run pts_module::remove_file('is_running'); if (pts_client::executable_in_path('import') == false) { echo PHP_EOL . 'ImageMagick must first be installed onto this system!' . PHP_EOL; return pts_module::MODULE_UNLOAD; } if (($interval = pts_module::read_variable('SCREENSHOT_INTERVAL')) > 1 && is_numeric($interval)) { self::$screenshot_interval = $interval; return true; } return pts_module::MODULE_UNLOAD; self::$existing_screenshots = pts_file_io::glob(pts_module::save_dir() . 'screenshot-*.png'); }
private static function set_monitoring_interval() { if (pts_module::read_variable('MONITOR_INTERVAL') != null) { $proposed_interval = pts_module::read_variable('MONITOR_INTERVAL'); if (is_numeric($proposed_interval) && $proposed_interval >= 0.5) { self::$sensor_monitoring_frequency = $proposed_interval; } } }
public static function __startup() { $halt_screensaver = pts_module::read_variable('HALT_SCREENSAVER'); if (!empty($halt_screensaver) && !pts_strings::string_bool($halt_screensaver) || phodevi::read_property('system', 'display-server') == null) { return pts_module::MODULE_UNLOAD; } if (phodevi::is_macosx()) { // Right now there doesn't appear to be a better way to disable OS X screensaver automatically... return pts_module::MODULE_UNLOAD; } // GNOME Screensaver? if (($gt = pts_client::executable_in_path('gconftool')) != false || ($gt = pts_client::executable_in_path('gconftool-2')) != false) { self::$gnome_gconftool = $gt; } if (self::$gnome_gconftool != false) { $is_gnome_screensaver_enabled = trim(shell_exec(self::$gnome_gconftool . ' -g /apps/gnome-screensaver/idle_activation_enabled 2>&1')); if ($is_gnome_screensaver_enabled == 'true') { // Stop the GNOME Screensaver shell_exec(self::$gnome_gconftool . ' --type bool --set /apps/gnome-screensaver/idle_activation_enabled false 2>&1'); self::$gnome2_screensaver_halted = true; } $sleep_display_ac = trim(shell_exec(self::$gnome_gconftool . ' -g /apps/gnome-power-manager/timeout/sleep_display_ac 2>&1')); if ($sleep_display_ac != 0) { // Don't sleep the display when on AC power shell_exec(self::$gnome_gconftool . ' --type int --set /apps/gnome-power-manager/timeout/sleep_display_ac 0 2>&1'); self::$sleep_display_ac = $sleep_display_ac; } } if (pts_client::executable_in_path('qdbus')) { // KDE Screensaver? $is_kde_screensaver_enabled = trim(shell_exec('qdbus org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSaver.GetActive 2>&1')); if ($is_kde_screensaver_enabled == 'true') { // Stop the KDE Screensaver shell_exec('qdbus org.freedesktop.ScreenSaver /ScreenSaver SimulateUserActivity 2>&1'); self::$kde_screensaver_halted = true; } } if (self::$gnome2_screensaver_halted == false && pts_client::executable_in_path('gsettings')) { // GNOME 3.x Screensaver? $is_gnome3_screensaver_enabled = trim(shell_exec('gsettings get org.gnome.desktop.session idle-delay 2>&1')); if (stripos($is_gnome3_screensaver_enabled, 'no such key') === false && pts_strings::last_in_string($is_gnome3_screensaver_enabled) > 0) { // Stop the GNOME 3.x Screensaver shell_exec('gsettings set org.gnome.desktop.session idle-delay 0 2>&1'); self::$gnome3_screensaver_halted = pts_strings::last_in_string($is_gnome3_screensaver_enabled); } // GNOME 3.x Lock-Screen $is_gnome3_lockscreen_enabled = trim(shell_exec('gsettings get org.gnome.desktop.lockdown disable-lock-screen 2>&1')); if (stripos($is_gnome3_lockscreen_enabled, 'no such key') === false && pts_strings::last_in_string($is_gnome3_lockscreen_enabled) == 'false') { // Stop the GNOME 3.x Lock Screen shell_exec('gsettings set org.gnome.desktop.lockdown disable-lock-screen true 2>&1'); self::$gnome3_lockscreen_disabled = true; } // This GNOME3 GSettings method is deprecated on distributions like GNOME 3.8 with Fedora 19 $is_gnome3_screensaver_enabled_old = trim(shell_exec('gsettings get org.gnome.desktop.screensaver idle-activation-enabled 2>&1')); if ($is_gnome3_screensaver_enabled_old == 'true') { // Stop the GNOME 3.x Screensaver shell_exec('gsettings set org.gnome.desktop.screensaver idle-activation-enabled false 2>&1'); self::$gnome3_screensaver_halted_old = true; } // GNOME 3.x Sleep Dispaly? $is_gnome3_sleep = trim(shell_exec('gsettings get org.gnome.settings-daemon.plugins.power sleep-display-ac 2>&1')); if ($is_gnome3_sleep > 0) { // Stop the GNOME 3.x Display Sleep shell_exec('gsettings set org.gnome.settings-daemon.plugins.power sleep-display-ac 0 2>&1'); self::$sleep_display_ac = $is_gnome3_sleep; } } if (pts_client::executable_in_path('xfconf-query')) { $is_xfce_screensaver_enabled = stripos(shell_exec('xfconf-query -c xfce4-session -p /startup/screensaver/enabled 2>&1'), 'false') !== false; if ($is_xfce_screensaver_enabled) { shell_exec('xfconf-query -c xfce4-session -n -t bool -p /startup/screensaver/enabled -s false 2>&1'); self::$xfce_screensaver_halted = true; } } if (getenv('DISPLAY') != false && (self::$xset = pts_client::executable_in_path('xset'))) { shell_exec('xset s off 2>&1'); } else { if (getenv('DISPLAY') == false && pts_client::executable_in_path('setterm')) { shell_exec('setterm -powersave off -blank 0 2>&1'); } } if (self::$gnome2_screensaver_halted || self::$gnome3_screensaver_halted || self::$gnome3_screensaver_halted_old || self::$kde_screensaver_halted || self::$xfce_screensaver_halted) { self::$screensaver_halted = true; } if (($xdg = pts_client::executable_in_path('xdg-screensaver')) == false) { self::$xdg_screensaver_available = $xdg; } if ($xscreensaver = pts_client::executable_in_path('xscreensaver-command')) { shell_exec($xscreensaver . ' -exit 2>&1'); } }
public static function __event_results_saved($test_run_manager) { if (pts_module::read_variable('AUTO_UPLOAD_RESULTS_TO_PHOROMATIC') && pts_module::is_module_setup()) { phoromatic::upload_unscheduled_test_results($test_run_manager->get_file_name()); } }
public static function __post_test_run_process(&$result_file) { if (self::$individual_monitoring == false || count(self::$to_monitor) == 0) { return; } // The self::$test_run_timer to contain how long each individual test run lasted, should anything else past this point want to use the info... self::$test_run_timer = time() - self::$test_run_timer; // Let the system return to brief idling.. sleep(self::$sensor_monitoring_frequency * 8); if (pts_module::read_variable('PERFORMANCE_PER_WATT')) { $sensor = array('sys', 'power'); $sensor_results = self::parse_monitor_log('logs/' . phodevi::sensor_identifier($sensor), self::$individual_test_run_offsets[phodevi::sensor_identifier($sensor)]); if (count($sensor_results) > 2 && self::$successful_test_run_request) { // Copy the value each time as if you are directly writing the original data, each succeeding time in the loop the used arguments gets borked $test_result = clone self::$successful_test_run_request; $process_perf_per_watt = true; $watt_average = array_sum($sensor_results) / count($sensor_results); switch (phodevi::read_sensor_unit($sensor)) { case 'Milliwatts': $watt_average = $watt_average / 1000; case 'Watts': break; default: $process_perf_per_watt = false; } if ($process_perf_per_watt && $watt_average > 0 && $test_result->test_profile->get_display_format() == 'BAR_GRAPH') { $test_result->test_profile->set_identifier(null); //$test_result->set_used_arguments_description(phodevi::sensor_name('sys.power') . ' Monitor'); //$test_result->set_used_arguments(phodevi::sensor_name('sys.power') . ' ' . $test_result->get_arguments()); $test_result->test_result_buffer = new pts_test_result_buffer(); if ($test_result->test_profile->get_result_proportion() == 'HIB') { $test_result->test_profile->set_result_scale($test_result->test_profile->get_result_scale() . ' Per Watt'); $test_result->test_result_buffer->add_test_result(self::$result_identifier, pts_math::set_precision($test_result->active->get_result() / $watt_average)); $result_file->add_result($test_result); } else { if ($test_result->test_profile->get_result_proportion() == 'LIB') { $test_result->test_profile->set_result_proportion('HIB'); $test_result->test_profile->set_result_scale('Performance Per Watt'); $test_result->test_result_buffer->add_test_result(self::$result_identifier, pts_math::set_precision(1 / $test_result->active->get_result() / $watt_average)); $result_file->add_result($test_result); } } array_push(self::$perf_per_watt_collection, $test_result->active->get_result()); } } } foreach (self::$to_monitor as $sensor) { $sensor_results = self::parse_monitor_log('logs/' . phodevi::sensor_identifier($sensor), self::$individual_test_run_offsets[phodevi::sensor_identifier($sensor)]); if (count($sensor_results) > 2) { // Copy the value each time as if you are directly writing the original data, each succeeding time in the loop the used arguments gets borked $test_result = clone self::$individual_test_run_request; $test_result->test_profile->set_identifier(null); $test_result->test_profile->set_result_proportion('LIB'); $test_result->test_profile->set_display_format('LINE_GRAPH'); $test_result->test_profile->set_result_scale(phodevi::read_sensor_unit($sensor)); $test_result->set_used_arguments_description(phodevi::sensor_name($sensor) . ' Monitor'); $test_result->set_used_arguments(phodevi::sensor_name($sensor) . ' ' . $test_result->get_arguments()); $test_result->test_result_buffer = new pts_test_result_buffer(); $test_result->test_result_buffer->add_test_result(self::$result_identifier, implode(',', $sensor_results), implode(',', $sensor_results)); $result_file->add_result($test_result); } self::$individual_test_run_offsets[phodevi::sensor_identifier($sensor)] = array(); } self::$successful_test_run_request = null; self::$individual_test_run_request = null; self::$monitor_test_count++; // Let the system rest before jumping to next test... sleep(self::$sensor_monitoring_frequency * 6); }
public static function __pre_run_process() { if (!(phodevi::is_nvidia_graphics() || phodevi::is_ati_graphics() && phodevi::is_linux())) { echo "\nNo supported driver found for graphics_override module!\n"; return pts_module::MODULE_UNLOAD; // Not using a supported driver, quit the module } $force_aa = pts_module::read_variable("FORCE_AA"); $force_af = pts_module::read_variable("FORCE_AF"); if ($force_aa !== FALSE && in_array($force_aa, self::$supported_aa_levels)) { // First backup any existing override, then set the new value if (phodevi::is_nvidia_graphics()) { self::$preset_aa = phodevi_parser::read_nvidia_extension("FSAA"); self::$preset_aa_control = phodevi_parser::read_nvidia_extension("FSAAAppControlled"); switch ($force_aa) { case 2: $nvidia_aa = 2; break; case 4: $nvidia_aa = 5; break; case 8: $nvidia_aa = 7; break; case 16: $nvidia_aa = 8; break; } if (isset($nvidia_aa)) { self::set_nvidia_extension("FSAA", $nvidia_aa); self::set_nvidia_extension("FSAAAppControlled", 0); } } else { if (phodevi::is_ati_graphics()) { self::$preset_aa = phodevi_linux_parser::read_amd_pcsdb("OpenGL,AntiAliasSamples"); self::$preset_aa_control = phodevi_linux_parser::read_amd_pcsdb("OpenGL,AAF"); switch ($force_aa) { case 2: $ati_aa = "0x00000002"; break; case 4: $ati_aa = "0x00000004"; break; case 8: $ati_aa = "0x00000008"; break; case 16: echo "\nThe ATI fglrx driver currently does not support 16x AA! Defaulting to 8x AA!\n"; $ati_aa = "0x00000008"; break; } if (isset($ati_aa)) { self::set_amd_pcsdb("OpenGL,AntiAliasSamples", $ati_aa); self::set_amd_pcsdb("OpenGL,AAF", "0x00000000"); } } } } if ($force_af !== FALSE && in_array($force_af, self::$supported_af_levels)) { // First backup any existing override, then set the new value if (phodevi::is_nvidia_graphics()) { self::$preset_af = phodevi_parser::read_nvidia_extension("LogAniso"); self::$preset_af_control = phodevi_parser::read_nvidia_extension("LogAnisoAppControlled"); switch ($force_af) { case 2: $nvidia_af = 1; break; case 4: $nvidia_af = 2; break; case 8: $nvidia_af = 3; break; case 16: $nvidia_af = 4; break; } if (isset($nvidia_af)) { self::set_nvidia_extension("LogAniso", $nvidia_af); self::set_nvidia_extension("LogAnisoAppControlled", 0); } } else { if (phodevi::is_ati_graphics()) { self::$preset_af = phodevi_linux_parser::read_amd_pcsdb("OpenGL,AnisoDegree"); switch ($force_af) { case 2: $ati_af = "0x00000002"; break; case 4: $ati_af = "0x00000004"; break; case 8: $ati_af = "0x00000008"; break; case 16: $ati_af = "0x00000010"; break; } if (isset($ati_af)) { self::set_amd_pcsdb("OpenGL,AnisoDegree", $ati_af); } } } } }