def _get_current_processes(self): # Add all current processes to make sure nothing misses the radar process_state_db = {} # list of all processes on the node is made here all_processes = self.process_info_manager.get_all_processes() self.msg_log("DBG: get_current_processes: '%s'" % all_processes, SandeshLevel.SYS_DEBUG) for proc_info in all_processes: proc_name = self._get_process_name(proc_info) proc_pid = int(proc_info['pid']) stat = ProcessStat(proc_name, host_ip=self.hostip, hostname=self.hostname) stat.process_state = proc_info['statename'] if 'start' in proc_info: stat.start_time = str(proc_info['start']) stat.start_count += 1 stat.pid = proc_pid if stat.group not in self.group_names: self.group_names.append(stat.group) if stat.group not in process_state_db: process_state_db[stat.group] = {} process_state_db[stat.group][proc_name] = stat return process_state_db
def _send_process_state(self, process_info): pname = self._get_process_name(process_info) # update process stats if pname in list(key for group in self.process_state_db for key in self.process_state_db[group]): for group in self.process_state_db: if pname in self.process_state_db[group]: proc_stat = self.process_state_db[group][pname] else: proc_stat = ProcessStat(pname, host_ip=self.hostip, hostname=self.hostname) pstate = process_info['state'] proc_stat.process_state = pstate send_uve = False if (pstate == 'PROCESS_STATE_RUNNING'): proc_stat.start_count += 1 proc_stat.start_time = str(int(time.time() * 1000000)) send_uve = True proc_stat.pid = int(process_info['pid']) if (pstate == 'PROCESS_STATE_STOPPED'): proc_stat.stop_count += 1 send_uve = True proc_stat.stop_time = str(int(time.time() * 1000000)) proc_stat.last_exit_unexpected = False proc_stat.last_cpu = None proc_stat.last_time = 0 if (pstate == 'PROCESS_STATE_EXITED'): proc_stat.exit_count += 1 send_uve = True proc_stat.exit_time = str(int(time.time() * 1000000)) proc_stat.last_cpu = None proc_stat.last_time = 0 if not process_info['expected']: self.msg_log('%s with pid: %s exited abnormally' % (pname, process_info['pid']), SandeshLevel.SYS_ERR) proc_stat.last_exit_unexpected = True send_init_uve = False # update process state database if proc_stat.group not in self.process_state_db: self.process_state_db[proc_stat.group] = {} send_init_uve = True self.process_state_db[proc_stat.group][pname] = proc_stat if send_uve: if (send_init_uve): self._send_init_info(proc_stat.group) self.send_process_state_db([proc_stat.group])
def get_process_stat_object(self, pname): return ProcessStat(pname)
def __init__(self, pname, sandesh_logger): self.logger = sandesh_logger ProcessStat.__init__(self, pname) (self.group, self.name) = self.get_vrouter_process_info(pname)
def __init__(self, pname, host_ip, sandesh_logger, hostname=None): self.logger = sandesh_logger self.host_ip = host_ip self.hostname = hostname ProcessStat.__init__(self, pname, self.host_ip, hostname=self.hostname) (self.group, self.name) = self.get_vrouter_process_info(pname)
def __init__(self, pname, sandesh_logger): self.logger = sandesh_logger ProcessStat.__init__(self, pname) (self.group, self.name) = self.get_vrouter_process_info(pname)
def __init__(self, pname): ProcessStat.__init__(self, pname) (self.group, self.name) = self.get_vrouter_process_info(pname)
def __init__(self, pname): ProcessStat.__init__(self, pname) (self.group, self.name) = self.get_vrouter_process_info(pname)