source: trunk/save-jobstats.sh@ 25

Last change on this file since 25 was 7, checked in by gegorbet, 10 years ago

airvata/thrift, us3-listen, update_notice changes

  • Property svn:executable set to *
  • Property svn:keywords set to LastChangedDate Author
File size: 2.0 KB
Line 
1#!/bin/sh
2# save-jobstats.sh -- save uslims3_data job_statistics.xml files
3
4BASEDIR=/srv/www/htdocs/uslims3/uslims3_data
5SAVEDIR=/srv/www/htdocs/uslims3/job_stats
6STATFILE=job_statistics.xml
7if [ ! -d ${SAVEDIR} ]; then
8 mkdir ${SAVEDIR}
9fi
10HOSTNAME=`uname -n`
11echo "HOSTNAME=${HOSTNAME}"
12
13##JSTIME=`stat ${SAVEDIR} -c %Y`
14JSTIME=`date +%s`
15##echo "JSTIME=${JSTIME}"
16NCFILE=0
17NMFILE=0
18ONEDAY=86400 # 24-hours worth of seconds
19
20# Get uslims3_data subdirectories
21cd ${BASEDIR}
22DATADIRS=`ls -rtF|tail -500|grep '/'`
23##DATADIRS=`ls -rtF|tail -200|grep '/'`
24
25for 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}
63done
64
65echo "job_stats+++ Files Created: ${NCFILE}"
66echo "jobxml/stats Files Missing: ${NMFILE} (aborted,running jobs?)"
67
Note: See TracBrowser for help on using the repository browser.