added for the first time
[monitor.git] / automate_pl03.sh
1 #!/bin/bash
2
3 set -e
4 cd $HOME/monitor/
5 DATE=`date +%Y-%m-%d-%T`
6
7 if [ -f $HOME/monitor/SKIP ] ; then 
8         #       echo "SKIPPING Monitor"
9         #       exit
10         # TODO: should be possible to kill the old version if 
11         # desired and prevent lingering instances of automate.
12         if [ -z "$1" ] ; then 
13                 echo "KILLING Monitor"
14                 PID=`cat $HOME/monitor/SKIP`
15                 rm -f $HOME/monitor/SKIP
16                 ./kill.cmd.sh $PID
17         else 
18                 # skipping monitor
19                 echo "SKIPPING Monitor"
20                 exit
21         fi 
22 fi
23 echo $$ > $HOME/monitor/SKIP
24 #########################
25 # 1. FINDBAD NODES 
26 rm -f pdb/production.findbad2.pkl
27 ./findbad.py --increment --cachenodes --debug=0 --dbname="findbad2" $DATE
28
29 ps ax | grep BatchMode | grep -v grep | awk '{print $1}' | xargs kill
30
31 ########################
32 # COPY to golf for diagnose.py and action.py
33 cp pdb/production.findbad2.pkl pdb/production.findbad.pkl
34 #scp pdb/production.findbad2.pkl soltesz@golf.cs.princeton.edu:monitor3/pdb/production.findbad.pkl
35
36 ########################
37 # COPY Act_all records
38 #scp soltesz@golf.cs.princeton.edu:monitor3/pdb/production.act_all.pkl pdb/
39
40 ########################
41 # badcsv.txt
42 ./printbadcsv.py  | grep -v loading | tr -d ' ' > badcsv.txt
43 cp badcsv.txt /plc/data/var/www/html/monitor/
44
45 #########################
46 # 2. FINDBAD PCUS
47 rm -f pdb/production.findbadpcus2.pkl
48 ./findbadpcu.py --increment --refresh --debug=0 --dbname=findbadpcus2 $DATE             
49
50 ./sitebad.py --increment
51
52 # clean up stray 'locfg' processes that hang around inappropriately...
53 ps ax | grep locfg | grep -v grep | awk '{print $1}' | xargs kill
54
55 # convert pkl to php serialize format.
56 cp pdb/production.findbadpcus2.pkl pdb/production.findbadpcus.pkl
57 ./pkl2php.py -i findbadpcus2 -o findbadpcus
58
59 ./pkl2php.py -i act_all -o act_all
60 ./pkl2php.py -i plcdb_hn2lb -o plcdb_hn2lb
61 ./pkl2php.py -i findbad -o findbadnodes
62 ./pkl2php.py -i ad_dbTickets -o ad_dbTickets
63 ./pkl2php.py -i idTickets -o idTickets
64
65 for f in findbad act_all findbadpcus l_plcnodes; do 
66         cp pdb/production.$f.pkl archive-pdb/`date +%F-%H:%M`.production.$f.pkl
67 done
68
69 rm -f $HOME/monitor/SKIP