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
Update an event in the list