Skip to content

Commit

Permalink
feat(exporter): add process info
Browse files Browse the repository at this point in the history
  • Loading branch information
XuehaiPan committed Dec 28, 2024
1 parent 25b6d61 commit f8a59ec
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions nvitop-exporter/nvitop_exporter/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).',
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit f8a59ec

Please sign in to comment.