From b12a9c9863ac8745418c3689904dbc7cff83a03f Mon Sep 17 00:00:00 2001 From: Nikolai Petukhov Date: Thu, 5 Dec 2024 23:21:58 -0300 Subject: [PATCH 1/2] add disk usage to hw_info, telemetry and load_info --- agent/worker/system_info.py | 15 +++++++++++++++ agent/worker/telemetry_reporter.py | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/agent/worker/system_info.py b/agent/worker/system_info.py index ab5053e..fd0936e 100644 --- a/agent/worker/system_info.py +++ b/agent/worker/system_info.py @@ -17,6 +17,9 @@ import supervisely_lib as sly +from worker import constants + + # Some functions below perform dirty parsing of corresponding utils output. # @TODO: They shall be replaced with more portable implementations. @@ -97,6 +100,16 @@ def cpu_freq_MHZ(): return res +def get_disk_usage(): + disk_usage = psutil.disk_usage(constants.AGENT_ROOT_DIR()) # root dir mounted to host + res = { + "total": disk_usage.total, + "used": disk_usage.used, + "free": disk_usage.free, + } + return res + + def get_hw_info(): res = { "psutil": { @@ -117,6 +130,7 @@ def get_hw_info(): "cpuinfo": sly.catch_silently(parse_cpuinfo), "meminfo": sly.catch_silently(parse_meminfo), "nvidia-smi": sly.catch_silently(print_nvsmi_devlist), + "disk_usage": get_disk_usage(), } return res @@ -132,6 +146,7 @@ def get_load_info(): "total": vmem[0], "available": vmem[1], }, + "disk_usage": get_disk_usage(), } return res diff --git a/agent/worker/telemetry_reporter.py b/agent/worker/telemetry_reporter.py index fc83217..b1e3d47 100644 --- a/agent/worker/telemetry_reporter.py +++ b/agent/worker/telemetry_reporter.py @@ -8,7 +8,7 @@ from worker.task_logged import TaskLogged from worker import constants -from worker.system_info import get_directory_size_bytes, get_gpu_info +from worker.system_info import get_directory_size_bytes, get_gpu_info, get_disk_usage class TelemetryReporter(TaskLogged): @@ -114,6 +114,7 @@ def get_telemetry_str(self): "node_storage": node_storage, "docker_image": docker_image, "gpu_info": get_gpu_info(self.logger), + "disk_usage": get_disk_usage(), } info_str = json.dumps(server_info) From 30df2a395076ac56b3e5eff30e80b5979181a49c Mon Sep 17 00:00:00 2001 From: Nikolai Petukhov Date: Fri, 6 Dec 2024 12:48:06 -0300 Subject: [PATCH 2/2] add more info to disk usage info --- agent/worker/system_info.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/agent/worker/system_info.py b/agent/worker/system_info.py index fd0936e..efdc8a4 100644 --- a/agent/worker/system_info.py +++ b/agent/worker/system_info.py @@ -101,11 +101,25 @@ def cpu_freq_MHZ(): def get_disk_usage(): - disk_usage = psutil.disk_usage(constants.AGENT_ROOT_DIR()) # root dir mounted to host + root = psutil.disk_usage("/") + agent_data = psutil.disk_usage(constants.AGENT_ROOT_DIR()) # root dir mounted to host + apps_data = psutil.disk_usage(constants.SUPERVISELY_AGENT_FILES_CONTAINER()) res = { - "total": disk_usage.total, - "used": disk_usage.used, - "free": disk_usage.free, + "root": { + "total": root.total, + "used": root.used, + "free": root.free, + }, + "agent_data": { + "total": agent_data.total, + "used": agent_data.used, + "free": agent_data.free, + }, + "apps_data": { + "total": apps_data.total, + "used": apps_data.used, + "free": apps_data.free, + }, } return res