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