def exit_program(self, w=None): """ Kill all stress operations upon exit""" try: kill_child_processes(self.controller.mode.get_stress_process()) except: logging.debug('Could not kill process') raise urwid.ExitMainLoop()
def unhandled_input(self, stui_input): logging.debug('Caught ' + str(stui_input)) if stui_input == 'q': logging.debug(graph_controller.mode.get_stress_process()) kill_child_processes(graph_controller.mode.get_stress_process()) raise urwid.ExitMainLoop() if stui_input == 'esc': graph_controller.view.on_menu_close()
def start_stress(self): mode = self.mode if mode.get_current_mode() == 'Stress': self.stress_start_time = timeit.default_timer() self.stress_time = 0 kill_child_processes(mode.get_stress_process()) mode.set_stress_process(None) # This is not pretty, but this is how we know stress started self.view.graphs['Frequency'].source.set_stress_started() stress_cmd = [stress_program] if int(self.view.stress_menu.sqrt_workers) > 0: stress_cmd.append('-c') stress_cmd.append(self.view.stress_menu.sqrt_workers) if int(self.view.stress_menu.sync_workers) > 0: stress_cmd.append('-i') stress_cmd.append(self.view.stress_menu.sync_workers) if int(self.view.stress_menu.memory_workers) > 0: stress_cmd.append('--vm') stress_cmd.append(self.view.stress_menu.memory_workers) stress_cmd.append('--vm-bytes') stress_cmd.append(self.view.stress_menu.malloc_byte) stress_cmd.append('--vm-stride') stress_cmd.append(self.view.stress_menu.byte_touch_cnt) if self.view.stress_menu.no_malloc: stress_cmd.append('--vm-keep') if int(self.view.stress_menu.write_workers) > 0: stress_cmd.append('--hdd') stress_cmd.append(self.view.stress_menu.write_workers) stress_cmd.append('--hdd-bytes') stress_cmd.append(self.view.stress_menu.write_bytes) if self.view.stress_menu.time_out != 'none': stress_cmd.append('-t') stress_cmd.append(self.view.stress_menu.time_out) with open(os.devnull, 'w') as DEVNULL: try: stress_proc = subprocess.Popen(stress_cmd, stdout=DEVNULL, stderr=DEVNULL, shell=False) mode.set_stress_process(psutil.Process(stress_proc.pid)) except OSError: logging.debug("Unable to start stress") elif mode.get_current_mode() == 'FIRESTARTER': logging.debug('Started FIRESTARTER mode') kill_child_processes(mode.get_stress_process()) mode.set_stress_process(None) stress_cmd = fire_starter self.stress_start_time = timeit.default_timer() self.stress_time = 0 self.view.graphs['Frequency'].source.set_stress_started() logging.debug("Firestarter " + str(fire_starter)) with open(os.devnull, 'w') as DEVNULL: try: stress_proc = subprocess.Popen( stress_cmd, stdout=DEVNULL, stderr=DEVNULL, shell=False) mode.set_stress_process(psutil.Process(stress_proc.pid)) logging.debug('Started process' + str(mode.get_stress_process())) except OSError: logging.debug("Unable to start stress") else: logging.debug('Monitoring') kill_child_processes(mode.get_stress_process()) mode.set_stress_process(None) try: self.view.graphs['Frequency'].source.set_stress_stopped() except(KeyError, AttributeError): logging.debug('Unalbe to reset performance loss meter') # Start a new clock upon starting a new stress test self.view.clock_view.set_text(('bold text', seconds_to_text( int(self.stress_time))))
def exit_program(self, w=None): """ Kill all stress operations upon exit""" kill_child_processes(self.controller.mode.get_stress_process()) raise urwid.ExitMainLoop()
def signal_handler(self, frame): """signal handler for properly exiting Ctrl+C""" logging.debug(graph_controller.mode.get_stress_process()) kill_child_processes(graph_controller.mode.get_stress_process()) raise urwid.ExitMainLoop()
def start_stress(self): mode = self.mode if mode.get_current_mode() == 'Stress Operation': try: kill_child_processes(mode.get_stress_process()) except: logging.debug('Could not kill process') # This is not pretty, but this is how we know stress started self.view.graphs['Frequency'].source.set_stress_started() stress_cmd = [stress_program] if int(self.view.stress_menu.sqrt_workers) > 0: stress_cmd.append('-c') stress_cmd.append(self.view.stress_menu.sqrt_workers) if int(self.view.stress_menu.sync_workers) > 0: stress_cmd.append('-i') stress_cmd.append(self.view.stress_menu.sync_workers) if int(self.view.stress_menu.memory_workers) > 0: stress_cmd.append('--vm') stress_cmd.append(self.view.stress_menu.memory_workers) stress_cmd.append('--vm-bytes') stress_cmd.append(self.view.stress_menu.malloc_byte) stress_cmd.append('--vm-stride') stress_cmd.append(self.view.stress_menu.byte_touch_cnt) if self.view.stress_menu.no_malloc: stress_cmd.append('--vm-keep') if int(self.view.stress_menu.write_workers) > 0: stress_cmd.append('--hdd') stress_cmd.append(self.view.stress_menu.write_workers) stress_cmd.append('--hdd-bytes') stress_cmd.append(self.view.stress_menu.write_bytes) if self.view.stress_menu.time_out != 'none': stress_cmd.append('-t') stress_cmd.append(self.view.stress_menu.time_out) with open(os.devnull, 'w') as DEVNULL: try: stress_proc = subprocess.Popen(stress_cmd, stdout=DEVNULL, stderr=DEVNULL, shell=False) mode.set_stress_process(psutil.Process(stress_proc.pid)) except: logging.debug("Unable to start stress") #self.data.max_perf_lost = 0 #self.data.samples_taken = 0 elif mode.get_current_mode() == 'FIRESTARTER': logging.debug('Started FIRESTARTER mode') try: kill_child_processes(mode.get_stress_process()) except: logging.debug('Could not kill process') stress_cmd = fire_starter self.view.graphs['Frequency'].source.set_stress_started() logging.debug("Firestarter " + str(fire_starter)) with open(os.devnull, 'w') as DEVNULL: try: stress_proc = subprocess.Popen(stress_cmd, stdout=DEVNULL, stderr=DEVNULL, shell=False) mode.set_stress_process(psutil.Process(stress_proc.pid)) logging.debug('Started process' + str(mode.get_stress_process())) except: logging.debug("Unable to start stress") else: logging.debug('Regular operation mode') try: kill_child_processes(mode.get_stress_process()) self.view.graphs['Frequency'].source.set_stress_stopped() except: try: logging.debug('Could not kill process' + str(mode.get_stress_process())) except: logging.debug('Could not kill process FIRESTARTER')