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