Skip to content

Commit

Permalink
Added support to display mem/cpu info for third-party processes on al…
Browse files Browse the repository at this point in the history
…l node types.

database node has 2 third-party processes - cassandra, zookeeper
Other nodes types have an empty list for now. This can be populated/extended as needed.
kafka and system mem/cpu is already covered by fix for bug-1467407

Change-Id: I088128fc8afa63b39769251998867f6938ab0c19
Closes-Bug: 1431220
  • Loading branch information
Santosh Gupta committed May 31, 2016
1 parent bffaf4f commit 13bcff0
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/nodemgr/analytics_nodemgr/analytics_event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(self, rule_file, discovery_server,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus)
self.send_system_cpu_info()
self.third_party_process_list = [ ]
# end __init__

def process(self):
Expand All @@ -74,6 +75,9 @@ def send_nodemgr_process_status(self):
ProcessStateNames, ProcessState, ProcessStatus,
NodeStatus, NodeStatusUVE)

def get_node_third_party_process_list(self):
return self.third_party_process_list

def get_node_status_class(self):
return NodeStatus

Expand Down
20 changes: 20 additions & 0 deletions src/nodemgr/common/event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,26 @@ def get_all_processes_mem_cpu_usage(self):
process_mem_cpu.module_id = pstat.pname
process_mem_cpu.inst_id = "0" # ??
process_mem_cpu_usage.append(process_mem_cpu)

# walk through all processes being monitored by nodemgr,
# not spawned by supervisord
third_party_process_list = self.get_node_third_party_process_list()
for pname in third_party_process_list:
cmd = "ps -aux | grep -v grep | grep " + str(pname) + " | awk '{print $2}' | head -n1"
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = proc.communicate()
if (stdout != ''):
pid = int(stdout.strip('\n'))
try:
mem_cpu_usage_data = MemCpuUsageData(pid)
except psutil.NoSuchProcess:
sys.stderr.write("NoSuchProcess: process name:%s pid:%d\n"
% (pname, pid))
else:
process_mem_cpu = mem_cpu_usage_data.get_process_mem_cpu_info()
process_mem_cpu.module_id = pname
process_mem_cpu.inst_id = "0"
process_mem_cpu_usage.append(process_mem_cpu)
return process_mem_cpu_usage

def get_disk_usage(self):
Expand Down
4 changes: 4 additions & 0 deletions src/nodemgr/config_nodemgr/config_event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def __init__(self, rule_file, discovery_server,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus)
self.send_system_cpu_info()
self.third_party_process_list = [ ]
# end __init__

def process(self):
Expand All @@ -83,6 +84,9 @@ def send_nodemgr_process_status(self):
ProcessStateNames, ProcessState, ProcessStatus,
NodeStatus, NodeStatusUVE)

def get_node_third_party_process_list(self):
return self.third_party_process_list

def get_node_status_class(self):
return NodeStatus

Expand Down
4 changes: 4 additions & 0 deletions src/nodemgr/control_nodemgr/control_event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def __init__(self, rule_file, discovery_server,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus)
self.send_system_cpu_info()
self.third_party_process_list = [ ]
# end __init__

def process(self):
Expand All @@ -83,6 +84,9 @@ def send_nodemgr_process_status(self):
ProcessStateNames, ProcessState, ProcessStatus,
NodeStatus, NodeStatusUVE)

def get_node_third_party_process_list(self):
return self.third_party_process_list

def get_node_status_class(self):
return NodeStatus

Expand Down
4 changes: 4 additions & 0 deletions src/nodemgr/database_nodemgr/database_event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def __init__(self, rule_file, discovery_server,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus)
self.send_system_cpu_info()
self.third_party_process_list = [ "cassandra", "zookeeper" ]
# end __init__

def _get_cassandra_config_option(self, config):
Expand Down Expand Up @@ -162,6 +163,9 @@ def send_nodemgr_process_status(self):
ProcessStateNames, ProcessState, ProcessStatus,
NodeStatus, NodeStatusUVE)

def get_node_third_party_process_list(self):
return self.third_party_process_list

def get_node_status_class(self):
return NodeStatus

Expand Down
4 changes: 4 additions & 0 deletions src/nodemgr/vrouter_nodemgr/vrouter_event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def __init__(self, rule_file, discovery_server,

self.lb_stats = LoadbalancerStats()
self.send_system_cpu_info()
self.third_party_process_list = [ ]
# end __init__

def msg_log(self, msg, level):
Expand All @@ -95,6 +96,9 @@ def send_nodemgr_process_status(self):
ProcessStateNames, ProcessState, ProcessStatus,
NodeStatus, NodeStatusUVE)

def get_node_third_party_process_list(self):
return self.third_party_process_list

def get_node_status_class(self):
return NodeStatus

Expand Down

0 comments on commit 13bcff0

Please sign in to comment.