#! /usr/bin/sh set -xva ############################################################# # NAME: DAVID MA # DATE: August 6, 2002 # PROGRAM: jobview_run # Description: This program to execute and compute the job # time for the web page. # # Script history log: # 2004-03-15 Collectingd number of nodes into the Node_file # in /ptmp/web directory. # # ########################################################## # echo "STARTING THE JOBVIEW PROCESSING" typeset -L10 JNATime JobOutTime JobLTime JobZTime JRunTime JDurTime typeset -L50 ASName export DATA ddat sjobs stimes smain sctime zctime qmach JobtmpRunTime export JobSMSName ctime JobOutTime JNATime JobZTime JRunTime JDurTime export lAStartTime lASETime JobPer JobLName JobName JobStat lAmsg JobPID export JobNode JobNumNode JobNodeClass node_file old_node_file # JobStat=${JobStat:-"4"} JobssPath=${JobssPath:-"/com/output/prod"} JobPID=${JobPID:-"101*"} zdate=`ls -rt $JobssPath | sort -k1.1,1 | tail -2 | head -1` zdatem1=`ls -rt $JobssPath | sort -k1.1,1 | tail -3 | head -1` echo "First date marker..." date -u ((sctime=$ctime)) # --- if job is running if [ ${JobStat} -eq 4 -o ${JobStat} -eq 9 -o ${JobStat} -eq 15 ] then # --- cannot find some ingest jobs ---- JobSp0File=`echo ${JobOFile} | cut -d "." -f 1` JobSp1File=`echo ${JobOFile} | cut -d "." -f 2` #*-- special names with hours attached to name of the file. JobcOFile=${JobSp0File}*${JobSp1File} # ------------------------------------- JobOFile1=`ls -rlt ${JobcOFile} | tail -1 ` if [ "${JobOFile1}" = "" ] then JobssPath=${JobssPath:-"/com/output/prod"} JobOFile1=`ls -rlt ${JobssPath}/$zdate/*${JobPID} | tail -1` JobOFile2=`ls -rlt ${JobssPath}/$zdatem1/*${JobPID} | tail -1` JobOFile1=${JobOFile1:-"$JobOFile2"} fi JobOmsg=`echo ${JobOFile1}` JobOPermission=`echo ${JobOFile1} | cut -d " " -f 1` JobmTime=`echo ${JobOmsg} | cut -d " " -f 8` JobmHR=`echo $JobmTime | cut -d ":" -f 1` JobmMM=`echo $JobmTime | cut -d ":" -f 2` # ---------- added this 2/4/03 JobOFile1=`echo $JobOFile1 | cut -d " " -f 9` ((JobOutTime = ${JobmHR} * 60.0 + ${JobmMM})) if [ $JobZTime -gt $JobLTime ] then ((JDurTime = $JobZTime - $JobLTime)) else ((JDurTime = 1440 + $JobZTime - $JobLTime)) echo "$JobName TAKE 1 = $JDurTime 2 = $JobZTime 3 = $JobLTime 4 = $JobOutTime 5 = $ctime" >> ttsai fi ((JobOutTime = ${JobOutTime} + ${JDurTime})) # ((sctime = $ctime + 1440)) # get working directory name if [ "${JobOPermission}" != "-rwx------" -a "${JobOPermission}" != "-rw-------" ] then JobSMSName=`grep "SMS-> active:" ${JobOFile1} | head -1 | cut -d ":" -f 2 ` JobSMSName=${JobSMSName}" " JobtmpName=`grep "DATA=" ${JobOFile1} | grep tmpnwprd | head -1 | cut -d "=" -f 2 ` echo "$JobName $JobOFile $JobtmpName" >> lljobtmp.lst if [ "${JobtmpName}" = "" ] then JobtmpName=${JobmTime} fi # # --------get the average time from /com/web/prod ------------------------------------------------- grep -i ${JobSMSName} ${tfile} > ttsd # grep -i ${JobSMSName} $JobHist >> ttsd # echo "Jobsms name = ${JobSMSName}" #cat ttsd ((ASETime=0)) ((lASETime=0)) qi=0 qi=`cat ttsd | wc -l ` if [ $qi -lt 1 ] then grep -i ${JobSMSName} ${jhist} > ttsd echo "No record found ${JobSMSName} ${zctime} $ctime " fi # -------------------------------------------------------------- date -u JobCSMSName=`basename $JobSMSName | cut -c1` if [ "$JobCSMSName" = "j" ] then # compute tmpnwprd time Jobtmpnwprdb contains /tmpnwprd path # Jobtmpnwprdb1=`find -H ${JobtmpName} -newer ${JobtmpName} | head -1` # ls -rltd $Jobtmpnwprdb1 # find working directory time changed to find file time. Jobtmpnwprdb1=`ls -dl ${JobtmpName}` # Jobtmpnwprdb=`find -H ${JobtmpName} -newer ${JobtmpName} | head -1` # Jobtmpnwprdb1=`ls -l ${Jobtmpnwprdb}` # Jobtmpnwprdb1=${Jobtmpnwprdb1:-"${JobtmpName}"} # Jobtmpnwprdb1=${Jobtmpnwprdb1:-"${JobOFile1}"} # echo "Got the tmpnwprod directory... ${JobtmpName}" Jobtmpnwprdb=${Jobtmpnwprdb1} date -u JobtmpTime=`echo ${Jobtmpnwprdb} | cut -d " " -f 8` # ---- added 5/21/2003 # echo "***** Job NEW list = $Jobtmpnwprd" # ---- JobtmpTime should be 00:00 format ---- # JobtmpTime=${JobtmpTime:-"0"} # if [ "${JobtmpTime}" = "0" ] # then #---- changed 6/5/03 # if [ -s ${JobtmpTime}/${Jobtmpnwprdb} ] # if [ -s ${Jobtmpnwprdb} ] # then #---- changed 6/5/03 # Jobtmpnwprd=`ls -ld ${JobtmpTime}/${Jobtmpnwprdb}` # Jobtmpnwprd=`ls -ld ${Jobtmpnwprdb}` # JobtmpTime=`echo ${Jobtmpnwprd} | cut -d " " -f 8` # fi # JobtmpTime=${JobtmpTime:-"0"} # fi JobtmpHR=`echo ${JobtmpTime} | cut -d ":" -f 1` JobtmpMM=`echo ${JobtmpTime} | cut -d ":" -f 2` if [ ${JobtmpHR} -eq 0 -a ${JobtmpMM} -eq 0 ] then ((JobtmpRunTime = ${JobOutTime})) else (( JobtmpRunTime = ${JobtmpHR}*60.0 + ${JobtmpMM} + ${JDurTime} )) fi if [ $JobtmpRunTime -gt 1440 ] then (( JobtmpRunTime = ${JobtmpRunTime} - 1440 )) fi else JobtmpHR="00:00" JobtmpMM="00:00" Jobtmpnwprdb1=$JobOFile1 Jobtmpnwprdb=$JobOFile1 JobtmpRunTime=$ctime fi fi # ------------------------------------------ if [ "$JobSMSName" = "" ] then echo "sms name = $JobSMSName" else echo "$JobSMSName $JobNumNode $JobNodeClass" >> ${node_file} fi JobSMSName=${JobSMSName:-"XXXX"} if [ $qi -ne 1 ] then if [ "$JobType" = "dev" ] then grep dev ttsd | sort -k2.1,2 > ttsf else if [ "$JobType" = "para" ] then grep para ttsd | sort -k2.1,2 > ttsf else if [ "$JobType" = "transfer" ] then grep transfer ttsd | sort -k2.1,2 > ttsf else grep -v dev ttsd | grep -v para | sort -k2.1,2 > ttsf fi fi fi # grep $JobName ttsff | grep $chr > ttsf ((MJobOutTime = $sctime)) # --------------------------------------------------- ((qi=0)) cat ttsf cat ttsf | while read qsline do if (( qi < 0 )) then ASName=`echo $qsline | cut -d " " -f 1` lAStartTime=`echo $qsline | cut -d " " -f 3` lAStopTime=`echo $qsline | cut -d " " -f 4` ((lAStartTime=$lAStartTime*100/100)) ((lAStopTime=$lAStopTime*100/100+1)) if (( lAStartTime < 10000 )) then lASETime=`echo $qsline | cut -d " " -f 5` if (( MJobOutTime >= lAStartTime && MJobOutTime <= lAStopTime )) then ((qi=100)) else ((AStartTime=$lAStartTime)) ((AStopTime=$lAStopTime)) ((ASETime=$lASETime)) if (( MJobOutTime > lAStartTime )) then ((AStartTime=$lAStartTime)) ((AStopTime=$lAStopTime)) ((ASETime=$lASETime)) else if (( MJobOutTime >= lAStopTime )) then ((lAStartTime=$AStartTime)) ((lAStopTime=$AStopTime)) ((lASETime=$ASETime)) ((qi=100)) else if [ $lAStartTime -ge 10000 -a $lAStopTime -ge 10000 ] then lAmsg="11440" fi ((AStartTime=$lAStartTime)) ((AStopTime=$lAStopTime)) ((ASETime=$lASETime)) fi fi fi lAmsg="9999" else lAmsg="11440" fi fi done lAmsg=${lAmsg:-"9999"} else ASName=`cat ttsd | cut -d " " -f 1` lAStartTime=`cat ttsd | cut -d " " -f 3` lAStopTime=`cat ttsd | cut -d " " -f 4` if [ $lAStartTime -lt 10000 -a $lAStopTime -lt 10000 ] then lAmsg="9999" lASETime=`cat ttsd | cut -d " " -f 5` else # set to indicate job aborted last time. # There is nothing like this on jobs that run all the time. lASETime=`cat ttsd | cut -d " " -f 5` lAmsg="11440" fi fi # -------------------------------------------------- # this will add one to the history duration time. if (( lASETime < 0 )) then ((lASETime=$lASETime+1.0)) fi ((lASETime=$lASETime*100.0/100.0)) # Z and L time different # ------- added 5/21/2003 # JobOutTime=${JobtmpRunTime} if [ $JobZTime -gt $JobLTime ] then ((JNATime = $ctime - $JobOutTime)) ((JRunTime = $ctime - $JobZTime)) else ((JNATime = $ctime - $JobOutTime - $JDurTime)) ((JRunTime = $ctime - $JobZTime)) fi ((JobLTime = $JobLTime + $JDurTime)) if [ $JobLTime -gt 1440 ] then ((JobLTime = $JobLTime - 1440)) fi # current time and z start time different if [ $JNATime -lt 0.0 ] then ((JNATime=0.0)) fi # if [ $JRunTime -lt 0.0 ] then ((JRunTime=0.0)) fi # Outline=`tail -1 ttsd` # echo "$ASName $lASETime" if [ ${lASETime} -le 0.0 ] then ((JobPer=0.0)) else ((JobPer=${JRunTime}*10000 / (${lASETime}*100))) fi ${stimes} elif [ ${JobStat} -eq 1 -o ${JobStat} -eq 3 ] then qidleline=`grep $JobName ${IDLEjobs}` qidleline=${qidleline:-"XXXX"} JobtmpRunTime=${JobtmpRunTime:-"0"} if [ "${qidleline}" != "XXXX" ] then JobIName=`echo "${qidleline} | cut -d " " -f 1` JobITime=`echo "${qidleline} | cut -d " " -f 2` # check to see in idle more than 5 minutes. if [ $ctime - $JobITime > 4 ] then lAmsg="20001" echo "$qidleline" >> ${IDLEjobsbkup} else if [ $ctime - $JobZTime > 5 ] then lAmsg="20001" echo "$qidleline" >> ${IDLEjobsbkup} else echo "$qidleline" >> ${IDLEjobsbkup} lAmsg="9999" fi fi else lAmsg="20000" echo "$JobLName $JobZTime" >> ${IDLEjobsbkup} fi ${stimes} else ${stimes} fi echo "Third date marker..." date -u