]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/scripts/crontab.sh
648a1a709c07d1cc4b25e758c003df1d6cc68e8c
[helm.git] / helm / matita / scripts / crontab.sh
1 #!/bin/bash
2 TODAY=`date +%Y%m%d`
3 YESTERDAY=`date -d yesterday +%Y%m%d`
4 TMPDIRNAME=$HOME/__${TODAY}_crontab
5 CVSROOT=":ext:$USER@marcello.cs.unibo.it:/home/faculty/PROJECTS/cvs/helm"
6 SHELLTIME2CENTSPHP=helm/matita/scripts/shell_time2cents.php
7 SHELLADDERPHP=helm/matita/scripts/shell_adder.php
8 COMMONPHP=helm/matita/scripts/public_html/common.php
9
10
11 OLD=$PWD
12 rm -rf $TMPDIRNAME 
13 mkdir $TMPDIRNAME
14 cd $TMPDIRNAME
15 cvs -d $CVSROOT co helm/matita/scripts 1>/dev/null 2>/dev/null
16 helm/matita/scripts/profile_cvs.sh 2> LOG
17
18 MARK=`echo "select distinct mark from bench where mark like '$TODAY%' order by mark" | mysql -u helm matita | tail -n 1`
19 LASTMARK=`echo "select distinct mark from bench where mark like '$YESTERDAY%' order by mark" | mysql -u helm matita | tail -n 1`
20
21 if [ -z "$MARK" ]; then
22   echo "No benchmark records for $TODAY"
23   exit 1
24 fi
25
26 if [ -z "$LASTMARK" ]; then
27   echo "No benchmark records for $YESTERDAY"
28   exit 1
29 fi
30
31 CUR_TIME=`/usr/bin/php4 -c /etc/php4/apache/php.ini -f $SHELLADDERPHP -- $COMMONPHP "select SEC_TO_TIME(SUM(TIME_TO_SEC(time))) from bench where mark = \"$MARK\" group by mark;"`
32 OLD_TIME=`/usr/bin/php4 -c /etc/php4/apache/php.ini -f $SHELLADDERPHP -- $COMMONPHP  "select SEC_TO_TIME(SUM(TIME_TO_SEC(time))) from bench where mark = \"$LASTMARK\" group by mark;"`
33
34 CUR_CENTS=`/usr/bin/php4 -c /etc/php4/apache/php.ini -f $SHELLTIME2CENTSPHP -- $COMMONPHP $CUR_TIME`
35 OLD_CENTS=`/usr/bin/php4 -c /etc/php4/apache/php.ini -f $SHELLTIME2CENTSPHP -- $COMMONPHP $OLD_TIME`
36
37 ((DELTA=$CUR_CENTS-$OLD_CENTS))
38 if [ $DELTA -lt 0 ]; then
39   PERC=0
40 else
41   ((PERC=100 * $DELTA))
42   ((PERC=$PERC / $OLD_CENTS))
43 fi
44 if [ $PERC -ge 5 ]; then
45   cat <<EOT
46   REPORT FOR `date`
47   http://mowgli.cs.unibo.it/~tassi/bench.php
48
49   PERFORMANCE LOSS DETECTED (MARK $MARK vs MARK $LASTMARK)
50   is $CUR_TIME sec 
51   was $OLD_TIME sec
52
53 EOT
54 fi
55
56 CUR_FAIL=`/usr/bin/php4 -c /etc/php4/apache/php.ini -f $SHELLADDERPHP -- $COMMONPHP "select count(distinct test) from bench where mark = \"$MARK\" and result = 'fail';"`
57 OLD_FAIL=`/usr/bin/php4 -c /etc/php4/apache/php.ini -f $SHELLADDERPHP -- $COMMONPHP "select count(distinct test) from bench where mark = \"$LASTMARK\" and result = 'fail';"`
58
59 if [ $CUR_FAIL -gt $OLD_FAIL ]; then
60   cat <<EOT
61   REPORT FOR `date`
62   http://mowgli.cs.unibo.it/~tassi/bench.php
63
64   MORE BROKEN TESTS DETECTED (MARK $MARK vs MARK $LASTMARK)
65   now broken:
66   `echo "select distinct test from bench where mark = \"$MARK\" and result = 'fail';" | mysql -u helm -h mowgli.cs.unibo.it matita`
67   were broken:
68   `echo "select distinct test from bench where mark = \"$LASTMARK\" and result = 'fail';" | mysql -u helm -h mowgli.cs.unibo.it matita`
69   
70 EOT
71
72 fi
73
74 cd $OLD
75 #rm -rf $TMPDIRNAME
76