[7] | 1 | #!/bin/sh
|
---|
| 2 | # save-jobstats.sh -- save uslims3_data job_statistics.xml files
|
---|
| 3 |
|
---|
| 4 | BASEDIR=/srv/www/htdocs/uslims3/uslims3_data
|
---|
| 5 | SAVEDIR=/srv/www/htdocs/uslims3/job_stats
|
---|
| 6 | STATFILE=job_statistics.xml
|
---|
| 7 | if [ ! -d ${SAVEDIR} ]; then
|
---|
| 8 | mkdir ${SAVEDIR}
|
---|
| 9 | fi
|
---|
| 10 | HOSTNAME=`uname -n`
|
---|
[37] | 11 | if [ `echo ${HOSTNAME}|grep -c "novalo"` -ne 0 ]; then
|
---|
| 12 | HOSTNAME="uslims3.aucsolutions.com"
|
---|
| 13 | fi
|
---|
[7] | 14 | echo "HOSTNAME=${HOSTNAME}"
|
---|
| 15 |
|
---|
| 16 | ##JSTIME=`stat ${SAVEDIR} -c %Y`
|
---|
| 17 | JSTIME=`date +%s`
|
---|
| 18 | ##echo "JSTIME=${JSTIME}"
|
---|
| 19 | NCFILE=0
|
---|
| 20 | NMFILE=0
|
---|
| 21 | ONEDAY=86400 # 24-hours worth of seconds
|
---|
| 22 |
|
---|
| 23 | # Get uslims3_data subdirectories
|
---|
| 24 | cd ${BASEDIR}
|
---|
| 25 | DATADIRS=`ls -rtF|tail -500|grep '/'`
|
---|
| 26 | ##DATADIRS=`ls -rtF|tail -200|grep '/'`
|
---|
| 27 |
|
---|
| 28 | for D in $DATADIRS ; do
|
---|
| 29 | # Change to job subdirectory
|
---|
| 30 | JDTIME=`stat ${D} -c %Y`
|
---|
| 31 | AGE=`expr ${JSTIME} - ${JDTIME}`
|
---|
| 32 | ##echo "D=${D}"
|
---|
| 33 | ##echo " JDTIME=${JDTIME}"
|
---|
| 34 | ##echo " AGE=${AGE}"
|
---|
| 35 |
|
---|
| 36 | # Only process directories less than a day old
|
---|
| 37 | if [ ${AGE} -lt ${ONEDAY} ]; then
|
---|
| 38 | JDDATE=`stat ${D} -c %y | cut -d: -f1-2 | sed -e 's/ /-/' -e 's/://g'`
|
---|
| 39 | cd ${BASEDIR}/${D}
|
---|
| 40 | ##echo " +++Less than 1 day old+++"
|
---|
| 41 |
|
---|
| 42 | if [ -f ${STATFILE} ]; then
|
---|
| 43 | # Build job stats if job_statistics.xml exists
|
---|
| 44 | PART1A=`grep cluster= ${STATFILE}|sed -e 's/^.*cluster=\"//'|cut -d'"' -f1`
|
---|
| 45 | PART1A=`echo ${PART1A} | sed -e 's@-@_@'`
|
---|
| 46 | PART1B=`echo ${D} | cut -d'-' -f1`
|
---|
| 47 | PART1=${PART1A}-${PART1B}
|
---|
| 48 | PART2=`grep submittime= ${STATFILE}|sed -e 's/^.*submittime=\"//'|cut -d' ' -f1`
|
---|
| 49 | PART2=`echo ${PART2}|sed -e 's/\-//g'`
|
---|
| 50 | SOUTFILE=${SAVEDIR}/${PART1}-${PART2}-${STATFILE}
|
---|
| 51 | ##echo "we can build: ${SOUTFILE}"
|
---|
| 52 | if [ ! -f ${SOUTFILE} ]; then
|
---|
| 53 | echo "cp -p ${STATFILE} ${SOUTFILE}"
|
---|
| 54 | cp -p ${STATFILE} ${SOUTFILE}
|
---|
| 55 | NCFILE=`expr ${NCFILE} + 1`
|
---|
| 56 | fi
|
---|
| 57 | else
|
---|
| 58 | CLUST=`grep shortname ${BASEDIR}/${D}hpcr*xml|cut -d'"' -f4`
|
---|
| 59 | echo "job_statistics.xml in ${D} [ ${JDDATE} ${CLUST} ] does not exist!"
|
---|
| 60 | NMFILE=`expr ${NMFILE} + 1`
|
---|
| 61 | fi
|
---|
| 62 | fi
|
---|
| 63 |
|
---|
| 64 | # Change back to ./uslims3_data
|
---|
| 65 | cd ${BASEDIR}
|
---|
| 66 | done
|
---|
| 67 |
|
---|
| 68 | echo "job_stats+++ Files Created: ${NCFILE}"
|
---|
| 69 | echo "jobxml/stats Files Missing: ${NMFILE} (aborted,running jobs?)"
|
---|
| 70 |
|
---|