Various updates; Add logAxis patch for graphite; Add namespaces to summary scripts.
[myops.git] / web / collect / client / bootstrap.sh
1 #!/bin/bash
2
3 # NOTE: use unique value to get minute
4 if [[ -f /etc/planetlab/node_id ]] ; then
5     V=`cat /etc/planetlab/node_id`
6 else
7     if [[ ! -f ./node_id ]] ; then
8         echo $RANDOM > ./node_id
9     fi
10     V=`cat node_id`
11 fi
12
13 if [[ -f /etc/planetlab/plc_config ]] ; then
14         source /etc/planetlab/plc_config
15 else
16         PLC_SLICE_PREFIX='pl'
17 fi
18
19 min=$(( $V % 60 ))
20 min2=$(( ($min + 10) % 60 ))
21 min3=$(( ($min + 20) % 60 ))
22 # Run every three hours using a fixed point in time.
23 cat <<EOF > collect_and_upload.cron
24 PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/home/${PLC_SLICE_PREFIX}_myops/
25 $min */1 * * * /home/${PLC_SLICE_PREFIX}_myops/collect.sh
26 $min2 */1 * * * /home/${PLC_SLICE_PREFIX}_myops/upload.sh
27 $min3 */1 * * * /home/${PLC_SLICE_PREFIX}_myops/update.sh
28 EOF
29
30 if [ ! -x /usr/sbin/lshw ] ; then
31     yum install -y lshw
32 fi
33
34 if [ ! -f /usr/boot/myops_cacert.pem ] ; then
35     mkdir -p /usr/boot
36         cp -f myops_cacert.pem /usr/boot/myops_cacert.pem
37 fi
38
39 chmod 755 /home/${PLC_SLICE_PREFIX}_myops/collect.sh
40 chmod 755 /home/${PLC_SLICE_PREFIX}_myops/upload.sh
41 chmod 755 /home/${PLC_SLICE_PREFIX}_myops/update.sh
42 crontab -u root collect_and_upload.cron
43