#!/bin/sh ############################################################################## # # Program: get-remote-jobinfo # Usage: get-remote-jobinfo # Purpose: Get remote-job-directory information for a given job # #Logic Handling: ########################################################################### # #set the exitCode variable export exitCode=0 if [ $# -ne 2 ] then echo "Usage: get-remote-jobinfo " echo "Example: get-remote-jobinfo CPE_6890_4 /direct/atlas/myname/jobs" exitCode=1 exit $exitCode else #Get the path to the run directory jobDIR=$2 runDIR=${jobDIR}/run # #Check that the job directory exists if [ ! -e ${jobDIR} ] then echo "[get-remote-jobinfo]: jobs_directory:${jobDIR} does not exist" exitCode=1 exit $exitCode fi #Check that the run directory exists if [ ! -e ${runDIR} ] then echo "[get-remote-jobinfo]: run_directory:${runDIR} does not exist" exitCode=1 exit $exitCode fi #Get the job ID ID=$1 #Check that a directory exists in ${runDIR} whch contains the string $ID ls ${runDIR} |grep "${ID}" > /tmp/getIDs.$$ if [ $? -ne 0 ] then echo "[get-remote-jobinfo]: error: no run directory can be found containing the string <${ID}>" exitCode=1 exit $exitCode fi fi #cat /tmp/getIDs.$$ daxDIR="${jobDIR}/dax" logDIR="${jobDIR}/log" ##### Perform File Checks ######################################## #Check that the logfile-directory exists if [ ! -w ${logDIR} ] then mkdir -p ${logDIR} if [ $? != 0 ] then echo "[get-remote-jobinefo]: error: can not make log directory ${logDIR}" exitCode=2 exit $exitCode else chmod 775 ${logDIR} fi fi #First check that the user has a valid grid proxy #GRID-PROXY CHECK grid-proxy-info -e if [ $? != 0 ];then grid-proxy-init if [ $? != 0 ];then exitCode=2 echo "[get-remote-jobinfo]: a valid grid proxy for user `whoami` can not be established" exit $exitCode fi fi for jobname in `cat /tmp/getIDs.$$` do logFile="${logDIR}/${jobname}.log" echo "`date +'%Y.%m.%d %X %Z'`: [get-remote-jobinfo]: entering get-remote-jobinfo" >> ${logFile} echo "" echo "Job:${jobname}" echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo "Job:${jobname}" >> ${logFile} jobrunDIR=${runDIR}/${jobname} gceTrans=`echo $jobname | cut -d"." -f1` cd ${jobrunDIR} #Check that the file ${gceTrans}_ID000001.sub exists xformsubfile=${gceTrans}_ID000001.sub if [ -s ${xformsubfile} ] then # ######################################### # Perform checks on the chosenCE # ######################################### # #--------- # Step 1 | Get the URL for the compute element (put in stuff later for lcgpbs sites) #--------- compute_element=`grep "^globusscheduler = " ${xformsubfile}|cut -d"=" -f2|sed -e "s/ //"|cut -d '/' -f1`/jobmanager-fork echo "[get-remote-jobinfo]: compute_element=${compute_element}" echo "[get-remote-jobinfo]: compute_element=${compute_element}" >> ${logFile} # #--------- # Step 2 | Get the working directory on the compute elemenet #--------- remote_initialdir=`grep "^remote_initialdir = " ${xformsubfile}|cut -d"=" -f2|sed -e "s/ //"` echo "[get-remote-jobinfo]: remote_initialdir=${remote_initialdir}" echo "[get-remote-jobinfo]: remote_initialdir=${remote_initialdir}" >> ${logFile} # #--------- # Step 3 | Remove the remote_initialdir #--------- # echo "[get-remote-jobinfo]: listing space used in working directories on ${compute_element}" echo "[get-remote-jobinfo]: listing space used in working directories on ${compute_element}" >> ${logFile} echo " and contents of directory ${remote_initialdir}" echo " and contents of directory ${remote_initialdir}" >> ${logFile} globus-job-run ${compute_element} /bin/sh -c "/bin/df -h ${remote_initialdir};echo '';echo ""Contents of ${remote_initialdir}:""; /bin/ls -l ${remote_initialdir}" if [ $? != 0 ] then exitCode=2 echo "[get-remote-jobinfo]: Unable to list information for ${remote_initialdir} on ${compute_element}" echo "[get-remote-jobinfo]: Unable to list information for ${remote_initialdir} on ${compute_element}" >> ${logFile} echo "`date +'%Y.%m.%d %X %Z'`: [get-remote-jobinfo]: exiting get-remote-jobinfo" >> ${logFile} continue fi else echo "[get-remote-jobinfo]: File ${jobrunDIR}/${xformsubfile} does not exist" echo "[get-remote-jobinfo]: File ${jobrunDIR}/${xformsubfile} does not exist" >> ${logFile} echo " Unable to determine URL of compute element." echo " Unable to determine URL of compute element." >> ${logFile} exitCode=2 echo "`date +'%Y.%m.%d %X %Z'`: [get-remote-jobinfo]: exiting get-remote-jobinfo" >> ${logFile} fi echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" done /bin/rm -r /tmp/getIDs.$$ exit ${exitCode}