Created
February 21, 2013 10:46
-
-
Save pescobar/5003865 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
import commands | |
from string import strip | |
#def get_hosts_for_user(user): | |
#hosts = map(strip, commands.getoutput('qstat -s r -u ' + user + ' | grep -v job-ID |grep -v\ | |
#\'\-\-\'|awk {\'print $8\'}|awk -F \"@\" {\'print $2\'} |awk -F \'.\'\ | |
#{\'print $1\'}').split("\n")) | |
#return list(set(hosts)) | |
def get_mem_for_user(user): | |
res_mem = 0 | |
used_vmem = 0 | |
max_vmem = 0 | |
running_jobs_ids = map(strip, commands.getoutput('qstat -s r -u ' + user +\ | |
'| awk {\'print $1\'} |grep -v job |grep -v -').split("\n")) | |
for jobid in running_jobs_ids: | |
mem_reserved = map(strip, commands.getoutput('qstat -j ' + jobid +' |grep \ | |
h_vmem|awk {\'print $3\'} | awk -F \"=\" {\'print $2\'}').split("\n")) | |
vmem = map(strip, commands.getoutput('qstat -j '+ jobid +' |grep \ | |
usage|awk -F \",\" {\'print $4\'} |awk -F \"=\" \ | |
{\'print $2\'}').split("\n")) | |
maxvmem = map(strip, commands.getoutput('qstat -j '+ jobid +' |grep \ | |
usage|awk -F \",\" {\'print $5\'} |awk -F \"=\" \ | |
{\'print $2\'}').split("\n")) | |
#res_mem = res_mem + mem_reserved | |
#used_vmem = used_vmem + vmem | |
#max_vmem = max_vmem + maxvmem | |
#print user + ' has reserved ' max_vmem | |
print mem_reserved | |
print vmem | |
print maxvmem | |
get_mem_for_user('ralonso') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment