source: trunk/save-jobstats.sh@ 40

Last change on this file since 40 was 37, checked in by gegorbet, 6 years ago

gridctl mods for mysqli and aucsolutions, plus new text for crontabs and cronic

  • Property svn:executable set to *
  • Property svn:keywords set to LastChangedDate Author
File size: 2.1 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`
11if [ `echo ${HOSTNAME}|grep -c "novalo"` -ne 0 ]; then
12 HOSTNAME="uslims3.aucsolutions.com"
13fi
14echo "HOSTNAME=${HOSTNAME}"
15
16##JSTIME=`stat ${SAVEDIR} -c %Y`
17JSTIME=`date +%s`
18##echo "JSTIME=${JSTIME}"
19NCFILE=0
20NMFILE=0
21ONEDAY=86400 # 24-hours worth of seconds
22
23# Get uslims3_data subdirectories
24cd ${BASEDIR}
25DATADIRS=`ls -rtF|tail -500|grep '/'`
26##DATADIRS=`ls -rtF|tail -200|grep '/'`
27
28for 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}
66done
67
68echo "job_stats+++ Files Created: ${NCFILE}"
69echo "jobxml/stats Files Missing: ${NMFILE} (aborted,running jobs?)"
70
Note: See TracBrowser for help on using the repository browser.