def add(self, item_state, item_type, item_value, proc_list=None, proc_desc="", peak_time=6): """Add a new item to the logs list. If 'item' is a 'new one', add the new item at the beginning of the logs list. If 'item' is not a 'new one', update the existing item. If event < peak_time the the alert is not setoff. """ proc_list = proc_list or glances_processes.getlist() # Add or update the log item_index = self.__itemexist__(item_type) if item_index < 0: # Item did not exist, add if WARNING or CRITICAL self._create_item(item_state, item_type, item_value, proc_list, proc_desc, peak_time) else: # Item exist, update self._update_item(item_index, item_state, item_type, item_value, proc_list, proc_desc, peak_time) return self.len()
def update(self): """Update the command result attributed.""" # Get the current processes list (once) processlist = glances_processes.getlist() # Iter upon the AMPs dict for k, v in iteritems(self.get()): if not v.enable(): # Do not update if the enable tag is set continue amps_list = self._build_amps_list(v, processlist) if len(amps_list) > 0: # At least one process is matching the regex logger.debug("AMPS: {} processes {} detected ({})".format(len(amps_list), k, amps_list)) # Call the AMP update method thread = threading.Thread(target=v.update_wrapper, args=[amps_list]) thread.start() else: # Set the process number to 0 v.set_count(0) if v.count_min() is not None and v.count_min() > 0: # Only display the "No running process message" if countmin is defined v.set_result("No running process") return self.__amps_dict
def update(self): """Update the command result attributed.""" # Search application monitored processes by a regular expression processlist = glances_processes.getlist() # Iter upon the AMPs dict for k, v in iteritems(self.get()): if not v.enable(): # Do not update if the enable tag is set continue try: # Search in both cmdline and name (for kernel thread, see #1261) amps_list = [p['pid'] for p in processlist for c in p['cmdline'] if ((re.search(v.regex(), c) is not None) or (re.search(v.regex(), p['name']) is not None))] amps_list = list(set(amps_list)) except (TypeError, KeyError): continue if len(amps_list) > 0: # At least one process is matching the regex logger.debug("AMPS: {} processes {} detected ({})".format(len(amps_list), k, amps_list)) # Call the AMP update method thread = threading.Thread(target=v.update_wrapper, args=[amps_list]) thread.start() else: # Set the process number to 0 v.set_count(0) if v.count_min() is not None and v.count_min() > 0: # Only display the "No running process message" is countmin is defined v.set_result("No running process") return self.__amps_dict
def add(self, event_state, event_type, event_value, proc_list=None, proc_desc="", peak_time=6): """Add a new item to the logs list. If 'event' is a 'new one', add it at the beginning of the list. If 'event' is not a 'new one', update the list . If event < peak_time then the alert is not set. """ proc_list = proc_list or glances_processes.getlist() # Add or update the log event_index = self.__event_exist(event_type) if event_index < 0: # Event did not exist, add it self._create_event(event_state, event_type, event_value, proc_list, proc_desc, peak_time) else: # Event exist, update it self._update_event(event_index, event_state, event_type, event_value, proc_list, proc_desc, peak_time) return self.len()
def update(self): """Update processes stats using the input method.""" # Reset stats self.reset() if self.input_method == 'local': # Update stats using the standard system lib # Note: Update is done in the processcount plugin # Just return the processes list if glances_processes.is_tree_enabled(): self.stats = glances_processes.gettree() else: self.stats = glances_processes.getlist() elif self.input_method == 'snmp': # No SNMP grab for processes pass return self.stats
def update(self): """Update processes stats using the input method.""" # Reset stats self.reset() if self.input_method == 'local': # Update stats using the standard system lib # Note: Update is done in the processcount plugin # Just return the processes list if glances_processes.is_tree_enabled(): self.stats = glances_processes.gettree() else: self.stats = glances_processes.getlist() elif self.input_method == 'snmp': # No SNMP grab for processes pass return self.stats
def add(self, event_state, event_type, event_value, proc_list=None, proc_desc="", peak_time=6): """Add a new item to the logs list. If 'event' is a 'new one', add it at the beginning of the list. If 'event' is not a 'new one', update the list . If event < peak_time then the alert is not set. """ proc_list = proc_list or glances_processes.getlist() # Add or update the log event_index = self.__event_exist(event_type) if event_index < 0: # Event did not exist, add it self._create_event(event_state, event_type, event_value, proc_list, proc_desc, peak_time) else: # Event exist, update it self._update_event(event_index, event_state, event_type, event_value, proc_list, proc_desc, peak_time) return self.len()
def update(self): """Update processes stats using the input method.""" # Init new stats stats = self.get_init_value() if self.input_method == 'local': # Update stats using the standard system lib # Note: Update is done in the processcount plugin # Just return the processes list stats = glances_processes.getlist() elif self.input_method == 'snmp': # No SNMP grab for processes pass # Update the stats self.stats = stats # Get the max values (dict) # Use Deep copy to avoid change between update and display self.max_values = copy.deepcopy(glances_processes.max_values()) return self.stats
def add(self, item_state, item_type, item_value, proc_list=None, proc_desc="", peak_time=6): """Add a new item to the logs list. If 'item' is a 'new one', add the new item at the beginning of the logs list. If 'item' is not a 'new one', update the existing item. If event < peak_time the the alert is not setoff. """ proc_list = proc_list or glances_processes.getlist() # Add or update the log item_index = self.__itemexist__(item_type) if item_index < 0: # Item did not exist, add if WARNING or CRITICAL self._create_item(item_state, item_type, item_value, proc_list, proc_desc, peak_time) else: # Item exist, update self._update_item(item_index, item_state, item_type, item_value, proc_list, proc_desc, peak_time) return self.len()