@cryptotaxi247 / netdata-1 / commits / 7c33c4c70

nvidia_smi: Not count users with zero memory allocated (#10098)

Co-authored-by: ilyam8 <ilya@netdata.cloud>

Guido committed Oct 20, 2020 at 10:59 UTC 7c33c4c70f4588313ed697885065092ad9a2b29a
3 files changed +10 -4
collectors/python.d.plugin/nvidia_smi/README.md
+1
@@ -52,6 +52,7 @@ Sample:
52 ```yaml
53 loop_mode : yes
54 poll_seconds : 1
55 +exclude_zero_memory_users : yes
56 ```
57
58 [![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fcollectors%2Fpython.d.plugin%2Fnvidia_smi%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)](<>)
collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py
+6 -2
@@ -288,9 +288,10 @@ def get_username_by_pid_safe(pid, passwd_file):
288
289
290 class GPU:
291 - def __init__(self, num, root):
291 + def __init__(self, num, root, exclude_zero_memory_users=False):
292 self.num = num
293 self.root = root
294 + self.exclude_zero_memory_users = exclude_zero_memory_users
295
296 def id(self):
297 return self.root.get('id')
@@ -404,6 +405,8 @@ class GPU:
405 for p in processes:
406 data['process_mem_{0}'.format(p['pid'])] = p['used_memory']
407 if p['username']:
408 + if self.exclude_zero_memory_users and p['used_memory'] == 0:
409 + continue
410 users.add(p['username'])
411 key = 'user_mem_{0}'.format(p['username'])
412 if key in data:
@@ -424,6 +427,7 @@ class Service(SimpleService):
427 self.definitions = dict()
428 self.loop_mode = configuration.get('loop_mode', True)
429 poll = int(configuration.get('poll_seconds', 1))
430 + self.exclude_zero_memory_users = configuration.get('exclude_zero_memory_users', False)
431 self.poller = NvidiaSMIPoller(poll)
432
433 def get_data_loop_mode(self):
@@ -454,7 +458,7 @@ class Service(SimpleService):
458
459 data = dict()
460 for idx, root in enumerate(parsed.findall('gpu')):
457 - gpu = GPU(idx, root)
461 + gpu = GPU(idx, root, self.exclude_zero_memory_users)
462 data.update(gpu.data())
463 self.update_processes_mem_chart(gpu)
464 self.update_processes_user_mem_chart(gpu)
collectors/python.d.plugin/nvidia_smi/nvidia_smi.conf
+3 -2
@@ -61,7 +61,8 @@
61 #
62 # Additionally to the above, example also supports the following:
63 #
64 -# loop_mode: yes/no # default is yes. If set to yes `nvidia-smi` is executed in a separate thread using `-l` option.
65 -# poll_seconds: SECONDS # default is 1. Sets the frequency of seconds the nvidia-smi tool is polled in loop mode.
64 +# loop_mode: yes/no # default is yes. If set to yes `nvidia-smi` is executed in a separate thread using `-l` option.
65 +# poll_seconds: SECONDS # default is 1. Sets the frequency of seconds the nvidia-smi tool is polled in loop mode.
66 +# exclude_zero_memory_users: yes/no # default is no. Whether to collect users metrics with 0Mb memory allocation.
67 #
68 # ----------------------------------------------------------------------