From 2569f8aed2a30e58e59902dde9aa404371db7cea Mon Sep 17 00:00:00 2001
From: Nikolay Stanchev <ns17@it-innovation.soton.ac.uk>
Date: Tue, 21 Aug 2018 14:55:54 +0100
Subject: [PATCH] Updated tick stack installation to create alert templates
 when kapacitor is installed

---
 scripts/clmc-service/install-tick-stack.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/scripts/clmc-service/install-tick-stack.sh b/scripts/clmc-service/install-tick-stack.sh
index d2f639d..74de385 100755
--- a/scripts/clmc-service/install-tick-stack.sh
+++ b/scripts/clmc-service/install-tick-stack.sh
@@ -49,3 +49,19 @@ systemctl start influxdb
 systemctl start kapacitor
 systemctl start chronograf
 
+# wait for kapacitor to start
+while ! nc -z localhost 9092
+do
+  echo "Waiting for kapacitor port 9092 to be ready on localhost..."
+  sleep 1
+done
+
+# define the TICK script templates within Kapacitor
+echo "----> Creating alert templates in Kapacitor"
+cd ${REPO_ROOT}/src/service/clmcservice/resources/TICKscript
+for template_file in *.tick; do
+    template_id=$(basename ${template_file} .tick)
+    echo ${template_id} ${template_file}
+    kapacitor define-template ${template_id} -tick ${template_file}
+done
+
-- 
GitLab