Commit 88281b55 authored by Andrew McNab's avatar Andrew McNab
Browse files

Version 0.7

parent 676f32fa
......@@ -31,7 +31,9 @@
include VERSION
INSTALL_FILES=VERSION prologue.user epilogue.user mjf.init mjf.sh mjf.csh mjf-get-total-cpu.torque
INSTALL_FILES=VERSION prologue.user epilogue.user mjf.init \
mjf-torque.sh mjf-torque.csh mjf-get-total-cpu.torque \
mjf-htcondor.sh mjf-htcondor.csh
TGZ_FILES=$(INSTALL_FILES) Makefile mjf-torque.spec mjf-htcondor.spec README
......@@ -47,10 +49,12 @@ install: $(INSTALL_FILES)
$(RPM_BUILD_ROOT)/etc/profile.d
cp mjf.init \
$(RPM_BUILD_ROOT)/etc/rc.d/init.d/mjf
cp mjf.sh mjf.csh \
$(RPM_BUILD_ROOT)/etc/profile.d
torque-install: $(INSTALL_FILES) install
cp mjf-torque.sh \
$(RPM_BUILD_ROOT)/etc/profile.d/mjf.sh
cp mjf-torque.csh \
$(RPM_BUILD_ROOT)/etc/profile.d/mjf.csh
mkdir -p $(RPM_BUILD_ROOT)/var/lib/torque/mom_priv
mkdir -p $(RPM_BUILD_ROOT)/usr/bin
cp prologue.user epilogue.user \
......@@ -58,6 +62,7 @@ torque-install: $(INSTALL_FILES) install
cp mjf-get-total-cpu.torque \
$(RPM_BUILD_ROOT)/usr/bin/mjf-get-total-cpu
torque-rpm: mjf-scripts.tgz
rm -Rf RPMTMP
mkdir -p RPMTMP/SOURCES RPMTMP/SPECS RPMTMP/BUILD \
......@@ -68,6 +73,10 @@ torque-rpm: mjf-scripts.tgz
--buildroot $(shell pwd)/RPMTMP/BUILDROOT mjf-torque.spec
htcondor-install: $(INSTALL_FILES) install
cp mjf-htcondor.sh \
$(RPM_BUILD_ROOT)/etc/profile.d/mjf.sh
cp mjf-htcondor.csh \
$(RPM_BUILD_ROOT)/etc/profile.d/mjf.csh
htcondor-rpm: mjf-scripts.tgz
rm -Rf RPMTMP
......
#!/bin/env python
import os, sys, urllib
class mjf:
InfoCode, WarningCode, ErrorCode = range(3)
def __init__(self):
# WarningCode etc values are what to report if that MJF key is absent
self.featuredict = {
'MACHINEFEATURES' : { 'hs06' : self.WarningCode,
'total_cpu' : self.ErrorCode,
'shutdowntime': self.InfoCode,
'grace_secs' : self.InfoCode },
'JOBFEATURES' : { 'allocated_cpu' : self.ErrorCode,
'hs06_job' : self.WarningCode,
'shutdowntime_job' : self.InfoCode,
'grace_secs_job' : self.InfoCode,
'jobstart_secs' : self.ErrorCode,
'job_id' : self.ErrorCode,
'wall_limit_secs' : self.ErrorCode,
'cpu_limit_secs' : self.ErrorCode,
'max_rss_bytes' : self.ErrorCode,
'max_swap_bytes' : self.WarningCode,
'scratch_limit_bytes' : self.WarningCode }
}
self.exitcode = 0
self.loglines = []
self.logdict = {'Info' : self.InfoCode,
'Warning' : self.WarningCode,
'Error' : self.ErrorCode}
self.logdictinv = {self.InfoCode: 'Info', self.WarningCode : 'Warning', self.ErrorCode : 'Error'}
self.reportline = 'Probe executed successfully'
def log(self, loglevel, logline):
if self.logdict[loglevel] > self.exitcode : self.reportline = logline
self.exitcode = max(self.exitcode, self.logdict[loglevel])
self.loglines.append(loglevel.ljust(8) + ': ' + logline)
def probe(self, featurevar):
self.log('Info', 'Processing %s' % featurevar)
proberoot = os.environ.get(featurevar)
if proberoot != None :
self.log('Info', '%s=%s' % (featurevar, proberoot))
onefeaturefound = False
for featureName in self.featuredict[featurevar]:
featureAbsentCode = self.featuredict[featurevar][featureName]
featureValue = None
try:
featureValue = urllib.urlopen(proberoot + '/' + featureName).read()
if not featureValue :
featureValue = 'None'
while featureValue[-1] == '\n':
featureValue = featureValue[:-1]
if not featureValue is None and featureValue != '':
onefeaturefound = True
self.log('Info', 'Key %s found with value %s' % (featureName, featureValue))
else :
featureValue = None
self.log('Info', 'Key %s found but value is empty' % featureName)
except :
featureValue = None
if featureValue is None:
self.log(self.logdictinv[featureAbsentCode], 'Key %s absent (or empty)' % featureName)
if not onefeaturefound:
self.log('Error', 'Environment variable %s set but cannot find any valid keys in there' % featurevar)
else:
self.log('Error', 'Environment variable %s not set' % featurevar)
def run(self):
map(lambda x: self.probe(x), self.featuredict.keys())
sys.stdout.write('%s %s\n\n' % (self.logdictinv[self.exitcode], self.reportline))
map(lambda x: sys.stdout.write(x + '\n'), self.loglines)
sys.exit(self.exitcode)
if __name__ == '__main__' :
mjf().run()
......@@ -32,7 +32,7 @@
# POSSIBILITY OF SUCH DAMAGE.
# Remove $JOBFEATURES directory for this job where the directory
# is at $HOME/jobfeatures-$PBS_JOBID ($1 is $PBS_JOBID)
# is at $PBS_O_HOME/jobfeatures-$PBS_JOBID ($1 is $PBS_JOBID)
if [ "$1" != "" -a -d ~/jobfeatures-$1 ] ; then
rm -Rf ~/jobfeatures-$1
......
if ( -d /etc/machinefeatures ) then
setenv MACHINEFEATURES /etc/machinefeatures
endif
if [ -d /etc/machinefeatures ] ; then
export MACHINEFEATURES=/etc/machinefeatures
fi
......@@ -2,5 +2,5 @@ if ( -d /etc/machinefeatures ) then
setenv MACHINEFEATURES /etc/machinefeatures
endif
if ( "$PBS_JOBID" != "" ) then
setenv JOBFEATURES $HOME/jobfeatures-$PBS_JOBID
setenv JOBFEATURES $PBS_O_HOME/jobfeatures-$PBS_JOBID
endif
......@@ -2,5 +2,5 @@ if [ -d /etc/machinefeatures ] ; then
export MACHINEFEATURES=/etc/machinefeatures
fi
if [ "$PBS_JOBID" != "" ] ; then
export JOBFEATURES=$HOME/jobfeatures-$PBS_JOBID
export JOBFEATURES=$PBS_O_HOME/jobfeatures-$PBS_JOBID
fi
......@@ -35,7 +35,7 @@
# specification in HSF-TN-2016-02
#
# This script creates the $JOBFEATURES directory at
# $HOME/jobfeatures-$PBS_JOBID and attempts to populate it
# $PBS_O_HOME/jobfeatures-$PBS_JOBID and attempts to populate it
# from Torque/PBS information and from
# $MACHINEFEATURES=/etc/machinefeatures
#
......@@ -56,7 +56,7 @@ import re
import sys
import time
homeDir = os.path.expanduser('~')
homeDir = os.environ['PBS_O_HOME']
job_id = sys.argv[1]
......
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