3 source monitorconfig.py
4 cd ${MONITOR_SCRIPT_ROOT}
6 DATE=`date +%Y-%m-%d-%T`
7 MONITOR_PID="$HOME/monitor/SKIP"
10 if [ "$API" != "ok" ] ; then
11 # NOTE: Do not try to run any commands if the API is obviously broken.
12 echo "API IS DOWN : "`date`
16 if [ -f $MONITOR_PID ] ; then
18 echo "KILLING Monitor"
19 PID=`cat $MONITOR_PID`
21 ${MONITOR_SCRIPT_ROOT}/kill.cmd.sh $PID
24 echo "SKIPPING Monitor"
28 echo $$ > $MONITOR_PID
30 #########################
32 rm -f ${MONITOR_DATA_ROOT}/production.findbad2.pkl
33 ${MONITOR_SCRIPT_ROOT}/findbad.py --increment --cachenodes --debug=0 --dbname="findbad2" $DATE || :
34 cp ${MONITOR_DATA_ROOT}/production.findbad2.pkl ${MONITOR_DATA_ROOT}/production.findbad.pkl
35 ps ax | grep BatchMode | grep -v grep | awk '{print $1}' | xargs kill || :
37 #########################
39 rm -f ${MONITOR_DATA_ROOT}/production.findbadpcus2.pkl
40 ${MONITOR_SCRIPT_ROOT}/findbadpcu.py --increment --refresh --debug=0 --dbname=findbadpcus2 $DATE || :
41 cp ${MONITOR_DATA_ROOT}/production.findbadpcus2.pkl ${MONITOR_DATA_ROOT}/production.findbadpcus.pkl
42 # clean up stray 'locfg' processes that hang around inappropriately...
43 ps ax | grep locfg | grep -v grep | awk '{print $1}' | xargs kill || :
46 ${MONITOR_SCRIPT_ROOT}/printbadcsv.py | grep -v loading | tr -d ' ' > badcsv.txt
47 cp badcsv.txt /plc/data/var/www/html/monitor/
48 ${MONITOR_SCRIPT_ROOT}/showlatlon.py | head -9 | awk 'BEGIN {print "<table>"} { print "<tr><td>", $0, "</td></tr>"} END{print "</table>"}' | sed -e 's\|\</td><td>\g' > /plc/data/var/www/html/monitor/regions.html
50 ########################
51 # 3. record last-changed for sites, nodes and pcus.
52 ${MONITOR_SCRIPT_ROOT}/sitebad.py --increment || :
53 ${MONITOR_SCRIPT_ROOT}/nodebad.py --increment || :
54 ${MONITOR_SCRIPT_ROOT}/pcubad.py --increment || :
56 #########################
57 # 4. convert pkl to php serialize format.
58 ${MONITOR_SCRIPT_ROOT}/pkl2php.py -i findbadpcus2 -o findbadpcus
59 ${MONITOR_SCRIPT_ROOT}/pkl2php.py -i act_all -o act_all
60 ${MONITOR_SCRIPT_ROOT}/pkl2php.py -i plcdb_hn2lb -o plcdb_hn2lb
61 ${MONITOR_SCRIPT_ROOT}/pkl2php.py -i findbad -o findbadnodes
62 ${MONITOR_SCRIPT_ROOT}/pkl2php.py -i ad_dbTickets -o ad_dbTickets
63 ${MONITOR_SCRIPT_ROOT}/pkl2php.py -i idTickets -o idTickets
65 #########################
67 for f in findbad act_all findbadpcus l_plcnodes site_persistflags node_persistflags pcu_persistflags ; do
68 cp ${MONITOR_DATA_ROOT}/production.$f.pkl ${MONITOR_ARCHIVE_ROOT}/`date +%F-%H:%M`.production.$f.pkl
71 ############################
72 # 5. Check if there are any nodes in dbg state. Clean up afterward.
73 ${MONITOR_SCRIPT_ROOT}/grouprins.py --mail=1 \
74 --nodeselect 'state=DEBUG&&boot_state=dbg||state=DEBUG&&boot_state=boot' \
75 --stopselect 'state=BOOT&&kernel=2.6.22.19-vs2.3.0.34.9.planetlab' \
77 ${MONITOR_SCRIPT_ROOT}/findbad.py --increment --cachenodes --debug=0 --dbname="findbad" --nodeselect 'state=DEBUG&&boot_state=dbg||state=DEBUG&&boot_state=boot' || :
79 ##########################
80 # 6. cache the RT db locally.
81 python ${MONITOR_SCRIPT_ROOT}/rt.py