diff --git a/addons/hpcmonitor4b/actions/action_blade.py b/addons/hpcmonitor4b/actions/action_blade.py index 99aee187171b0bf0e73a5bd0fd7616aea1f3c458..006ce7f62bd930b6c087c2ff92e37125b68caab1 100644 --- a/addons/hpcmonitor4b/actions/action_blade.py +++ b/addons/hpcmonitor4b/actions/action_blade.py @@ -34,7 +34,7 @@ for ob_node in ob_blade.children: for ob_label in ob_node.children: ob_label.location = ob_label['LOCATION'] - ob_label.display_type = 'SOLID' + #ob_label.display_type = 'SOLID' \ No newline at end of file diff --git a/addons/hpcmonitor4b/hpcmonitor4b_client.py b/addons/hpcmonitor4b/hpcmonitor4b_client.py index 4cd0a22e45068ff49772c5498557c73374dbf041..4b5ffae1c550073bff3afd60e6ac83a31031c9c1 100644 --- a/addons/hpcmonitor4b/hpcmonitor4b_client.py +++ b/addons/hpcmonitor4b/hpcmonitor4b_client.py @@ -58,6 +58,13 @@ class HPCMonitor4BClient: return response + def GetStatusMsr(self, context, type): + pref = hpcmonitor4b_pref.preferences() + response = self.hpcmonitor4b_stub.GetStatusMsr( + hpcmonitor4b_pb2.GetStatusMsrRequest(type=type, username=pref.username, password=pref.password)) + + return response + def GetStatusPower(self, context, type): pref = hpcmonitor4b_pref.preferences() response = self.hpcmonitor4b_stub.GetStatusPower( diff --git a/addons/hpcmonitor4b/hpcmonitor4b_pb2.py b/addons/hpcmonitor4b/hpcmonitor4b_pb2.py index 054a6ce64e37cfdb500055d636377829287d8e6b..6f031ce03ce40b7eef27f5a40ec37426305aa1aa 100644 --- a/addons/hpcmonitor4b/hpcmonitor4b_pb2.py +++ b/addons/hpcmonitor4b/hpcmonitor4b_pb2.py @@ -13,7 +13,7 @@ _sym_db = _symbol_database.Default() -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12hpcmonitor4b.proto\x12\x12proto_hpcmonitor4b\"J\n\x16GetStatusSystemRequest\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x10\n\x08password\x18\x03 \x01(\t\"=\n\x0cSystemRecord\x12\r\n\x05value\x18\x01 \x01(\t\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12\x0c\n\x04time\x18\x03 \x01(\t\"K\n\x17GetStatusSystemResponse\x12\x30\n\x06values\x18\x01 \x03(\x0b\x32 .proto_hpcmonitor4b.SystemRecord\"H\n\x14GetStatusNvmlRequest\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x10\n\x08password\x18\x03 \x01(\t\"\x1e\n\rNvmlGPURecord\x12\r\n\x05value\x18\x01 \x01(\t\"]\n\nNvmlRecord\x12/\n\x04gpus\x18\x01 \x03(\x0b\x32!.proto_hpcmonitor4b.NvmlGPURecord\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12\x0c\n\x04time\x18\x03 \x01(\t\"G\n\x15GetStatusNvmlResponse\x12.\n\x06values\x18\x01 \x03(\x0b\x32\x1e.proto_hpcmonitor4b.NvmlRecord\"Y\n\x13GetSystemPNGRequest\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12\x10\n\x08username\x18\x03 \x01(\t\x12\x10\n\x08password\x18\x04 \x01(\t\"%\n\x14GetSystemPNGResponse\x12\r\n\x05image\x18\x01 \x01(\x0c\"D\n\x11GetJobInfoRequest\x12\x0b\n\x03job\x18\x01 \x01(\t\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x10\n\x08password\x18\x03 \x01(\t\"\'\n\x12GetJobInfoResponse\x12\x11\n\thostnames\x18\x01 \x03(\t\"I\n\x15GetStatusPowerRequest\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x10\n\x08password\x18\x03 \x01(\t\"<\n\x0bPowerRecord\x12\r\n\x05value\x18\x01 \x01(\t\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12\x0c\n\x04time\x18\x03 \x01(\t\"I\n\x16GetStatusPowerResponse\x12/\n\x06values\x18\x01 \x03(\x0b\x32\x1f.proto_hpcmonitor4b.PowerRecord2\xda\x06\n\x0cHPCMonitor4B\x12l\n\x0fGetStatusSystem\x12*.proto_hpcmonitor4b.GetStatusSystemRequest\x1a+.proto_hpcmonitor4b.GetStatusSystemResponse\"\x00\x12\x66\n\rGetStatusNvml\x12(.proto_hpcmonitor4b.GetStatusNvmlRequest\x1a).proto_hpcmonitor4b.GetStatusNvmlResponse\"\x00\x12i\n\x0eGetStatusPower\x12).proto_hpcmonitor4b.GetStatusPowerRequest\x1a*.proto_hpcmonitor4b.GetStatusPowerResponse\"\x00\x12g\n\x10GetSystemLoadPNG\x12\'.proto_hpcmonitor4b.GetSystemPNGRequest\x1a(.proto_hpcmonitor4b.GetSystemPNGResponse\"\x00\x12h\n\x11GetSystemPowerPNG\x12\'.proto_hpcmonitor4b.GetSystemPNGRequest\x1a(.proto_hpcmonitor4b.GetSystemPNGResponse\"\x00\x12j\n\x13GetSystemLoadGPUPNG\x12\'.proto_hpcmonitor4b.GetSystemPNGRequest\x1a(.proto_hpcmonitor4b.GetSystemPNGResponse\"\x00\x12k\n\x14GetSystemPowerGPUPNG\x12\'.proto_hpcmonitor4b.GetSystemPNGRequest\x1a(.proto_hpcmonitor4b.GetSystemPNGResponse\"\x00\x12]\n\nGetJobInfo\x12%.proto_hpcmonitor4b.GetJobInfoRequest\x1a&.proto_hpcmonitor4b.GetJobInfoResponse\"\x00\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12hpcmonitor4b.proto\x12\x12proto_hpcmonitor4b\"J\n\x16GetStatusSystemRequest\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x10\n\x08password\x18\x03 \x01(\t\"=\n\x0cSystemRecord\x12\r\n\x05value\x18\x01 \x01(\t\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12\x0c\n\x04time\x18\x03 \x01(\t\"K\n\x17GetStatusSystemResponse\x12\x30\n\x06values\x18\x01 \x03(\x0b\x32 .proto_hpcmonitor4b.SystemRecord\"H\n\x14GetStatusNvmlRequest\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x10\n\x08password\x18\x03 \x01(\t\"\x1e\n\rNvmlGPURecord\x12\r\n\x05value\x18\x01 \x01(\t\"]\n\nNvmlRecord\x12/\n\x04gpus\x18\x01 \x03(\x0b\x32!.proto_hpcmonitor4b.NvmlGPURecord\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12\x0c\n\x04time\x18\x03 \x01(\t\"G\n\x15GetStatusNvmlResponse\x12.\n\x06values\x18\x01 \x03(\x0b\x32\x1e.proto_hpcmonitor4b.NvmlRecord\"G\n\x13GetStatusMsrRequest\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x10\n\x08password\x18\x03 \x01(\t\"\x1d\n\x0cMsrCPURecord\x12\r\n\x05value\x18\x01 \x01(\t\"[\n\tMsrRecord\x12.\n\x04\x63pus\x18\x01 \x03(\x0b\x32 .proto_hpcmonitor4b.MsrCPURecord\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12\x0c\n\x04time\x18\x03 \x01(\t\"E\n\x14GetStatusMsrResponse\x12-\n\x06values\x18\x01 \x03(\x0b\x32\x1d.proto_hpcmonitor4b.MsrRecord\"Y\n\x13GetSystemPNGRequest\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12\x10\n\x08username\x18\x03 \x01(\t\x12\x10\n\x08password\x18\x04 \x01(\t\"%\n\x14GetSystemPNGResponse\x12\r\n\x05image\x18\x01 \x01(\x0c\"D\n\x11GetJobInfoRequest\x12\x0b\n\x03job\x18\x01 \x01(\t\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x10\n\x08password\x18\x03 \x01(\t\"\'\n\x12GetJobInfoResponse\x12\x11\n\thostnames\x18\x01 \x03(\t\"I\n\x15GetStatusPowerRequest\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x10\n\x08password\x18\x03 \x01(\t\"<\n\x0bPowerRecord\x12\r\n\x05value\x18\x01 \x01(\t\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12\x0c\n\x04time\x18\x03 \x01(\t\"I\n\x16GetStatusPowerResponse\x12/\n\x06values\x18\x01 \x03(\x0b\x32\x1f.proto_hpcmonitor4b.PowerRecord2\xbf\x07\n\x0cHPCMonitor4B\x12l\n\x0fGetStatusSystem\x12*.proto_hpcmonitor4b.GetStatusSystemRequest\x1a+.proto_hpcmonitor4b.GetStatusSystemResponse\"\x00\x12\x66\n\rGetStatusNvml\x12(.proto_hpcmonitor4b.GetStatusNvmlRequest\x1a).proto_hpcmonitor4b.GetStatusNvmlResponse\"\x00\x12\x63\n\x0cGetStatusMsr\x12\'.proto_hpcmonitor4b.GetStatusMsrRequest\x1a(.proto_hpcmonitor4b.GetStatusMsrResponse\"\x00\x12i\n\x0eGetStatusPower\x12).proto_hpcmonitor4b.GetStatusPowerRequest\x1a*.proto_hpcmonitor4b.GetStatusPowerResponse\"\x00\x12g\n\x10GetSystemLoadPNG\x12\'.proto_hpcmonitor4b.GetSystemPNGRequest\x1a(.proto_hpcmonitor4b.GetSystemPNGResponse\"\x00\x12h\n\x11GetSystemPowerPNG\x12\'.proto_hpcmonitor4b.GetSystemPNGRequest\x1a(.proto_hpcmonitor4b.GetSystemPNGResponse\"\x00\x12j\n\x13GetSystemLoadGPUPNG\x12\'.proto_hpcmonitor4b.GetSystemPNGRequest\x1a(.proto_hpcmonitor4b.GetSystemPNGResponse\"\x00\x12k\n\x14GetSystemPowerGPUPNG\x12\'.proto_hpcmonitor4b.GetSystemPNGRequest\x1a(.proto_hpcmonitor4b.GetSystemPNGResponse\"\x00\x12]\n\nGetJobInfo\x12%.proto_hpcmonitor4b.GetJobInfoRequest\x1a&.proto_hpcmonitor4b.GetJobInfoResponse\"\x00\x62\x06proto3') _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'hpcmonitor4b_pb2', globals()) @@ -34,20 +34,28 @@ if _descriptor._USE_C_DESCRIPTORS == False: _NVMLRECORD._serialized_end=457 _GETSTATUSNVMLRESPONSE._serialized_start=459 _GETSTATUSNVMLRESPONSE._serialized_end=530 - _GETSYSTEMPNGREQUEST._serialized_start=532 - _GETSYSTEMPNGREQUEST._serialized_end=621 - _GETSYSTEMPNGRESPONSE._serialized_start=623 - _GETSYSTEMPNGRESPONSE._serialized_end=660 - _GETJOBINFOREQUEST._serialized_start=662 - _GETJOBINFOREQUEST._serialized_end=730 - _GETJOBINFORESPONSE._serialized_start=732 - _GETJOBINFORESPONSE._serialized_end=771 - _GETSTATUSPOWERREQUEST._serialized_start=773 - _GETSTATUSPOWERREQUEST._serialized_end=846 - _POWERRECORD._serialized_start=848 - _POWERRECORD._serialized_end=908 - _GETSTATUSPOWERRESPONSE._serialized_start=910 - _GETSTATUSPOWERRESPONSE._serialized_end=983 - _HPCMONITOR4B._serialized_start=986 - _HPCMONITOR4B._serialized_end=1844 + _GETSTATUSMSRREQUEST._serialized_start=532 + _GETSTATUSMSRREQUEST._serialized_end=603 + _MSRCPURECORD._serialized_start=605 + _MSRCPURECORD._serialized_end=634 + _MSRRECORD._serialized_start=636 + _MSRRECORD._serialized_end=727 + _GETSTATUSMSRRESPONSE._serialized_start=729 + _GETSTATUSMSRRESPONSE._serialized_end=798 + _GETSYSTEMPNGREQUEST._serialized_start=800 + _GETSYSTEMPNGREQUEST._serialized_end=889 + _GETSYSTEMPNGRESPONSE._serialized_start=891 + _GETSYSTEMPNGRESPONSE._serialized_end=928 + _GETJOBINFOREQUEST._serialized_start=930 + _GETJOBINFOREQUEST._serialized_end=998 + _GETJOBINFORESPONSE._serialized_start=1000 + _GETJOBINFORESPONSE._serialized_end=1039 + _GETSTATUSPOWERREQUEST._serialized_start=1041 + _GETSTATUSPOWERREQUEST._serialized_end=1114 + _POWERRECORD._serialized_start=1116 + _POWERRECORD._serialized_end=1176 + _GETSTATUSPOWERRESPONSE._serialized_start=1178 + _GETSTATUSPOWERRESPONSE._serialized_end=1251 + _HPCMONITOR4B._serialized_start=1254 + _HPCMONITOR4B._serialized_end=2213 # @@protoc_insertion_point(module_scope) diff --git a/addons/hpcmonitor4b/hpcmonitor4b_pb2_grpc.py b/addons/hpcmonitor4b/hpcmonitor4b_pb2_grpc.py index 84869678b4ffdf55d56c8cd9ff6aa650ff6ebb56..37610d4b78bf0f4c78ee855c8faa088c41b13d1a 100644 --- a/addons/hpcmonitor4b/hpcmonitor4b_pb2_grpc.py +++ b/addons/hpcmonitor4b/hpcmonitor4b_pb2_grpc.py @@ -24,6 +24,11 @@ class HPCMonitor4BStub(object): request_serializer=hpcmonitor4b__pb2.GetStatusNvmlRequest.SerializeToString, response_deserializer=hpcmonitor4b__pb2.GetStatusNvmlResponse.FromString, ) + self.GetStatusMsr = channel.unary_unary( + '/proto_hpcmonitor4b.HPCMonitor4B/GetStatusMsr', + request_serializer=hpcmonitor4b__pb2.GetStatusMsrRequest.SerializeToString, + response_deserializer=hpcmonitor4b__pb2.GetStatusMsrResponse.FromString, + ) self.GetStatusPower = channel.unary_unary( '/proto_hpcmonitor4b.HPCMonitor4B/GetStatusPower', request_serializer=hpcmonitor4b__pb2.GetStatusPowerRequest.SerializeToString, @@ -71,6 +76,12 @@ class HPCMonitor4BServicer(object): context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') + def GetStatusMsr(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + def GetStatusPower(self, request, context): """Missing associated documentation comment in .proto file.""" context.set_code(grpc.StatusCode.UNIMPLEMENTED) @@ -120,6 +131,11 @@ def add_HPCMonitor4BServicer_to_server(servicer, server): request_deserializer=hpcmonitor4b__pb2.GetStatusNvmlRequest.FromString, response_serializer=hpcmonitor4b__pb2.GetStatusNvmlResponse.SerializeToString, ), + 'GetStatusMsr': grpc.unary_unary_rpc_method_handler( + servicer.GetStatusMsr, + request_deserializer=hpcmonitor4b__pb2.GetStatusMsrRequest.FromString, + response_serializer=hpcmonitor4b__pb2.GetStatusMsrResponse.SerializeToString, + ), 'GetStatusPower': grpc.unary_unary_rpc_method_handler( servicer.GetStatusPower, request_deserializer=hpcmonitor4b__pb2.GetStatusPowerRequest.FromString, @@ -194,6 +210,23 @@ class HPCMonitor4B(object): options, channel_credentials, insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + @staticmethod + def GetStatusMsr(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/proto_hpcmonitor4b.HPCMonitor4B/GetStatusMsr', + hpcmonitor4b__pb2.GetStatusMsrRequest.SerializeToString, + hpcmonitor4b__pb2.GetStatusMsrResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + @staticmethod def GetStatusPower(request, target, diff --git a/addons/hpcmonitor4b/monitoring.py b/addons/hpcmonitor4b/monitoring.py index 23c13262cd5ff149976b9d6b2c973f8b6bade1f9..aa2a6955e82c63f5ace975f61a0d5aaa3a66ca2d 100644 --- a/addons/hpcmonitor4b/monitoring.py +++ b/addons/hpcmonitor4b/monitoring.py @@ -18,6 +18,7 @@ import bpy import math +from pathlib import Path monitor_type_items = [ ("NONE", "None", ""), @@ -62,9 +63,19 @@ class HPCMonitor4BMonitoringShowHostname(bpy.types.Operator): if len(context.scene.view_pg_hpcmonitor4b_monitoring.filter_jobid) > 0: filter_hostnames = get_hostnames_by_jobid(context, context.scene.view_pg_hpcmonitor4b_monitoring.filter_jobid) + tex_path = context.scene.view_pg_hpcmonitor4b_prepare_scene.output_path + for ob in bpy.data.objects: if 'LABEL' in ob: if filter_hostnames is None or ob.name in filter_hostnames: + + filename = ob.name.replace('.karolina.it4i.cz', '') + tex_filename = str( + Path(bpy.path.abspath(tex_path)) / (filename + '.png')) + + texture_node = ob.material_slots[0].material.node_tree.nodes['Image Texture'] + texture_node.image = bpy.data.images.load(tex_filename) + ob.display_type = 'TEXTURED' bpy.data.objects["TOTAL"].data.body = 'Total:' @@ -119,20 +130,41 @@ class HPCMonitor4BMonitoringShowLoad(bpy.types.Operator): total = 0.0 total_count = 0 + tex_path = context.scene.view_pg_hpcmonitor4b_prepare_scene.output_path + # average utilization all cores per 1 min system_data = context.scene.hpcmonitor4b_client.GetStatusSystem(context, 'load1') for system_record in system_data.values: if filter_hostnames is None or system_record.hostname in filter_hostnames: if system_record.hostname in bpy.data.objects: ob = bpy.data.objects[system_record.hostname] + fvalue = int(float(system_record.value)) + ob.material_slots[0].material.diffuse_color = ( - float(system_record.value) / 128.0, 0, 0, 1) + fvalue / 128.0, 0, 0, 1) + + if not math.isnan(fvalue): + total = total + fvalue / 128.0 + ivalue = int(fvalue) + else: + ivalue = 0 + + total_count = total_count + 1 + + if ivalue > 128: + ivalue = 128 + elif ivalue < 0: + ivalue = 0 - if not math.isnan(float(system_record.value)): - total = total + float(system_record.value) / 128.0 - total_count = total_count + 1 + filename = 'load_cpu_%d' % (ivalue) + tex_filename = str( + Path(bpy.path.abspath(tex_path)) / (filename + '.png')) - ob.display_type = 'SOLID' + texture_node = ob.material_slots[0].material.node_tree.nodes['Image Texture'] + texture_node.image = bpy.data.images.load(tex_filename) + + #ob.display_type = 'SOLID' + ob.display_type = 'TEXTURED' nvml_data = context.scene.hpcmonitor4b_client.GetStatusNvml( context, 'UTILIZATION_SM') @@ -141,18 +173,35 @@ class HPCMonitor4BMonitoringShowLoad(bpy.types.Operator): hostname = 'gpu.' + nvml_record.hostname if hostname in bpy.data.objects: ob = bpy.data.objects[hostname] - value = 0.0 + fvalue = 0.0 for gpu in nvml_record.gpus: - value = value + float(gpu.value) + fvalue = fvalue + float(gpu.value) ob.material_slots[0].material.diffuse_color = ( - 0, float(value) / 800.0, 0, 1) + 0, fvalue / 800.0, 0, 1) + + if not math.isnan(fvalue): + total = total + fvalue / 800.0 + ivalue = int(fvalue) + else: + ivalue = 0 + + total_count = total_count + 1 + + if ivalue > 800: + ivalue = 800 + elif ivalue < 0: + ivalue = 0 - if not math.isnan(float(value)): - total = total + float(value) / 800.0 - total_count = total_count + 1 + filename = 'load_gpu_%d' % (ivalue) + tex_filename = str( + Path(bpy.path.abspath(tex_path)) / (filename + '.png')) - ob.display_type = 'SOLID' + texture_node = ob.material_slots[0].material.node_tree.nodes['Image Texture'] + texture_node.image = bpy.data.images.load(tex_filename) + + # ob.display_type = 'SOLID' + ob.display_type = 'TEXTURED' # Total bpy.data.objects["TOTAL"].data.body = 'Total Load: %0.1f %%' % (float(total) * 60.0 / float(total_count)) @@ -174,20 +223,76 @@ class HPCMonitor4BMonitoringShowPower(bpy.types.Operator): if len(context.scene.view_pg_hpcmonitor4b_monitoring.filter_jobid) > 0: filter_hostnames = get_hostnames_by_jobid(context, context.scene.view_pg_hpcmonitor4b_monitoring.filter_jobid) - total = 0.0 + total = 0.0 + tex_path = context.scene.view_pg_hpcmonitor4b_prepare_scene.output_path + + # system_data = context.scene.hpcmonitor4b_client.GetStatusPower(context, 'average') + # for system_record in system_data.values: + # if filter_hostnames is None or system_record.hostname in filter_hostnames: + # if system_record.hostname in bpy.data.objects: + # ob = bpy.data.objects[system_record.hostname] + # fvalue = float(system_record.value) + # ob.material_slots[0].material.diffuse_color = ( + # fvalue / 700.0, 0, 0, 1) + + # if not math.isnan(fvalue): + # total = total + fvalue + # ivalue = int(fvalue) + # else: + # ivalue = 0 + + # print(ob.name, ' ', ivalue) + + # if ivalue > 700: + # ivalue = 700 + # elif ivalue < 0: + # ivalue = 0 + + # filename = 'power_cpu_%d' % (ivalue) + # tex_filename = str( + # Path(bpy.path.abspath(tex_path)) / (filename + '.png')) + + # texture_node = ob.material_slots[0].material.node_tree.nodes['Image Texture'] + # texture_node.image = bpy.data.images.load(tex_filename) + + # # ob.display_type = 'SOLID' + # ob.display_type = 'TEXTURED' + + msr_data = context.scene.hpcmonitor4b_client.GetStatusMsr( + context, 'CPU_RAPL_AVG_PKG') + + for msr_record in msr_data.values: + if filter_hostnames is None or msr_record.hostname in filter_hostnames: + hostname = msr_record.hostname + if hostname in bpy.data.objects: + ob = bpy.data.objects[hostname] + fvalue = 0.0 + for cpu in msr_record.cpus: + fvalue = fvalue + float(cpu.value) - system_data = context.scene.hpcmonitor4b_client.GetStatusPower(context, 'average') - for system_record in system_data.values: - if filter_hostnames is None or system_record.hostname in filter_hostnames: - if system_record.hostname in bpy.data.objects: - ob = bpy.data.objects[system_record.hostname] ob.material_slots[0].material.diffuse_color = ( - float(system_record.value) / 700.0, 0, 0, 1) + 0, fvalue / 700.0, 0, 1) + + if not math.isnan(fvalue): + total = total + fvalue + ivalue = int(fvalue) + else: + ivalue = 0 - if not math.isnan(float(system_record.value)): - total = total + float(system_record.value) + if ivalue > 700: + ivalue = 700 + elif ivalue < 0: + ivalue = 0 - ob.display_type = 'SOLID' + filename = 'power_cpu_%d' % (ivalue) + tex_filename = str( + Path(bpy.path.abspath(tex_path)) / (filename + '.png')) + + texture_node = ob.material_slots[0].material.node_tree.nodes['Image Texture'] + texture_node.image = bpy.data.images.load(tex_filename) + + # ob.display_type = 'SOLID' + ob.display_type = 'TEXTURED' nvml_data = context.scene.hpcmonitor4b_client.GetStatusNvml(context, 'AVERAGE_POWER') for nvml_record in nvml_data.values: @@ -195,17 +300,33 @@ class HPCMonitor4BMonitoringShowPower(bpy.types.Operator): hostname = 'gpu.' + nvml_record.hostname if hostname in bpy.data.objects: ob = bpy.data.objects[hostname] - value = 0.0 + fvalue = 0.0 for gpu in nvml_record.gpus: - value = value + float(gpu.value) + fvalue = fvalue + float(gpu.value) ob.material_slots[0].material.diffuse_color = ( - 0, float(value) / 3500.0, 0, 1) + 0, fvalue / 3500.0, 0, 1) + + if not math.isnan(fvalue): + total = total + fvalue + ivalue = int(fvalue) + else: + ivalue = 0 - if not math.isnan(float(value)): - total = total + float(value) + if ivalue > 3500: + ivalue = 3500 + elif ivalue < 0: + ivalue = 0 - ob.display_type = 'SOLID' + filename = 'power_gpu_%d' % (ivalue) + tex_filename = str( + Path(bpy.path.abspath(tex_path)) / (filename + '.png')) + + texture_node = ob.material_slots[0].material.node_tree.nodes['Image Texture'] + texture_node.image = bpy.data.images.load(tex_filename) + + # ob.display_type = 'SOLID' + ob.display_type = 'TEXTURED' # Total bpy.data.objects["TOTAL"].data.body = 'Total Power: %0.1f MW' % (float(total) / 1000000.0) diff --git a/addons/hpcmonitor4b/prepare_scene.py b/addons/hpcmonitor4b/prepare_scene.py index 7b3506a3f2307bc7fd8f669e84a530326b1b03ad..e0f1c931c437ab31280a4e91ce7d25546f8d96ac 100644 --- a/addons/hpcmonitor4b/prepare_scene.py +++ b/addons/hpcmonitor4b/prepare_scene.py @@ -43,6 +43,7 @@ class HPCMonitor4BPrepareSceneCreateMenu(bpy.types.Operator): def execute(self, context): context.scene.hpcmonitor4b_prepare_scene.create_menu(context) context.scene.hpcmonitor4b_prepare_scene.create_panel(context) + context.scene.hpcmonitor4b_prepare_scene.create_values(context) return {'FINISHED'} @@ -180,19 +181,57 @@ class HPCMonitor4BPrepareScene: return plane - def create_menu_item(self, context, name, menu_collection, tex_path, location_z, only_text): - # bpy.ops.mesh.primitive_plane_add() - plane = self.create_plane(context, name, -self.item_w / 2, -self.item_h / - 2 - location_z, self.item_w / 2, self.item_h / 2 - location_z) - # plane.name = name - # plane.location = location - plane.rotation_mode = 'QUATERNION' + def create_values(self, context): + tex_path = context.scene.view_pg_hpcmonitor4b_prepare_scene.output_path + #LOAD_CPU + for i in range(129): + self.create_value_png(tex_path, 'load_cpu_%d' % i, '%d' % i, float(i) / 128.0 , (150, 33, 33, 255)) + + #POWER_CPU + for i in range(701): + self.create_value_png(tex_path, 'power_cpu_%d' % i, '%dW' % + i, float(i) / 700.0, (150, 33, 33, 255)) + #LOAD_GPU + for i in range(801): + self.create_value_png(tex_path, 'load_gpu_%d' % i, '%d' % i, float(i) / 800.0 , (33, 150, 33, 255)) + + #POWER_GPU + for i in range(3501): + self.create_value_png(tex_path, 'power_gpu_%d' % i, '%dW' % + i, float(i) / 3500.0, (33, 150, 33, 255)) + + def create_value_png(self, tex_path, filename, txt, value, color): + from PIL import Image, ImageDraw, ImageFont + tex_filename = str( + Path(bpy.path.abspath(tex_path)) / (filename + '.png')) + + img = Image.new('RGBA', (self.item_image_w, + self.item_image_h), color=self.item_image_color) + + scripts_dir = bpy.utils.user_resource('SCRIPTS') + font_file = os.path.join( + scripts_dir, 'addons/hpcmonitor4b/bmonofont-i18n.ttf') + + font = ImageFont.truetype(str(font_file), self.item_font_size) + w, h = font.getsize(txt) + + d = ImageDraw.Draw(img) + + d.polygon([(0, 0), (self.item_image_w * value, 0), + (self.item_image_w * value, self.item_image_h), (0, self.item_image_h)], fill=color) + + d.text(((self.item_image_w - w) / 2, (self.item_image_h - h) / 2), + txt, font=font, fill=self.item_font_color) + + img.save(tex_filename) + return tex_filename + + def create_menu_item_png(self, tex_path, filename, txt): from PIL import Image, ImageDraw, ImageFont - ############################################## - tex_filename = str(Path(bpy.path.abspath(tex_path)) / (name + '.png')) + tex_filename = str( + Path(bpy.path.abspath(tex_path)) / (filename + '.png')) - # img = Image.new('RGB', (self.item_image_w, self.item_image_h), color = (33, 33, 33)) img = Image.new('RGBA', (self.item_image_w, self.item_image_h), color=self.item_image_color) @@ -200,60 +239,47 @@ class HPCMonitor4BPrepareScene: font_file = os.path.join( scripts_dir, 'addons/hpcmonitor4b/bmonofont-i18n.ttf') - # font_file = Path(sys.path[0]) / '..' / '..' / 'datafiles' / 'fonts' / 'bmonofont-i18n.ttf' font = ImageFont.truetype(str(font_file), self.item_font_size) - w, h = font.getsize(name) + w, h = font.getsize(txt) d = ImageDraw.Draw(img) d.text(((self.item_image_w - w) / 2, (self.item_image_h - h) / 2), - name, font=font, fill=self.item_font_color) - if not only_text: - d.polygon([(self.item_image_w - self.item_font_size / 2, self.item_image_h / 2 + self.item_font_size / 4), (self.item_image_w - self.item_font_size / 2, - self.item_image_h / 2 - self.item_font_size / 4), (self.item_image_w - self.item_font_size / 4, self.item_image_h / 2)], fill=(217, 217, 217, 255)) + txt, font=font, fill=self.item_font_color) + img.save(tex_filename) - # bmat = self.create_bmat(context, name, str(tex_filename)) - # plane.data.materials.append(bmat) - bmat = self.create_menu_bmat(context, name, tex_filename) - plane.data.materials.append(bmat) - plane.data.materials.append(bmat) + return tex_filename + + def create_menu_item(self, context, name, menu_collection, tex_path, location_z, only_text): + plane = self.create_plane(context, name, -self.item_w / 2, -self.item_h / + 2 - location_z, self.item_w / 2, self.item_h / 2 - location_z) + plane.rotation_mode = 'QUATERNION' + ############################################## - if not only_text: - name_selected = name + '_selected' - tex_filename_selected = str( - Path(bpy.path.abspath(tex_path)) / (name_selected + '.png')) - - img_selected = Image.new( - 'RGB', (self.item_image_w, self.item_image_h), color=(81, 119, 179)) - - # font_file_selected = Path(sys.path[0]) / '..' / '..' / 'datafiles' / 'fonts' / 'bmonofont-i18n.ttf' - font_selected = ImageFont.truetype( - str(font_file), self.item_font_size) - w, h = font.getsize(name) - - d_selected = ImageDraw.Draw(img_selected) - d_selected.text(((self.item_image_w - w) / 2, (self.item_image_h - h) / 2), - name, font=font_selected, fill=(217, 217, 217, 255)) - d_selected.polygon([(self.item_image_w - self.item_font_size / 2, self.item_image_h / 2 + self.item_font_size / 4), (self.item_image_w - self.item_font_size / 2, - self.item_image_h / 2 - self.item_font_size / 4), (self.item_image_w - self.item_font_size / 4, self.item_image_h / 2)], fill=(217, 217, 217, 255)) - img_selected.save(tex_filename_selected) - - bmat_selected = self.create_menu_bmat( - context, name_selected, tex_filename_selected) - plane.data.materials.append(bmat_selected) - # else: - # tex_filename_selected = None - - # bmat = self.create_menu_bmat(context, name, tex_filename, tex_filename_selected) - # plane.data.materials.append(bmat) - plane.active_material = plane.data.materials[1] + tex_filename = self.create_menu_item_png(tex_path, name, name) + bmat = self.create_menu_bmat(context, name, tex_filename) + plane.data.materials.append(bmat) + plane.active_material = plane.data.materials[0] ############################################## menu_collection.objects.link(plane) return plane + def create_action(self, context, name): + action_txt = bpy.data.texts.new(name) + + scripts_dir = bpy.utils.user_resource('SCRIPTS') + action_file = os.path.join( + scripts_dir, 'addons/hpcmonitor4b/actions/%s.py' % name) + + with open(action_file, 'r') as file: + data = file.read() + action_txt.write(data) + + return action_txt + def create_menu(self, context): self.map_menu_item = [] @@ -275,9 +301,9 @@ class HPCMonitor4BPrepareScene: menu_collection = bpy.data.collections.new('Label') context.scene.collection.children.link(menu_collection) self.planes = [] - action_node_txt = bpy.data.texts.new('action_node') - action_blade_txt = bpy.data.texts.new('action_blade') - action_label_txt = bpy.data.texts.new('action_label') + action_node_txt = self.create_action(context, 'action_node') + action_blade_txt = self.create_action(context, 'action_blade') + action_label_txt = self.create_action(context, 'action_label') for i in range(len(self.map_menu_item)): ob = self.map_menu_item[i][0] @@ -375,7 +401,7 @@ class HPCMonitor4BPrepareScene: menu_collection = bpy.data.collections.new('Panel') context.scene.collection.children.link(menu_collection) - action_panel_txt = bpy.data.texts.new('action_panel') + action_panel_txt = self.create_action(context, 'action_panel') # HOSTNAME plane = self.create_menu_item(context, "Hostname", menu_collection, diff --git a/proto/gen.cmd b/proto/gen.cmd index 69c2be1503e410f61d0ebd8a23f0dd2ace0c0a69..497024aa37ac59483341717fe4bd5dc48f642a1b 100644 --- a/proto/gen.cmd +++ b/proto/gen.cmd @@ -1,3 +1,4 @@ +@echo off REM ##################################################################################################################### REM # Copyright(C) 2011-2023 IT4Innovations National Supercomputing Center, VSB - Technical University of Ostrava REM # diff --git a/proto/hpcmonitor4b.proto b/proto/hpcmonitor4b.proto index f60b27de9175c9f76b0c92a9337cb68b64bd4eb9..84828b65ddc2088e8d03698951cc023a49d873e6 100644 --- a/proto/hpcmonitor4b.proto +++ b/proto/hpcmonitor4b.proto @@ -24,6 +24,7 @@ package proto_hpcmonitor4b; service HPCMonitor4B { rpc GetStatusSystem (GetStatusSystemRequest) returns (GetStatusSystemResponse) {} rpc GetStatusNvml (GetStatusNvmlRequest) returns (GetStatusNvmlResponse) {} + rpc GetStatusMsr (GetStatusMsrRequest) returns (GetStatusMsrResponse) {} rpc GetStatusPower (GetStatusPowerRequest) returns (GetStatusPowerResponse) {} rpc GetSystemLoadPNG(GetSystemPNGRequest) returns (GetSystemPNGResponse) {} @@ -34,6 +35,7 @@ service HPCMonitor4B { rpc GetJobInfo(GetJobInfoRequest) returns (GetJobInfoResponse) {} } +// ##################################################################################################################### message GetStatusSystemRequest { string type = 1; string username = 2; @@ -49,7 +51,7 @@ message SystemRecord { message GetStatusSystemResponse { repeated SystemRecord values = 1; } - +// ##################################################################################################################### message GetStatusNvmlRequest { string type = 1; string username = 2; @@ -69,7 +71,27 @@ message NvmlRecord { message GetStatusNvmlResponse { repeated NvmlRecord values = 1; } +// ##################################################################################################################### +message GetStatusMsrRequest { + string type = 1; + string username = 2; + string password = 3; +} + +message MsrCPURecord { + string value = 1; +} +message MsrRecord { + repeated MsrCPURecord cpus = 1; + string hostname = 2; + string time = 3; +} + +message GetStatusMsrResponse { + repeated MsrRecord values = 1; +} +// ##################################################################################################################### message GetSystemPNGRequest { string type = 1; string hostname = 2; @@ -80,7 +102,7 @@ message GetSystemPNGRequest { message GetSystemPNGResponse { bytes image = 1; } - +// ##################################################################################################################### message GetJobInfoRequest { string job = 1; string username = 2; @@ -90,7 +112,7 @@ message GetJobInfoRequest { message GetJobInfoResponse { repeated string hostnames = 1; } - +// ##################################################################################################################### message GetStatusPowerRequest { string type = 1; string username = 2; @@ -105,4 +127,4 @@ message PowerRecord { message GetStatusPowerResponse { repeated PowerRecord values = 1; -} \ No newline at end of file +}// ##################################################################################################################### \ No newline at end of file diff --git a/server/hpcmonitor4b/hpcmonitor4b_pb2.py b/server/hpcmonitor4b/hpcmonitor4b_pb2.py index 054a6ce64e37cfdb500055d636377829287d8e6b..6f031ce03ce40b7eef27f5a40ec37426305aa1aa 100644 --- a/server/hpcmonitor4b/hpcmonitor4b_pb2.py +++ b/server/hpcmonitor4b/hpcmonitor4b_pb2.py @@ -13,7 +13,7 @@ _sym_db = _symbol_database.Default() -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12hpcmonitor4b.proto\x12\x12proto_hpcmonitor4b\"J\n\x16GetStatusSystemRequest\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x10\n\x08password\x18\x03 \x01(\t\"=\n\x0cSystemRecord\x12\r\n\x05value\x18\x01 \x01(\t\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12\x0c\n\x04time\x18\x03 \x01(\t\"K\n\x17GetStatusSystemResponse\x12\x30\n\x06values\x18\x01 \x03(\x0b\x32 .proto_hpcmonitor4b.SystemRecord\"H\n\x14GetStatusNvmlRequest\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x10\n\x08password\x18\x03 \x01(\t\"\x1e\n\rNvmlGPURecord\x12\r\n\x05value\x18\x01 \x01(\t\"]\n\nNvmlRecord\x12/\n\x04gpus\x18\x01 \x03(\x0b\x32!.proto_hpcmonitor4b.NvmlGPURecord\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12\x0c\n\x04time\x18\x03 \x01(\t\"G\n\x15GetStatusNvmlResponse\x12.\n\x06values\x18\x01 \x03(\x0b\x32\x1e.proto_hpcmonitor4b.NvmlRecord\"Y\n\x13GetSystemPNGRequest\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12\x10\n\x08username\x18\x03 \x01(\t\x12\x10\n\x08password\x18\x04 \x01(\t\"%\n\x14GetSystemPNGResponse\x12\r\n\x05image\x18\x01 \x01(\x0c\"D\n\x11GetJobInfoRequest\x12\x0b\n\x03job\x18\x01 \x01(\t\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x10\n\x08password\x18\x03 \x01(\t\"\'\n\x12GetJobInfoResponse\x12\x11\n\thostnames\x18\x01 \x03(\t\"I\n\x15GetStatusPowerRequest\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x10\n\x08password\x18\x03 \x01(\t\"<\n\x0bPowerRecord\x12\r\n\x05value\x18\x01 \x01(\t\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12\x0c\n\x04time\x18\x03 \x01(\t\"I\n\x16GetStatusPowerResponse\x12/\n\x06values\x18\x01 \x03(\x0b\x32\x1f.proto_hpcmonitor4b.PowerRecord2\xda\x06\n\x0cHPCMonitor4B\x12l\n\x0fGetStatusSystem\x12*.proto_hpcmonitor4b.GetStatusSystemRequest\x1a+.proto_hpcmonitor4b.GetStatusSystemResponse\"\x00\x12\x66\n\rGetStatusNvml\x12(.proto_hpcmonitor4b.GetStatusNvmlRequest\x1a).proto_hpcmonitor4b.GetStatusNvmlResponse\"\x00\x12i\n\x0eGetStatusPower\x12).proto_hpcmonitor4b.GetStatusPowerRequest\x1a*.proto_hpcmonitor4b.GetStatusPowerResponse\"\x00\x12g\n\x10GetSystemLoadPNG\x12\'.proto_hpcmonitor4b.GetSystemPNGRequest\x1a(.proto_hpcmonitor4b.GetSystemPNGResponse\"\x00\x12h\n\x11GetSystemPowerPNG\x12\'.proto_hpcmonitor4b.GetSystemPNGRequest\x1a(.proto_hpcmonitor4b.GetSystemPNGResponse\"\x00\x12j\n\x13GetSystemLoadGPUPNG\x12\'.proto_hpcmonitor4b.GetSystemPNGRequest\x1a(.proto_hpcmonitor4b.GetSystemPNGResponse\"\x00\x12k\n\x14GetSystemPowerGPUPNG\x12\'.proto_hpcmonitor4b.GetSystemPNGRequest\x1a(.proto_hpcmonitor4b.GetSystemPNGResponse\"\x00\x12]\n\nGetJobInfo\x12%.proto_hpcmonitor4b.GetJobInfoRequest\x1a&.proto_hpcmonitor4b.GetJobInfoResponse\"\x00\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12hpcmonitor4b.proto\x12\x12proto_hpcmonitor4b\"J\n\x16GetStatusSystemRequest\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x10\n\x08password\x18\x03 \x01(\t\"=\n\x0cSystemRecord\x12\r\n\x05value\x18\x01 \x01(\t\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12\x0c\n\x04time\x18\x03 \x01(\t\"K\n\x17GetStatusSystemResponse\x12\x30\n\x06values\x18\x01 \x03(\x0b\x32 .proto_hpcmonitor4b.SystemRecord\"H\n\x14GetStatusNvmlRequest\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x10\n\x08password\x18\x03 \x01(\t\"\x1e\n\rNvmlGPURecord\x12\r\n\x05value\x18\x01 \x01(\t\"]\n\nNvmlRecord\x12/\n\x04gpus\x18\x01 \x03(\x0b\x32!.proto_hpcmonitor4b.NvmlGPURecord\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12\x0c\n\x04time\x18\x03 \x01(\t\"G\n\x15GetStatusNvmlResponse\x12.\n\x06values\x18\x01 \x03(\x0b\x32\x1e.proto_hpcmonitor4b.NvmlRecord\"G\n\x13GetStatusMsrRequest\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x10\n\x08password\x18\x03 \x01(\t\"\x1d\n\x0cMsrCPURecord\x12\r\n\x05value\x18\x01 \x01(\t\"[\n\tMsrRecord\x12.\n\x04\x63pus\x18\x01 \x03(\x0b\x32 .proto_hpcmonitor4b.MsrCPURecord\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12\x0c\n\x04time\x18\x03 \x01(\t\"E\n\x14GetStatusMsrResponse\x12-\n\x06values\x18\x01 \x03(\x0b\x32\x1d.proto_hpcmonitor4b.MsrRecord\"Y\n\x13GetSystemPNGRequest\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12\x10\n\x08username\x18\x03 \x01(\t\x12\x10\n\x08password\x18\x04 \x01(\t\"%\n\x14GetSystemPNGResponse\x12\r\n\x05image\x18\x01 \x01(\x0c\"D\n\x11GetJobInfoRequest\x12\x0b\n\x03job\x18\x01 \x01(\t\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x10\n\x08password\x18\x03 \x01(\t\"\'\n\x12GetJobInfoResponse\x12\x11\n\thostnames\x18\x01 \x03(\t\"I\n\x15GetStatusPowerRequest\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x10\n\x08password\x18\x03 \x01(\t\"<\n\x0bPowerRecord\x12\r\n\x05value\x18\x01 \x01(\t\x12\x10\n\x08hostname\x18\x02 \x01(\t\x12\x0c\n\x04time\x18\x03 \x01(\t\"I\n\x16GetStatusPowerResponse\x12/\n\x06values\x18\x01 \x03(\x0b\x32\x1f.proto_hpcmonitor4b.PowerRecord2\xbf\x07\n\x0cHPCMonitor4B\x12l\n\x0fGetStatusSystem\x12*.proto_hpcmonitor4b.GetStatusSystemRequest\x1a+.proto_hpcmonitor4b.GetStatusSystemResponse\"\x00\x12\x66\n\rGetStatusNvml\x12(.proto_hpcmonitor4b.GetStatusNvmlRequest\x1a).proto_hpcmonitor4b.GetStatusNvmlResponse\"\x00\x12\x63\n\x0cGetStatusMsr\x12\'.proto_hpcmonitor4b.GetStatusMsrRequest\x1a(.proto_hpcmonitor4b.GetStatusMsrResponse\"\x00\x12i\n\x0eGetStatusPower\x12).proto_hpcmonitor4b.GetStatusPowerRequest\x1a*.proto_hpcmonitor4b.GetStatusPowerResponse\"\x00\x12g\n\x10GetSystemLoadPNG\x12\'.proto_hpcmonitor4b.GetSystemPNGRequest\x1a(.proto_hpcmonitor4b.GetSystemPNGResponse\"\x00\x12h\n\x11GetSystemPowerPNG\x12\'.proto_hpcmonitor4b.GetSystemPNGRequest\x1a(.proto_hpcmonitor4b.GetSystemPNGResponse\"\x00\x12j\n\x13GetSystemLoadGPUPNG\x12\'.proto_hpcmonitor4b.GetSystemPNGRequest\x1a(.proto_hpcmonitor4b.GetSystemPNGResponse\"\x00\x12k\n\x14GetSystemPowerGPUPNG\x12\'.proto_hpcmonitor4b.GetSystemPNGRequest\x1a(.proto_hpcmonitor4b.GetSystemPNGResponse\"\x00\x12]\n\nGetJobInfo\x12%.proto_hpcmonitor4b.GetJobInfoRequest\x1a&.proto_hpcmonitor4b.GetJobInfoResponse\"\x00\x62\x06proto3') _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'hpcmonitor4b_pb2', globals()) @@ -34,20 +34,28 @@ if _descriptor._USE_C_DESCRIPTORS == False: _NVMLRECORD._serialized_end=457 _GETSTATUSNVMLRESPONSE._serialized_start=459 _GETSTATUSNVMLRESPONSE._serialized_end=530 - _GETSYSTEMPNGREQUEST._serialized_start=532 - _GETSYSTEMPNGREQUEST._serialized_end=621 - _GETSYSTEMPNGRESPONSE._serialized_start=623 - _GETSYSTEMPNGRESPONSE._serialized_end=660 - _GETJOBINFOREQUEST._serialized_start=662 - _GETJOBINFOREQUEST._serialized_end=730 - _GETJOBINFORESPONSE._serialized_start=732 - _GETJOBINFORESPONSE._serialized_end=771 - _GETSTATUSPOWERREQUEST._serialized_start=773 - _GETSTATUSPOWERREQUEST._serialized_end=846 - _POWERRECORD._serialized_start=848 - _POWERRECORD._serialized_end=908 - _GETSTATUSPOWERRESPONSE._serialized_start=910 - _GETSTATUSPOWERRESPONSE._serialized_end=983 - _HPCMONITOR4B._serialized_start=986 - _HPCMONITOR4B._serialized_end=1844 + _GETSTATUSMSRREQUEST._serialized_start=532 + _GETSTATUSMSRREQUEST._serialized_end=603 + _MSRCPURECORD._serialized_start=605 + _MSRCPURECORD._serialized_end=634 + _MSRRECORD._serialized_start=636 + _MSRRECORD._serialized_end=727 + _GETSTATUSMSRRESPONSE._serialized_start=729 + _GETSTATUSMSRRESPONSE._serialized_end=798 + _GETSYSTEMPNGREQUEST._serialized_start=800 + _GETSYSTEMPNGREQUEST._serialized_end=889 + _GETSYSTEMPNGRESPONSE._serialized_start=891 + _GETSYSTEMPNGRESPONSE._serialized_end=928 + _GETJOBINFOREQUEST._serialized_start=930 + _GETJOBINFOREQUEST._serialized_end=998 + _GETJOBINFORESPONSE._serialized_start=1000 + _GETJOBINFORESPONSE._serialized_end=1039 + _GETSTATUSPOWERREQUEST._serialized_start=1041 + _GETSTATUSPOWERREQUEST._serialized_end=1114 + _POWERRECORD._serialized_start=1116 + _POWERRECORD._serialized_end=1176 + _GETSTATUSPOWERRESPONSE._serialized_start=1178 + _GETSTATUSPOWERRESPONSE._serialized_end=1251 + _HPCMONITOR4B._serialized_start=1254 + _HPCMONITOR4B._serialized_end=2213 # @@protoc_insertion_point(module_scope) diff --git a/server/hpcmonitor4b/hpcmonitor4b_pb2_grpc.py b/server/hpcmonitor4b/hpcmonitor4b_pb2_grpc.py index 551960219aa606cc998726042c770636d7104065..3307a510b9c752184d13fcce19674f26b4d053a2 100644 --- a/server/hpcmonitor4b/hpcmonitor4b_pb2_grpc.py +++ b/server/hpcmonitor4b/hpcmonitor4b_pb2_grpc.py @@ -24,6 +24,11 @@ class HPCMonitor4BStub(object): request_serializer=hpcmonitor4b__pb2.GetStatusNvmlRequest.SerializeToString, response_deserializer=hpcmonitor4b__pb2.GetStatusNvmlResponse.FromString, ) + self.GetStatusMsr = channel.unary_unary( + '/proto_hpcmonitor4b.HPCMonitor4B/GetStatusMsr', + request_serializer=hpcmonitor4b__pb2.GetStatusMsrRequest.SerializeToString, + response_deserializer=hpcmonitor4b__pb2.GetStatusMsrResponse.FromString, + ) self.GetStatusPower = channel.unary_unary( '/proto_hpcmonitor4b.HPCMonitor4B/GetStatusPower', request_serializer=hpcmonitor4b__pb2.GetStatusPowerRequest.SerializeToString, @@ -71,6 +76,12 @@ class HPCMonitor4BServicer(object): context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') + def GetStatusMsr(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + def GetStatusPower(self, request, context): """Missing associated documentation comment in .proto file.""" context.set_code(grpc.StatusCode.UNIMPLEMENTED) @@ -120,6 +131,11 @@ def add_HPCMonitor4BServicer_to_server(servicer, server): request_deserializer=hpcmonitor4b__pb2.GetStatusNvmlRequest.FromString, response_serializer=hpcmonitor4b__pb2.GetStatusNvmlResponse.SerializeToString, ), + 'GetStatusMsr': grpc.unary_unary_rpc_method_handler( + servicer.GetStatusMsr, + request_deserializer=hpcmonitor4b__pb2.GetStatusMsrRequest.FromString, + response_serializer=hpcmonitor4b__pb2.GetStatusMsrResponse.SerializeToString, + ), 'GetStatusPower': grpc.unary_unary_rpc_method_handler( servicer.GetStatusPower, request_deserializer=hpcmonitor4b__pb2.GetStatusPowerRequest.FromString, @@ -194,6 +210,23 @@ class HPCMonitor4B(object): options, channel_credentials, insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + @staticmethod + def GetStatusMsr(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/proto_hpcmonitor4b.HPCMonitor4B/GetStatusMsr', + hpcmonitor4b__pb2.GetStatusMsrRequest.SerializeToString, + hpcmonitor4b__pb2.GetStatusMsrResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + @staticmethod def GetStatusPower(request, target, diff --git a/server/hpcmonitor4b/hpcmonitor4b_server.py b/server/hpcmonitor4b/hpcmonitor4b_server.py index a5812872c5f7691e68e1a9e20e1677eeda1f1140..e1dafe8abfb290babaecbf79d0f02b9dc4ccae9e 100644 --- a/server/hpcmonitor4b/hpcmonitor4b_server.py +++ b/server/hpcmonitor4b/hpcmonitor4b_server.py @@ -63,6 +63,13 @@ class HPCMonitor4BInfluxDB: df = pd.DataFrame(cq.get_points()) return df + def GetStatusMsr(self, type): + cq = self.client.query( + "SELECT %s_0,%s_1,host,time FROM msr_data WHERE time > now() - 2m GROUP BY host ORDER BY time DESC LIMIT 1" % (type, type)) + + df = pd.DataFrame(cq.get_points()) + return df + hpcMonitor4BInfluxDB = HPCMonitor4BInfluxDB() @@ -224,6 +231,23 @@ class HPCMonitor4B(hpcmonitor4b_pb2_grpc.HPCMonitor4BServicer): return response + def GetStatusMsr(self, request, context): + hpcMonitor4Bauth.CheckCrendetials(request) + + df = hpcMonitor4BInfluxDB.GetStatusMsr(request.type) + + response = hpcmonitor4b_pb2.GetStatusMsrResponse() + for i in range(len(df)): + msr_record = response.values.add() + msr_record.hostname = str(df['host'][i]) + msr_record.time = str(df['time'][i]) + for c in range(2): + msr_cpu_record = msr_record.cpus.add() + msr_cpu_record.value = str( + df['%s_%d' % (request.type,c)][i]) + + return response + def GetStatusPower(self, request, context): hpcMonitor4Bauth.CheckCrendetials(request)