From e52196f8a2d07df26ab35b9ad42444750a57e16c Mon Sep 17 00:00:00 2001
From: MJB <mjb@it-innovation.soton.ac.uk>
Date: Fri, 2 Feb 2018 16:06:54 +0000
Subject: [PATCH] added simulation endpoint infra

---
 Vagrantfile                                   |   2 +-
 infra/streaming-sim/rspec.yml                 |  49 ++++++++
 .../services/ipendpoint/install-ipendpoint.sh |  28 +++++
 .../telegraf_ipendpoint_template.conf         | 112 ++++++++++++++++++
 4 files changed, 190 insertions(+), 1 deletion(-)
 create mode 100644 infra/streaming-sim/rspec.yml
 create mode 100644 test/services/ipendpoint/install-ipendpoint.sh
 create mode 100644 test/services/ipendpoint/telegraf_ipendpoint_template.conf

diff --git a/Vagrantfile b/Vagrantfile
index 7f890c9..e021b8f 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -88,7 +88,7 @@ Vagrant.configure("2") do |config|
       case instance_name
         when 'clmc-service'
           config.vm.provision :shell, :path => "scripts/clmc-service/#{host["install_script"]}"
-          config.vm.provision :shell, :path => "scripts/clmc-service/#{host["start_script"]}"
+          config.vm.provision :shell, :path => "scripts/clmc-service/#{host["start_script"]}" 
         else
           # specific service install
           service_install_path = "test/services/#{host["service_name"]}/install-#{host["service_name"]}.sh"
diff --git a/infra/streaming-sim/rspec.yml b/infra/streaming-sim/rspec.yml
new file mode 100644
index 0000000..11850d0
--- /dev/null
+++ b/infra/streaming-sim/rspec.yml
@@ -0,0 +1,49 @@
+hosts:
+  - name: clmc-service
+    cpus: 1
+    memory: 2048
+    disk: "10GB"
+    forward_ports:
+      - guest: 8086
+        host: 8086
+      - guest: 8888
+        host: 8888
+      - guest: 9092
+        host: 9092
+    ip_address: "192.168.50.10"
+    install_script: "install-clmc-service.sh"
+    start_script: "start-clmc-service.sh"
+  - name: ipendpoint1
+    cpus: 1
+    memory: 2048
+    disk: "10GB"
+    service_name: "ipendpoint"
+    forward_ports:
+      - guest: 80
+        host: 8081
+    ip_address: "192.168.50.11"
+    location: "DC1"
+    sfc_id: "MS_Template_1"
+    sfc_id_instance: "MS_I1"
+    sf_id: "adaptive_streaming"
+    sf_id_instance: "adaptive_streaming_I1"
+    ipendpoint_id: "adaptive_streaming_I1_apache1"
+    influxdb_url: "http://192.168.50.10:8086"
+    database_name: "CLMCMetrics"
+  - name: ipendpoint12
+    cpus: 1
+    memory: 2048
+    disk: "10GB"
+    service_name: "ipendpoint"
+    forward_ports:
+      - guest: 80
+        host: 8082
+    ip_address: "192.168.50.12"
+    location: "DC2"
+    sfc_id: "MS_Template_1"
+    sfc_id_instance: "MS_I1"
+    sf_id: "adaptive_streaming"
+    sf_id_instance: "adaptive_streaming_I1"
+    ipendpoint_id: "adaptive_streaming_I1_apache2"
+    influxdb_url: "http://192.168.50.10:8086"
+    database_name: "CLMCMetrics"      
\ No newline at end of file
diff --git a/test/services/ipendpoint/install-ipendpoint.sh b/test/services/ipendpoint/install-ipendpoint.sh
new file mode 100644
index 0000000..7cc5c34
--- /dev/null
+++ b/test/services/ipendpoint/install-ipendpoint.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+#/////////////////////////////////////////////////////////////////////////
+#//
+#// (c) University of Southampton IT Innovation Centre, 2017
+#//
+#// Copyright in this software belongs to University of Southampton
+#// IT Innovation Centre of Gamma House, Enterprise Road,
+#// Chilworth Science Park, Southampton, SO16 7NS, UK.
+#//
+#// This software may not be used, sold, licensed, transferred, copied
+#// or reproduced in whole or in part in any manner or form or in or
+#// on any media by any person other than in accordance with the terms
+#// of the Licence Agreement supplied with the software, or otherwise
+#// without the prior written consent of the copyright owners.
+#//
+#// This software is distributed WITHOUT ANY WARRANTY, without even the
+#// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+#// PURPOSE, except where stated in the Licence Agreement supplied with
+#// the software.
+#//
+#//      Created By :            Michael Boniface
+#//      Created Date :          23/01/2018
+#//      Created for Project :   FLAME
+#//
+#/////////////////////////////////////////////////////////////////////////
+
+# Install ipendpoint
+# This is a dummy script as the endpoint is driven by simulation
\ No newline at end of file
diff --git a/test/services/ipendpoint/telegraf_ipendpoint_template.conf b/test/services/ipendpoint/telegraf_ipendpoint_template.conf
new file mode 100644
index 0000000..32640e1
--- /dev/null
+++ b/test/services/ipendpoint/telegraf_ipendpoint_template.conf
@@ -0,0 +1,112 @@
+# Telegraf configuration
+
+# Telegraf is entirely plugin driven. All metrics are gathered from the
+# declared inputs, and sent to the declared outputs.
+
+# Plugins must be declared in here to be active.
+# To deactivate a plugin, comment out the name and any variables.
+
+# Use 'telegraf -config telegraf.conf -test' to see what metrics a config
+# file would generate.
+
+# Global tags can be specified here in key="value" format.
+[global_tags]
+  # location of the data centre
+  location="{{LOCATION}}"
+  # media service template id
+  sfc="{{SFC_ID}}"
+  # media service instance
+  sfc_i="{{SFC_ID_INSTANCE}}"
+  # service function type
+  sf="{{SF_ID}}"
+  # service function instance id
+  sf_i="{{SF_ID_INSTANCE}}"
+  # ipendpoint id aka surrogate instance
+  ipendpoint="{{IP_ENDPOINT_ID}}"
+
+# Configuration for telegraf agent
+[agent]
+  ## Default data collection interval for all inputs
+  interval = "10s"
+  ## Rounds collection interval to 'interval'
+  ## ie, if interval="10s" then always collect on :00, :10, :20, etc.
+  round_interval = true
+
+  ## Telegraf will cache metric_buffer_limit metrics for each output, and will
+  ## flush this buffer on a successful write.
+  metric_buffer_limit = 1000
+  ## Flush the buffer whenever full, regardless of flush_interval.
+  flush_buffer_when_full = true
+
+  ## Collection jitter is used to jitter the collection by a random amount.
+  ## Each plugin will sleep for a random time within jitter before collecting.
+  ## This can be used to avoid many plugins querying things like sysfs at the
+  ## same time, which can have a measurable effect on the system.
+  collection_jitter = "0s"
+
+  ## Default flushing interval for all outputs. You shouldn't set this below
+  ## interval. Maximum flush_interval will be flush_interval + flush_jitter
+  flush_interval = "10s"
+  ## Jitter the flush interval by a random amount. This is primarily to avoid
+  ## large write spikes for users running a large number of telegraf instances.
+  ## ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s
+  flush_jitter = "0s"
+
+  ## Logging configuration:
+  ## Run telegraf in debug mode
+  debug = false
+  ## Run telegraf in quiet mode
+  quiet = false
+  ## Specify the log file name. The empty string means to log to stdout.
+  logfile = "G:/Telegraf/telegraf.log"
+
+  ## Override default hostname, if empty use os.Hostname()
+  hostname = ""
+
+
+###############################################################################
+#                                  OUTPUTS                                    #
+###############################################################################
+
+# Configuration for influxdb server to send metrics to
+[[outputs.influxdb]]
+  # The full HTTP or UDP endpoint URL for your InfluxDB instance.
+  # Multiple urls can be specified but it is assumed that they are part of the same
+  # cluster, this means that only ONE of the urls will be written to each interval.
+  # urls = ["udp://127.0.0.1:8089"] # UDP endpoint example
+  urls = ["{{INFLUXDB_URL}}"] # required
+  # The target database for metrics (telegraf will create it if not exists)
+  database = "{{DATABASE_NAME}}" # required
+  # Precision of writes, valid values are "ns", "us" (or "µs"), "ms", "s", "m", "h".
+  # note: using second precision greatly helps InfluxDB compression
+  precision = "s"
+
+  ## Write timeout (for the InfluxDB client), formatted as a string.
+  ## If not provided, will default to 5s. 0s means no timeout (not recommended).
+  timeout = "5s"
+  # username = "telegraf"
+  # password = "metricsmetricsmetricsmetrics"
+  # Set the user agent for HTTP POSTs (can be useful for log differentiation)
+  # user_agent = "telegraf"
+  # Set UDP payload size, defaults to InfluxDB UDP Client default (512 bytes)
+  # udp_payload = 512
+
+
+###############################################################################
+#                                  INPUTS                                     #
+###############################################################################
+# # Influx HTTP write listener
+[[inputs.http_listener]]
+  ## Address and port to host HTTP listener on
+  service_address = ":8186"
+
+  ## timeouts
+  read_timeout = "10s"
+  write_timeout = "10s"
+
+  ## HTTPS
+  #tls_cert= "/etc/telegraf/cert.pem"
+  #tls_key = "/etc/telegraf/key.pem"
+
+  ## MTLS
+  #tls_allowed_cacerts = ["/etc/telegraf/clientca.pem"]
\ No newline at end of file
-- 
GitLab