@cryptotaxi247 / netdata-1 / commits / 6003e06f2

nvidia_smi_chart.py : fixed username for not-local users (#11858)

Guido committed Dec 24, 2021 at 00:01 UTC 6003e06f213cae2ad7298c4b01f48c8e5b1bd50c
1 file changed +8 -6
collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py
+8 -6
@@ -285,12 +285,14 @@ def get_username_by_pid_safe(pid, passwd_file):
285 try:
286 uid = os.stat(path).st_uid
287 except (OSError, IOError):
288 - return ''
289 -
290 - try:
291 - return passwd_file[uid][0]
292 - except KeyError:
293 - return str(uid)
288 + return ''
289 + if IS_INSIDE_DOCKER:
290 + try:
291 + return passwd_file[uid][0]
292 + except KeyError:
293 + return str(uid)
294 + else:
295 + return pwd.getpwuid(uid)[0]
296
297
298 class GPU: