diff --git a/src/analytics/viz.sandesh b/src/analytics/viz.sandesh index 60c461767dd..fa5ae2feb37 100644 --- a/src/analytics/viz.sandesh +++ b/src/analytics/viz.sandesh @@ -1906,7 +1906,7 @@ const list _STAT_TABLES = [ 'obj_table' : COLLECTOR_INFO_TABLE, 'attributes': [ { 'name' : 'disk_usage_info.partition_type', 'datatype' : 'string', 'index' : false }, - { 'name' : 'disk_usage_info.partition_name', 'datatype' : 'string', 'index' : false }, + { 'name' : 'disk_usage_info.__key', 'datatype' : 'string', 'index' : false }, { 'name' : 'disk_usage_info.partition_space_used_1k', 'datatype' : 'int', 'index' : false }, { 'name' : 'disk_usage_info.partition_space_available_1k', 'datatype' : 'int', 'index' : false }, ] @@ -1918,7 +1918,7 @@ const list _STAT_TABLES = [ 'obj_table' : DATABASE_INFO_TABLE, 'attributes': [ { 'name' : 'disk_usage_info.partition_type', 'datatype' : 'string', 'index' : false }, - { 'name' : 'disk_usage_info.partition_name', 'datatype' : 'string', 'index' : false }, + { 'name' : 'disk_usage_info.__key', 'datatype' : 'string', 'index' : false }, { 'name' : 'disk_usage_info.partition_space_used_1k', 'datatype' : 'int', 'index' : false }, { 'name' : 'disk_usage_info.partition_space_available_1k', 'datatype' : 'int', 'index' : false }, ] @@ -1930,7 +1930,7 @@ const list _STAT_TABLES = [ 'obj_table' : CONFIG_NODE_TABLE, 'attributes': [ { 'name' : 'disk_usage_info.partition_type', 'datatype' : 'string', 'index' : false }, - { 'name' : 'disk_usage_info.partition_name', 'datatype' : 'string', 'index' : false }, + { 'name' : 'disk_usage_info.__key', 'datatype' : 'string', 'index' : false }, { 'name' : 'disk_usage_info.partition_space_used_1k', 'datatype' : 'int', 'index' : false }, { 'name' : 'disk_usage_info.partition_space_available_1k', 'datatype' : 'int', 'index' : false }, ] @@ -1942,7 +1942,7 @@ const list _STAT_TABLES = [ 'obj_table' : BGP_ROUTER_TABLE, 'attributes': [ { 'name' : 'disk_usage_info.partition_type', 'datatype' : 'string', 'index' : false }, - { 'name' : 'disk_usage_info.partition_name', 'datatype' : 'string', 'index' : false }, + { 'name' : 'disk_usage_info.__key', 'datatype' : 'string', 'index' : false }, { 'name' : 'disk_usage_info.partition_space_used_1k', 'datatype' : 'int', 'index' : false }, { 'name' : 'disk_usage_info.partition_space_available_1k', 'datatype' : 'int', 'index' : false }, ] @@ -1954,7 +1954,7 @@ const list _STAT_TABLES = [ 'obj_table' : VROUTER_TABLE, 'attributes': [ { 'name' : 'disk_usage_info.partition_type', 'datatype' : 'string', 'index' : false }, - { 'name' : 'disk_usage_info.partition_name', 'datatype' : 'string', 'index' : false }, + { 'name' : 'disk_usage_info.__key', 'datatype' : 'string', 'index' : false }, { 'name' : 'disk_usage_info.partition_space_used_1k', 'datatype' : 'int', 'index' : false }, { 'name' : 'disk_usage_info.partition_space_available_1k', 'datatype' : 'int', 'index' : false }, ] @@ -1965,8 +1965,7 @@ const list _STAT_TABLES = [ 'stat_attr' : 'process_mem_cpu_usage', 'obj_table' : COLLECTOR_INFO_TABLE, 'attributes': [ - { 'name' : 'process_mem_cpu_usage.module_id', 'datatype' : 'string', 'index' : true, 'suffixes': ['process_mem_cpu_usage.inst_id']}, - { 'name' : 'process_mem_cpu_usage.inst_id', 'datatype' : 'string', 'index' : false }, + { 'name' : 'process_mem_cpu_usage.__key', 'datatype' : 'string', 'index' : true}, { 'name' : 'process_mem_cpu_usage.mem_virt', 'datatype' : 'int', 'index' : false }, { 'name' : 'process_mem_cpu_usage.cpu_share', 'datatype' : 'double', 'index' : true}, { 'name' : 'process_mem_cpu_usage.mem_res', 'datatype' : 'int', 'index' : false }, @@ -1978,8 +1977,7 @@ const list _STAT_TABLES = [ 'stat_attr' : 'process_mem_cpu_usage', 'obj_table' : DATABASE_INFO_TABLE, 'attributes': [ - { 'name' : 'process_mem_cpu_usage.module_id', 'datatype' : 'string', 'index' : true, 'suffixes': ['process_mem_cpu_usage.inst_id']}, - { 'name' : 'process_mem_cpu_usage.inst_id', 'datatype' : 'string', 'index' : false }, + { 'name' : 'process_mem_cpu_usage.__key', 'datatype' : 'string', 'index' : true}, { 'name' : 'process_mem_cpu_usage.mem_virt', 'datatype' : 'int', 'index' : false }, { 'name' : 'process_mem_cpu_usage.cpu_share', 'datatype' : 'double', 'index' : true}, { 'name' : 'process_mem_cpu_usage.mem_res', 'datatype' : 'int', 'index' : false }, @@ -1991,8 +1989,7 @@ const list _STAT_TABLES = [ 'stat_attr' : 'process_mem_cpu_usage', 'obj_table' : CONFIG_NODE_TABLE, 'attributes': [ - { 'name' : 'process_mem_cpu_usage.module_id', 'datatype' : 'string', 'index' : true, 'suffixes': ['process_mem_cpu_usage.inst_id']}, - { 'name' : 'process_mem_cpu_usage.inst_id', 'datatype' : 'string', 'index' : false }, + { 'name' : 'process_mem_cpu_usage.__key', 'datatype' : 'string', 'index' : true}, { 'name' : 'process_mem_cpu_usage.mem_virt', 'datatype' : 'int', 'index' : false }, { 'name' : 'process_mem_cpu_usage.cpu_share', 'datatype' : 'double', 'index' : true}, { 'name' : 'process_mem_cpu_usage.mem_res', 'datatype' : 'int', 'index' : false }, @@ -2004,8 +2001,7 @@ const list _STAT_TABLES = [ 'stat_attr' : 'process_mem_cpu_usage', 'obj_table' : BGP_ROUTER_TABLE, 'attributes': [ - { 'name' : 'process_mem_cpu_usage.module_id', 'datatype' : 'string', 'index' : true, 'suffixes': ['process_mem_cpu_usage.inst_id']}, - { 'name' : 'process_mem_cpu_usage.inst_id', 'datatype' : 'string', 'index' : false }, + { 'name' : 'process_mem_cpu_usage.__key', 'datatype' : 'string', 'index' : true}, { 'name' : 'process_mem_cpu_usage.mem_virt', 'datatype' : 'int', 'index' : false }, { 'name' : 'process_mem_cpu_usage.cpu_share', 'datatype' : 'double', 'index' : true}, { 'name' : 'process_mem_cpu_usage.mem_res', 'datatype' : 'int', 'index' : false }, @@ -2017,8 +2013,7 @@ const list _STAT_TABLES = [ 'stat_attr' : 'process_mem_cpu_usage', 'obj_table' : VROUTER_TABLE, 'attributes': [ - { 'name' : 'process_mem_cpu_usage.module_id', 'datatype' : 'string', 'index' : true, 'suffixes': ['process_mem_cpu_usage.inst_id']}, - { 'name' : 'process_mem_cpu_usage.inst_id', 'datatype' : 'string', 'index' : false }, + { 'name' : 'process_mem_cpu_usage.__key', 'datatype' : 'string', 'index' : true}, { 'name' : 'process_mem_cpu_usage.mem_virt', 'datatype' : 'int', 'index' : false }, { 'name' : 'process_mem_cpu_usage.cpu_share', 'datatype' : 'double', 'index' : true}, { 'name' : 'process_mem_cpu_usage.mem_res', 'datatype' : 'int', 'index' : false }, diff --git a/src/base/sandesh/cpuinfo.sandesh b/src/base/sandesh/cpuinfo.sandesh index e0dcad713e6..aef04d6c3d2 100644 --- a/src/base/sandesh/cpuinfo.sandesh +++ b/src/base/sandesh/cpuinfo.sandesh @@ -52,8 +52,8 @@ response sandesh CpuLoadInfoResp { * this is used to store cpu and memory statistics on a per process basis */ struct ProcessCpuInfo { - 1: string module_id - 2: string inst_id + 1: string module_id // deprecated + 2: string inst_id // deprecated 3: u32 mem_virt 4: double cpu_share 5: u32 mem_res diff --git a/src/base/sandesh/nodeinfo.sandesh b/src/base/sandesh/nodeinfo.sandesh index 3423070d812..a893e3859fc 100644 --- a/src/base/sandesh/nodeinfo.sandesh +++ b/src/base/sandesh/nodeinfo.sandesh @@ -30,11 +30,13 @@ struct NodeStatus { 4: optional list process_status (aggtype="union") // Sent by node manager 5: optional list process_info (aggtype="union") - 6: optional list disk_usage_info (tags="") + // map key is partition name + 6: optional map disk_usage_info (tags="") 7: optional string description 8: optional list all_core_file_list 9: optional string build_info - 10: optional list process_mem_cpu_usage (tags=".module_id:.inst_id,.cpu_share") + // map key is : + 10: optional map process_mem_cpu_usage (tags=".__key,.cpu_share") 11: optional cpuinfo.SystemMemCpuUsage system_mem_cpu_usage(tags=".cpu_share") 12: optional cpuinfo.SystemCpuInfo system_cpu_info } diff --git a/src/base/sandesh/process_info.sandesh b/src/base/sandesh/process_info.sandesh index 970d0ca6503..3393fddb3b4 100644 --- a/src/base/sandesh/process_info.sandesh +++ b/src/base/sandesh/process_info.sandesh @@ -92,7 +92,7 @@ struct ProcessStatus { */ struct DiskPartitionUsageStats { 1: string partition_type - 2: string partition_name + 2: string partition_name // deprecated 3: u64 partition_space_used_1k 4: u64 partition_space_available_1k 5: u16 percentage_partition_space_used diff --git a/src/nodemgr/common/event_manager.py b/src/nodemgr/common/event_manager.py index fcb0a805945..c625a025d5f 100644 --- a/src/nodemgr/common/event_manager.py +++ b/src/nodemgr/common/event_manager.py @@ -385,7 +385,7 @@ def get_system_mem_cpu_usage(self): return system_mem_cpu_usage_data.get_sys_mem_cpu_info() def get_all_processes_mem_cpu_usage(self): - process_mem_cpu_usage = [] + process_mem_cpu_usage = {} for key in self.process_state_db: pstat = self.process_state_db[key] if (pstat.process_state == 'PROCESS_STATE_RUNNING'): @@ -396,9 +396,8 @@ def get_all_processes_mem_cpu_usage(self): sys.stderr.write("NoSuchProcess: process name:%s pid:%d\n" % (pstat.pname, pstat.pid)) else: - process_mem_cpu.module_id = pstat.pname - process_mem_cpu.inst_id = "0" # ?? - process_mem_cpu_usage.append(process_mem_cpu) + process_mem_cpu.__key = pstat.pname + process_mem_cpu_usage[process_mem_cpu.__key] = process_mem_cpu # walk through all processes being monitored by nodemgr, # not spawned by supervisord @@ -416,13 +415,12 @@ def get_all_processes_mem_cpu_usage(self): sys.stderr.write("NoSuchProcess: process name:%s pid:%d\n" % (pname, pid)) else: - process_mem_cpu.module_id = pname - process_mem_cpu.inst_id = "0" - process_mem_cpu_usage.append(process_mem_cpu) + process_mem_cpu.__key = pname + process_mem_cpu_usage[process_mem_cpu.__key] = process_mem_cpu return process_mem_cpu_usage def get_disk_usage(self): - disk_usage_info = [] + disk_usage_info = {} partition = subprocess.Popen( "df -T -t ext2 -t ext3 -t ext4 -t xfs", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -436,7 +434,7 @@ def get_disk_usage(self): disk_usage_stat = DiskPartitionUsageStats() try: disk_usage_stat.partition_type = str(partition_type) - disk_usage_stat.partition_name = str(partition_name) + disk_usage_stat.__key = str(partition_name) disk_usage_stat.partition_space_used_1k = \ int(partition_space_used_1k) disk_usage_stat.partition_space_available_1k = \ @@ -450,7 +448,7 @@ def get_disk_usage(self): except ValueError: sys.stderr.write("Failed to get local disk space usage" + "\n") else: - disk_usage_info.append(disk_usage_stat) + disk_usage_info[partition_name] = disk_usage_stat return disk_usage_info # end get_disk_usage