From df5a8c3b6eba3e8ae5b17f11cf53f7afcf607746 Mon Sep 17 00:00:00 2001
From: MJB <mjb@it-innovation.soton.ac.uk>
Date: Thu, 17 May 2018 17:04:45 +0100
Subject: [PATCH] Added sr tag to the telegraf agent #69

---
 Vagrantfile                              |  2 +-
 clmctest/inputs/rspec.yml                | 10 ++++++++--
 clmctest/monitoring/rspec.yml            |  2 ++
 clmctest/streaming/rspec.yml             |  3 +++
 scripts/clmc-agent/configure.sh          | 14 +++++++++-----
 scripts/clmc-agent/configure_template.sh |  1 +
 scripts/clmc-agent/install.sh            |  4 ----
 scripts/clmc-agent/telegraf.conf         |  2 ++
 8 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/Vagrantfile b/Vagrantfile
index 58aab66..c195390 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -114,7 +114,7 @@ Vagrant.configure("2") do |config|
           # CLMC agent general and output configuration
           #instance_config.vm.provision :shell, :path => "scripts/clmc-agent/configure_template.sh"
 
-          instance_config.vm.provision :shell, :path => "scripts/clmc-agent/configure.sh", :args => "#{host["location"]} #{host["sfc_id"]} #{host["sfc_id_instance"]} #{host["sf_id"]} #{host["sf_id_instance"]} #{host["ipendpoint_id"]} #{host["influxdb_url"]} #{host["database_name"]}"  
+          instance_config.vm.provision :shell, :path => "scripts/clmc-agent/configure.sh", :args => "#{host["location"]} #{host["sfc_id"]} #{host["sfc_id_instance"]} #{host["sf_id"]} #{host["sf_id_instance"]} #{host["ipendpoint_id"]} #{host["sr_id"]} #{host["influxdb_url"]} #{host["database_name"]}"
 
           # CLMC start agent
           instance_config.vm.provision :shell, inline: "service telegraf restart"            
diff --git a/clmctest/inputs/rspec.yml b/clmctest/inputs/rspec.yml
index 7d90398..5084b29 100644
--- a/clmctest/inputs/rspec.yml
+++ b/clmctest/inputs/rspec.yml
@@ -47,6 +47,7 @@ hosts:
     sf_id: "adaptive_streaming"
     sf_id_instance: "adaptive_streaming_I1"
     ipendpoint_id: "adaptive_streaming_I1_apache1"
+    sr_id: "service_router"
     influxdb_url: "http://172.40.231.51:8086"
     database_name: "CLMCMetrics"
   - name: nginx
@@ -64,6 +65,7 @@ hosts:
     sf_id: "adaptive_streaming"
     sf_id_instance: "adaptive_streaming_nginx_I1"
     ipendpoint_id: "adaptive_streaming_nginx_I1_apache1"
+    sr_id: "service_router"    
     influxdb_url: "http://172.40.231.51:8086"
     database_name: "CLMCMetrics"
   - name: mongo
@@ -81,6 +83,7 @@ hosts:
     sf_id: "metadata_database"
     sf_id_instance: "metadata_database_I1"
     ipendpoint_id: "metadata_database_I1_apache1"
+    sr_id: "service_router"
     influxdb_url: "http://172.40.231.51:8086"
     database_name: "CLMCMetrics" 
   - name: ffmpeg
@@ -98,6 +101,7 @@ hosts:
     sf_id: "metadata_database"
     sf_id_instance: "metadata_database_I1"
     ipendpoint_id: "metadata_database_I1_apache1"
+    sr_id: "service_router"
     influxdb_url: "http://172.40.231.51:8086"
     database_name: "CLMCMetrics" 
   - name: host
@@ -115,11 +119,12 @@ hosts:
     sf_id: "adaptive_streaming"
     sf_id_instance: "adaptive_streaming_I1"
     ipendpoint_id: "adaptive_streaming_I1_apache1"
+    sr_id: "service_router"
     influxdb_url: "http://172.40.231.51:8086"
     database_name: "CLMCMetrics"
   - name: test-runner
-    cpus: 1
-    memory: 2048
+    cpus: 2
+    memory: 4096
     disk: "10GB"
     ip_address: "172.40.231.200"
   - name: minio
@@ -137,5 +142,6 @@ hosts:
     sf_id: "adaptive_streaming"
     sf_id_instance: "adaptive_streaming_I1"
     ipendpoint_id: "adaptive_streaming_I1_minio"
+    sr_id: "service_router"
     influxdb_url: "http://172.40.231.51:8086"
     database_name: "CLMCMetrics"
\ No newline at end of file
diff --git a/clmctest/monitoring/rspec.yml b/clmctest/monitoring/rspec.yml
index e016470..43fd381 100644
--- a/clmctest/monitoring/rspec.yml
+++ b/clmctest/monitoring/rspec.yml
@@ -47,6 +47,7 @@ hosts:
     sf_id: "test-sf-clmc-agent-build"
     sf_id_instance: "ms-A.ict-flame.eu"
     ipendpoint_id: "endpoint1.ms-A.ict-flame.eu"
+    sr_id: "service_router"
     influxdb_url: "http://172.40.231.51:8086"
     database_name: "CLMCMetrics"
   - name: ipendpoint2
@@ -64,6 +65,7 @@ hosts:
     sf_id: "test-sf-clmc-agent-build"
     sf_id_instance: "ms-A.ict-flame.eu"
     ipendpoint_id: "endpoint2.ms-A.ict-flame.eu"
+    sr_id: "service_router"
     influxdb_url: "http://172.40.231.51:8086"
     database_name: "CLMCMetrics"      
   - name: test-runner
diff --git a/clmctest/streaming/rspec.yml b/clmctest/streaming/rspec.yml
index 18dce36..5a0c594 100644
--- a/clmctest/streaming/rspec.yml
+++ b/clmctest/streaming/rspec.yml
@@ -47,6 +47,7 @@ hosts:
     sf_id: "adaptive_streaming"
     sf_id_instance: "adaptive_streaming_I1"
     ipendpoint_id: "adaptive_streaming_I1_nginx1"
+    sr_id: "service_router"
     influxdb_url: "http://192.168.50.10:8086"
     database_name: "CLMCMetrics"
   - name: nginx2
@@ -64,6 +65,7 @@ hosts:
     sf_id: "adaptive_streaming"
     sf_id_instance: "adaptive_streaming_I1"
     ipendpoint_id: "adaptive_streaming_I1_nginx2"
+    sr_id: "service_router"    
     influxdb_url: "http://192.168.50.10:8086"
     database_name: "CLMCMetrics"  
   - name: loadtest-streaming
@@ -81,5 +83,6 @@ hosts:
     sf_id: "adaptive_streaming_client"
     sf_id_instance: "adaptive_streaming_I1"
     ipendpoint_id: "adaptive_streaming_I1_client1"
+    sr_id: "service_router"
     influxdb_url: "http://192.168.50.10:8086"
     database_name: "CLMCMetrics"    
diff --git a/scripts/clmc-agent/configure.sh b/scripts/clmc-agent/configure.sh
index 9ce2c1c..41e91f5 100755
--- a/scripts/clmc-agent/configure.sh
+++ b/scripts/clmc-agent/configure.sh
@@ -30,10 +30,10 @@ set -euo pipefail
 echo "Configuring Telegraf agent general and output configuration"
 
 # Get command line parameters
-if [ "$#" -ne 8 ]; then
+if [ "$#" -ne 9 ]; then
     echo "Error: illegal number of arguments: "$#
-      echo "Usage: configure.sh LOCATION SFC_ID SFC_ID_INSTANCE SF_ID SF_ID_INSTANCE IP_ENDPOINT_ID INFLUXDB_URL DATABASE_NAME"
-      exit 1 
+    echo "Usage: configure.sh LOCATION SFC_ID SFC_ID_INSTANCE SF_ID SF_ID_INSTANCE IP_ENDPOINT_ID SR_ID INFLUXDB_URL DATABASE_NAME"
+    exit 1 
 fi
 
 LOCATION=$1
@@ -42,14 +42,17 @@ SFC_ID_INSTANCE=$3
 SF_ID=$4
 SF_ID_INSTANCE=$5
 IP_ENDPOINT_ID=$6
-INFLUXDB_URL=$7
-DATABASE_NAME=$8
+SR_ID=$7
+INFLUXDB_URL=$8
+DATABASE_NAME=$9
 
 TELEGRAF_CONF_DIR="/etc/telegraf"
 TELEGRAF_CONF_FILE=$TELEGRAF_CONF_DIR"/telegraf.conf"
 TELEGRAF_INCLUDE_CONF_DIR=$TELEGRAF_CONF_DIR"/telegraf.d"
 TELEGRAF_OUTPUT_CONF_FILE=$TELEGRAF_INCLUDE_CONF_DIR"/telegraf_output.conf"
 
+cat TELEGRAF_OUTPUT_CONF_FILE
+
 # Replace template parameters on general configuration
 sed -i 's/$LOCATION/'$LOCATION'/g' $TELEGRAF_CONF_FILE
 sed -i 's/$SFC_ID/'$SFC_ID'/g' $TELEGRAF_CONF_FILE
@@ -57,6 +60,7 @@ sed -i 's/$SFC_ID_INSTANCE/'$SFC_ID_INSTANCE'/g' $TELEGRAF_CONF_FILE
 sed -i 's/$SF_ID/'$SF_ID'/g' /etc/telegraf/telegraf.conf
 sed -i 's/$SF_ID_INSTANCE}}/'$SF_ID_INSTANCE'/g' $TELEGRAF_CONF_FILE
 sed -i 's/$IP_ENDPOINT_ID/'$IP_ENDPOINT_ID'/g' $TELEGRAF_CONF_FILE
+sed -i 's/$SR_ID/'$SR_ID'/g' $TELEGRAF_CONF_FILE
 
 # Replace parameters in output configuration file
 sed -i 's|$INFLUXDB_URL|'$INFLUXDB_URL'|g' $TELEGRAF_OUTPUT_CONF_FILE
diff --git a/scripts/clmc-agent/configure_template.sh b/scripts/clmc-agent/configure_template.sh
index 2df916b..136a266 100644
--- a/scripts/clmc-agent/configure_template.sh
+++ b/scripts/clmc-agent/configure_template.sh
@@ -53,6 +53,7 @@ echo "Telegraf general config file: " $TELEGRAF_CONF_FILE
   sf="$SF_ID"
   sf_i="$SF_ID_INSTANCE"
   ipendpoint="$IP_ENDPOINT_ID"
+  sr="$SR_ID"
 [agent]
   interval = "10s"
   round_interval = true
diff --git a/scripts/clmc-agent/install.sh b/scripts/clmc-agent/install.sh
index 335e272..d0a0de1 100755
--- a/scripts/clmc-agent/install.sh
+++ b/scripts/clmc-agent/install.sh
@@ -42,10 +42,6 @@ if [ ! -f ${REPO_ROOT}/reporc ]; then
 fi
 source ${REPO_ROOT}/reporc
 
-echo "Setting the envrionemtn variables"
-echo "USER: ${REPO_USER}"
-echo "PASS: ${REPO_PASS}"
-
 wget --user ${REPO_USER} --password ${REPO_PASS} https://flame-nexus.it-innovation.soton.ac.uk/repository/flame-general/it-innovation/telegraf/${TELEGRAF_VERSION}/telegraf-${TELEGRAF_VERSION}.deb -O telegraf-${TELEGRAF_VERSION}.deb
 
 
diff --git a/scripts/clmc-agent/telegraf.conf b/scripts/clmc-agent/telegraf.conf
index 1800940..6c5aed6 100644
--- a/scripts/clmc-agent/telegraf.conf
+++ b/scripts/clmc-agent/telegraf.conf
@@ -44,6 +44,8 @@
   sf_i="$SF_ID_INSTANCE"
   # ipendpoint id aka surrogate instance
   ipendpoint="$IP_ENDPOINT_ID"
+  # the service router providing access to the network
+  sr="$SR_ID"
 
 # Configuration for telegraf agent
 [agent]
-- 
GitLab