Created
October 2, 2014 15:51
-
-
Save ssplatt/9c8be852282fe2aa02c5 to your computer and use it in GitHub Desktop.
post number of used slots from GridEngine to Dashing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
# stats to dashing | |
import subprocess | |
import re | |
import httplib | |
import json | |
# config variables | |
# dashing host | |
host = "127.0.0.1" | |
port = 3030 | |
widget_id="/widgets/slotsused" | |
# get number of slots in use | |
raw = subprocess.check_output(["qstat","-f"]) | |
match = re.findall('\d+\/(\d+)\/(\d+)', raw) | |
used=0 | |
total=0 | |
for m,t in match: | |
used += int(m) | |
total += int(t) | |
# post to dashing | |
# data-view="Meter" in dashboard file | |
params = json.dumps({ 'auth_token': "TOKEN", 'value': used}) | |
conn = httplib.HTTPConnection(host, port) | |
conn.request("POST", widget_id, params) | |
response = conn.getresponse() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment