summaryrefslogtreecommitdiffstats
path: root/collectors
diff options
context:
space:
mode:
authorGuido <guido.scatena@unipi.it>2020-10-20 10:59:59 +0200
committerGitHub <noreply@github.com>2020-10-20 11:59:59 +0300
commit7c33c4c70f4588313ed697885065092ad9a2b29a (patch)
tree5ba39048122c0ab00891b17565b61f4feaf91a1e /collectors
parent5921a9fe4ff38b1f2ad44e8c908b464c3d7a8421 (diff)
nvidia_smi: Not count users with zero memory allocated (#10098)
Co-authored-by: ilyam8 <ilya@netdata.cloud>
Diffstat (limited to 'collectors')
-rw-r--r--collectors/python.d.plugin/nvidia_smi/README.md1
-rw-r--r--collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py8
-rw-r--r--collectors/python.d.plugin/nvidia_smi/nvidia_smi.conf5
3 files changed, 10 insertions, 4 deletions
diff --git a/collectors/python.d.plugin/nvidia_smi/README.md b/collectors/python.d.plugin/nvidia_smi/README.md
index 9d11e4a363..ca646dac80 100644
--- a/collectors/python.d.plugin/nvidia_smi/README.md
+++ b/collectors/python.d.plugin/nvidia_smi/README.md
@@ -52,6 +52,7 @@ Sample:
```yaml
loop_mode : yes
poll_seconds : 1
+exclude_zero_memory_users : yes
```
[![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)](<>)
diff --git a/collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py b/collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py
index a3be7b3ce1..68eb49966f 100644
--- a/collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py
+++ b/collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py
@@ -288,9 +288,10 @@ def get_username_by_pid_safe(pid, passwd_file):
class GPU:
- def __init__(self, num, root):
+ def __init__(self, num, root, exclude_zero_memory_users=False):
self.num = num
self.root = root
+ self.exclude_zero_memory_users = exclude_zero_memory_users
def id(self):
return self.root.get('id')
@@ -404,6 +405,8 @@ class GPU:
for p in processes:
data['process_mem_{0}'.format(p['pid'])] = p['used_memory']
if p['username']:
+ if self.exclude_zero_memory_users and p['used_memory'] == 0:
+ continue
users.add(p['username'])
key = 'user_mem_{0}'.format(p['username'])
if key in data:
@@ -424,6 +427,7 @@ class Service(SimpleService):
self.definitions = dict()
self.loop_mode = configuration.get('loop_mode', True)
poll = int(configuration.get('poll_seconds', 1))
+ self.exclude_zero_memory_users = configuration.get('exclude_zero_memory_users', False)
self.poller = NvidiaSMIPoller(poll)
def get_data_loop_mode(self):
@@ -454,7 +458,7 @@ class Service(SimpleService):
data = dict()
for idx, root in enumerate(parsed.findall('gpu')):
- gpu = GPU(idx, root)
+ gpu = GPU(idx, root, self.exclude_zero_memory_users)
data.update(gpu.data())
self.update_processes_mem_chart(gpu)
self.update_processes_user_mem_chart(gpu)
diff --git a/collectors/python.d.plugin/nvidia_smi/nvidia_smi.conf b/collectors/python.d.plugin/nvidia_smi/nvidia_smi.conf
index 4c8bdce766..3d2a30d412 100644
--- a/collectors/python.d.plugin/nvidia_smi/nvidia_smi.conf
+++ b/collectors/python.d.plugin/nvidia_smi/nvidia_smi.conf
@@ -61,7 +61,8 @@
#
# Additionally to the above, example also supports the following:
#
-# loop_mode: yes/no # default is yes. If set to yes `nvidia-smi` is executed in a separate thread using `-l` option.
-# poll_seconds: SECONDS # default is 1. Sets the frequency of seconds the nvidia-smi tool is polled in loop mode.
+# loop_mode: yes/no # default is yes. If set to yes `nvidia-smi` is executed in a separate thread using `-l` option.
+# poll_seconds: SECONDS # default is 1. Sets the frequency of seconds the nvidia-smi tool is polled in loop mode.
+# exclude_zero_memory_users: yes/no # default is no. Whether to collect users metrics with 0Mb memory allocation.
#
# ----------------------------------------------------------------------