Commit 62a013a2 authored by Andrew McNab's avatar Andrew McNab
Browse files

Use command line arguments

parent 479af87c
......@@ -32,8 +32,8 @@
# POSSIBILITY OF SUCH DAMAGE.
# Remove $JOBFEATURES directory for this job where the directory
# is at $HOME/jobfeatures-$PBS_JOBID
# is at $HOME/jobfeatures-$PBS_JOBID ($1 is $PBS_JOBID)
if [ "$PBS_JOBID" != "" -a -d "$HOME/jobfeatures-$PBS_JOBID" ] ; then
rm -Rf "$HOME/jobfeatures-$PBS_JOBID"
if [ "$1" != "" -a -d "$HOME/jobfeatures-$1" ] ; then
rm -Rf "$HOME/jobfeatures-$1"
fi
......@@ -58,7 +58,7 @@ import time
homeDir = os.path.expanduser('~')
job_id = os.environ['PBS_JOBID']
job_id = sys.argv[1]
jobfeaturesDir = homeDir + '/jobfeatures-' + job_id
os.mkdir(jobfeaturesDir)
......@@ -93,50 +93,45 @@ else:
jobstart_secs = int(time.time())
open(jobfeaturesDir + '/jobstart_secs', 'w').write(str(jobstart_secs))
try:
qstatResult = os.popen('qstat -f ' + job_id,'r').read()
# Examine the 5th argument, for resource limits
try:
wallMatchObject = re.search('walltime=([0-9]*):([0-9]*):([0-9]*)', sys.argv[5])
jobfeatures['wall_limit_secs'] = int(wallMatchObject.group(1)) * 3600 + int(wallMatchObject.group(2)) * 60 + int(wallMatchObject.group(3))
except:
# Ok if not possible (qstat not installed? Not allowed to use it?)
pass
else:
try:
wallMatchObject = re.search(' *Resource_List.walltime = ([0-9]*):([0-9]*):([0-9]*)', qstatResult)
jobfeatures['wall_limit_secs'] = int(wallMatchObject.group(1)) * 3600 + int(wallMatchObject.group(2)) * 60 + int(wallMatchObject.group(3))
except:
pass
try:
cpuMatchObject = re.search(' *Resource_List.cput = ([0-9]*):([0-9]*):([0-9]*)', qstatResult)
jobfeatures['cpu_limit_secs'] = int(cpuMatchObject.group(1)) * 3600 + int(cpuMatchObject.group(2)) * 60 + int(cpuMatchObject.group(3))
except:
pass
try:
rssMatchObject = re.search(' *Resource_List.mem = ([0-9]*)([a-z]*)', qstatResult)
rssInt = int(rssMatchObject.group(1))
rssUnit = rssMatchObject.group(2)
except:
pass
else:
if rssUnit == 'gb':
jobfeatures['max_rss_bytes'] = rssInt * 1000000000
elif rssUnit == 'mb':
jobfeatures['max_rss_bytes'] = rssInt * 1000000
elif rssUnit == 'kb':
jobfeatures['max_rss_bytes'] = rssInt * 1000
elif rssUnit == 'b':
# Is this the right name??
jobfeatures['max_rss_bytes'] = rssInt
# Values in /var/run/mjf take precedence
try:
fromRun = open('/var/run/mjf','r').read()
cpuMatchObject = re.search('cput=([0-9]*):([0-9]*):([0-9]*)', sys.argv[5])
jobfeatures['cpu_limit_secs'] = int(cpuMatchObject.group(1)) * 3600 + int(cpuMatchObject.group(2)) * 60 + int(cpuMatchObject.group(3))
except:
pass
try:
rssMatchObject = re.search('mem=([0-9]*)([a-z]*)', sys.argv[5])
rssInt = int(rssMatchObject.group(1))
rssUnit = rssMatchObject.group(2)
except:
pass
else:
if rssUnit == 'gb':
jobfeatures['max_rss_bytes'] = rssInt * 1000000000
elif rssUnit == 'mb':
jobfeatures['max_rss_bytes'] = rssInt * 1000000
elif rssUnit == 'kb':
jobfeatures['max_rss_bytes'] = rssInt * 1000
elif rssUnit == 'b':
# Is this the right name??
jobfeatures['max_rss_bytes'] = rssInt
# Values in /var/run/mjf-torque take precedence
try:
fromRun = open('/var/run/mjf-torque','r').read()
except:
fromRun = ''
# Also look in persistent /etc/sysconfig/mjf
# Also look in persistent /etc/sysconfig/mjf-torque
try:
fromSysconfig = open('/etc/sysconfig/mjf','r').read()
fromSysconfig = open('/etc/sysconfig/mjf-torque','r').read()
except:
fromSysconfig = ''
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment