def _update_event(self, event_index, event_state, event_type, event_value, proc_list, proc_desc, peak_time): """Update an event in the list""" if event_state == "OK" or event_state == "CAREFUL": # Reset the automatic process sort key self.reset_process_sort() # Set the end of the events endtime = time.mktime(datetime.now().timetuple()) if endtime - self.events_list[event_index][0] > peak_time: # If event is > peak_time seconds self.events_list[event_index][1] = endtime else: # If event <= peak_time seconds, ignore self.events_list.remove(self.events_list[event_index]) else: # Update the item self.set_process_sort(event_type) # State if event_state == "CRITICAL": self.events_list[event_index][2] = event_state # Min value self.events_list[event_index][6] = min( self.events_list[event_index][6], event_value) # Max value self.events_list[event_index][4] = max( self.events_list[event_index][4], event_value) # Average value self.events_list[event_index][7] += event_value self.events_list[event_index][8] += 1 self.events_list[event_index][5] = ( self.events_list[event_index][7] / self.events_list[event_index][8]) # TOP PROCESS LIST (only for CRITICAL ALERT) if event_state == "CRITICAL": events_sort_key = self.get_event_sort_key(event_type) # Sort the current process list to retreive the TOP 3 processes self.events_list[event_index][9] = sort_stats( proc_list, events_sort_key)[0:3] self.events_list[event_index][11] = events_sort_key # MONITORED PROCESSES DESC self.events_list[event_index][10] = proc_desc return True
def _update_event(self, event_index, event_state, event_type, event_value, proc_list, proc_desc, peak_time): """Update an event in the list""" if event_state == "OK" or event_state == "CAREFUL": # Reset the automatic process sort key self.reset_process_sort() # Set the end of the events endtime = time.mktime(datetime.now().timetuple()) if endtime - self.events_list[event_index][0] > peak_time: # If event is > peak_time seconds self.events_list[event_index][1] = endtime else: # If event <= peak_time seconds, ignore self.events_list.remove(self.events_list[event_index]) else: # Update the item self.set_process_sort(event_type) # State if event_state == "CRITICAL": self.events_list[event_index][2] = event_state # Min value self.events_list[event_index][6] = min(self.events_list[event_index][6], event_value) # Max value self.events_list[event_index][4] = max(self.events_list[event_index][4], event_value) # Average value self.events_list[event_index][7] += event_value self.events_list[event_index][8] += 1 self.events_list[event_index][5] = (self.events_list[event_index][7] / self.events_list[event_index][8]) # TOP PROCESS LIST (only for CRITICAL ALERT) if event_state == "CRITICAL": events_sort_key = self.get_event_sort_key(event_type) # Sort the current process list to retreive the TOP 3 processes self.events_list[event_index][9] = sort_stats(proc_list, events_sort_key)[0:3] self.events_list[event_index][11] = events_sort_key # MONITORED PROCESSES DESC self.events_list[event_index][10] = proc_desc return True
def _update_item(self, item_index, item_state, item_type, item_value, proc_list, proc_desc, peak_time): """Update a item in the log list""" if item_state == "OK" or item_state == "CAREFUL": # Reset the automatic process sort key self.reset_process_sort() endtime = time.mktime(datetime.now().timetuple()) if endtime - self.logs_list[item_index][0] > peak_time: # If event is > peak_time seconds self.logs_list[item_index][1] = endtime else: # If event <= peak_time seconds, ignore self.logs_list.remove(self.logs_list[item_index]) else: # Update the item # State if item_state == "CRITICAL": self.logs_list[item_index][2] = item_state # Value if item_value > self.logs_list[item_index][4]: # MAX self.logs_list[item_index][4] = item_value elif item_value < self.logs_list[item_index][6]: # MIN self.logs_list[item_index][6] = item_value # AVG (compute average value) self.logs_list[item_index][7] += item_value self.logs_list[item_index][8] += 1 self.logs_list[item_index][5] = (self.logs_list[item_index][7] / self.logs_list[item_index][8]) # TOP PROCESS LIST (only for CRITICAL ALERT) if item_state == "CRITICAL": # Sort the current process list to retreive the TOP 3 processes self.logs_list[item_index][9] = sort_stats( proc_list, glances_processes.sort_key)[0:3] self.logs_list[item_index][11] = glances_processes.sort_key # MONITORED PROCESSES DESC self.logs_list[item_index][10] = proc_desc return True
def _update_item(self, item_index, item_state, item_type, item_value, proc_list, proc_desc, peak_time): """Update a item in the log list""" if item_state == "OK" or item_state == "CAREFUL": # Reset the automatic process sort key self.reset_process_sort() endtime = time.mktime(datetime.now().timetuple()) if endtime - self.logs_list[item_index][0] > peak_time: # If event is > peak_time seconds self.logs_list[item_index][1] = endtime else: # If event <= peak_time seconds, ignore self.logs_list.remove(self.logs_list[item_index]) else: # Update the item # State if item_state == "CRITICAL": self.logs_list[item_index][2] = item_state # Value if item_value > self.logs_list[item_index][4]: # MAX self.logs_list[item_index][4] = item_value elif item_value < self.logs_list[item_index][6]: # MIN self.logs_list[item_index][6] = item_value # AVG (compute average value) self.logs_list[item_index][7] += item_value self.logs_list[item_index][8] += 1 self.logs_list[item_index][5] = (self.logs_list[item_index][7] / self.logs_list[item_index][8]) # TOP PROCESS LIST (only for CRITICAL ALERT) if item_state == "CRITICAL": # Sort the current process list to retreive the TOP 3 processes self.logs_list[item_index][9] = sort_stats(proc_list, glances_processes.sort_key)[0:3] self.logs_list[item_index][11] = glances_processes.sort_key # MONITORED PROCESSES DESC self.logs_list[item_index][10] = proc_desc return True
def __sort_stats(self, sortedby=None): """Return the stats (dict) sorted by (sortedby)""" return sort_stats(self.stats, sortedby, tree=glances_processes.is_tree_enabled(), reverse=glances_processes.sort_reverse)
def __sort_stats(self, sortedby=None): """Return the stats (dict) sorted by (sortedby).""" return sort_stats(self.stats, sortedby, reverse=glances_processes.sort_reverse)