Add scripts to create myops-getqueryview:
[myops.git] / web / collect / client / bootstrap.sh
diff --git a/web/collect/client/bootstrap.sh b/web/collect/client/bootstrap.sh
new file mode 100644 (file)
index 0000000..50af68e
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+# NOTE: use unique value to get minute
+if [[ -f /etc/planetlab/node_id ]] ; then
+    V=`cat /etc/planetlab/node_id`
+else
+    V=$RANDOM
+fi
+
+if [[ -f /etc/planetlab/plc_config ]] ; then
+       source /etc/planetlab/plc_config
+else
+       PLC_SLICE_PREFIX='pl'
+fi
+
+min=$(( $V % 60 ))
+min2=$(( ($min + 10) % 60 ))
+# Run every three hours using a fixed point in time.
+cat <<EOF > collect_and_upload.cron
+PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/home/${PLC_SLICE_PREFIX}_myops/
+$min */1 * * * /home/${PLC_SLICE_PREFIX}_myops/collect.sh
+$min2 */1 * * * /home/${PLC_SLICE_PREFIX}_myops/upload.sh
+EOF
+
+yum install -y lshw
+
+chmod 755 /home/${PLC_SLICE_PREFIX}_myops/collect.sh
+chmod 755 /home/${PLC_SLICE_PREFIX}_myops/upload.sh
+crontab -u root collect_and_upload.cron
+
+