3 # NOTE: Must be an absolute path to guarantee it is read.
4 source /usr/share/monitor-server/monitorconfig.py
5 cd ${MONITOR_SCRIPT_ROOT}
7 DATE=`date +%Y-%m-%d-%T`
8 MONITOR_PID="$HOME/monitor/SKIP"
10 echo "Performing API test"
12 if [ "$API" != "ok" ] ; then
13 # NOTE: Do not try to run any commands if the API is obviously broken.
14 echo "API IS DOWN : "`date`
18 if [ -f $MONITOR_PID ] ; then
20 echo "KILLING Monitor"
21 PID=`cat $MONITOR_PID`
23 ${MONITOR_SCRIPT_ROOT}/kill.cmd.sh $PID
26 echo "SKIPPING Monitor"
30 echo $$ > $MONITOR_PID
32 echo "Performing Findbad Nodes"
33 #########################
35 rm -f ${MONITOR_DATA_ROOT}/production.findbad2.pkl
36 ${MONITOR_SCRIPT_ROOT}/findbad.py --increment --cachenodes --debug=0 --dbname="findbad2" $DATE || :
37 cp ${MONITOR_DATA_ROOT}/production.findbad2.pkl ${MONITOR_DATA_ROOT}/production.findbad.pkl
38 ps ax | grep BatchMode | grep -v grep | awk '{print $1}' | xargs kill || :
40 echo "Performing Findbad PCUs"
41 #########################
43 rm -f ${MONITOR_DATA_ROOT}/production.findbadpcus2.pkl
44 ${MONITOR_SCRIPT_ROOT}/findbadpcu.py --increment --refresh --debug=0 --dbname=findbadpcus2 $DATE || :
45 cp ${MONITOR_DATA_ROOT}/production.findbadpcus2.pkl ${MONITOR_DATA_ROOT}/production.findbadpcus.pkl
46 # clean up stray 'locfg' processes that hang around inappropriately...
47 ps ax | grep locfg | grep -v grep | awk '{print $1}' | xargs kill || :
49 echo "Generating web data"
51 ${MONITOR_SCRIPT_ROOT}/printbadcsv.py | grep -v loading | tr -d ' ' > badcsv.txt
52 cp badcsv.txt /plc/data/var/www/html/monitor/
53 ${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
55 echo "Performing uptime changes for sites, nodes, and pcus"
56 ########################
57 # 3. record last-changed for sites, nodes and pcus.
58 ${MONITOR_SCRIPT_ROOT}/sitebad.py --increment || :
59 ${MONITOR_SCRIPT_ROOT}/nodebad.py --increment || :
60 ${MONITOR_SCRIPT_ROOT}/pcubad.py --increment || :
62 echo "Converting pkl files to phpserial"
63 #########################
64 # 4. convert pkl to php serialize format.
65 ${MONITOR_SCRIPT_ROOT}/pkl2php.py -i findbadpcus2 -o findbadpcus
66 ${MONITOR_SCRIPT_ROOT}/pkl2php.py -i act_all -o act_all
67 ${MONITOR_SCRIPT_ROOT}/pkl2php.py -i plcdb_hn2lb -o plcdb_hn2lb
68 ${MONITOR_SCRIPT_ROOT}/pkl2php.py -i findbad -o findbadnodes
69 ${MONITOR_SCRIPT_ROOT}/pkl2php.py -i ad_dbTickets -o ad_dbTickets
70 ${MONITOR_SCRIPT_ROOT}/pkl2php.py -i idTickets -o idTickets
72 echo "Archiving pkl files"
73 #########################
75 for f in findbad act_all findbadpcus l_plcnodes site_persistflags node_persistflags pcu_persistflags ; do
76 cp ${MONITOR_DATA_ROOT}/production.$f.pkl ${MONITOR_ARCHIVE_ROOT}/`date +%F-%H:%M`.production.$f.pkl
79 echo "Running grouprins on all dbg nodes"
80 ############################
81 # 5. Check if there are any nodes in dbg state. Clean up afterward.
82 ${MONITOR_SCRIPT_ROOT}/grouprins.py --mail=1 \
83 --nodeselect 'state=DEBUG&&boot_state=(rins|dbg|boot)' \
84 --stopselect 'state=BOOT&&kernel=2.6.22.19-vs2.3.0.34.9.planetlab' \
86 ${MONITOR_SCRIPT_ROOT}/findbad.py --increment --cachenodes --debug=0 --dbname="findbad" --nodeselect 'state=DEBUG&&boot_state=dbg||state=DEBUG&&boot_state=boot' || :
88 echo "Collecting RT database dump"
89 ##########################
90 # 6. cache the RT db locally.
91 python ${MONITOR_SCRIPT_ROOT}/rt.py