From f8a59ec018c8cf865bd16fbe24dc0ab96c15dd6d Mon Sep 17 00:00:00 2001 From: Xuehai Pan Date: Sun, 29 Dec 2024 03:26:21 +0800 Subject: [PATCH] feat(exporter): add process info --- nvitop-exporter/nvitop_exporter/exporter.py | 24 +++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/nvitop-exporter/nvitop_exporter/exporter.py b/nvitop-exporter/nvitop_exporter/exporter.py index b0861bf0..eb65bb6c 100644 --- a/nvitop-exporter/nvitop_exporter/exporter.py +++ b/nvitop-exporter/nvitop_exporter/exporter.py @@ -405,6 +405,12 @@ def __init__( # pylint: disable=too-many-statements ) # Create gauges for process metrics + self.process_info = Info( + name='process_info', + documentation='Process information.', + labelnames=['hostname', 'index', 'devicename', 'uuid', 'pid', 'username'], + registry=self.registry, + ) self.process_running_time = Gauge( name='process_running_time', documentation='Process running time (s).', @@ -597,6 +603,19 @@ def update_device(self, device: Device) -> None: # pylint: disable=too-many-loc username = process.username() running_time = process.running_time() alive_pids.add((pid, username)) + self.process_info.labels( + hostname=self.hostname, + index=index, + devicename=name, + uuid=uuid, + pid=pid, + username=username, + ).info( + { + 'status': process.status(), + 'command': process.command(), + }, + ) for gauge, value in ( ( self.process_running_time, @@ -633,7 +652,8 @@ def update_device(self, device: Device) -> None: # pylint: disable=too-many-loc ).set(value) for pid, username in previous_alive_pids.difference(alive_pids): - for gauge in ( + for collector in ( + self.process_info, self.process_running_time, self.process_cpu_percent, self.process_rss_memory, @@ -645,7 +665,7 @@ def update_device(self, device: Device) -> None: # pylint: disable=too-many-loc self.process_gpu_decoder_utilization, ): try: - gauge.remove( + collector.remove( self.hostname, index, name,