Skip to content
Snippets Groups Projects
Commit 1a442c78 authored by Gin Tan's avatar Gin Tan
Browse files

Merge branch 'collectd' into 'master'

Collectd

See merge request hpc-team/ansible_cluster_in_a_box!213
parents baed119d cc87b3ae
No related branches found
No related tags found
1 merge request!213Collectd
#!/usr/bin/env python #!/usr/bin/env python
import collectd try:
import collectd
from collectd import Values
except:
from fakeCollectd import Values
import subprocess import subprocess
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
def read(data=None): def read(data=None):
vl = collectd.Values(type='gauge') vl = Values(type='gauge')
vl.plugin = 'cuda' vl.plugin = 'cuda'
out = subprocess.check_output(['nvidia-smi', '-q', '-x']) out = subprocess.check_output(['nvidia-smi', '-q', '-x'])
...@@ -30,6 +35,18 @@ def read(data=None): ...@@ -30,6 +35,18 @@ def read(data=None):
values=[1e6 * float(gpu.find('utilization/gpu_util').text.split()[0])]) values=[1e6 * float(gpu.find('utilization/gpu_util').text.split()[0])])
except: except:
pass pass
try:
collectd.register_read(read) vl.dispatch(type='gauge', type_instance='power_state',
values=[int(gpu.find('power_readings/power_state').text.split()[0][1:])])
except:
pass
try:
vl.dispatch(type='gauge', type_instance='power_draw',
values=[float(gpu.find('power_readings/power_draw').text.split()[0])])
except:
pass
try:
collectd.register_read(read)
except:
readtest()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment