From 3e5e911d1ed5ac0be2e043ddad54cfdc3c3d3294 Mon Sep 17 00:00:00 2001
From: MJB <mjb@it-innovation.soton.ac.uk>
Date: Mon, 12 Feb 2018 16:37:10 +0000
Subject: [PATCH] added VLC scripts

---
 Vagrantfile                                   |   9 +-
 infra/streaming/rspec.yml                     |  17 +++
 test/services/apache/install-apache.sh        |  14 ++-
 .../ffmpeg/telegraf_ffmpeg_template.conf      |   2 +-
 test/services/ffmpeg/transcode.sh             |  17 +--
 .../telegraf_ipendpoint_template.conf         |   2 +-
 .../mongo/telegraf_mongo_template.conf        |   2 +-
 test/services/vlc/install-vlc.sh              |  29 +++++
 test/services/vlc/telegraf_vlc_template.conf  | 112 ++++++++++++++++++
 9 files changed, 186 insertions(+), 18 deletions(-)
 create mode 100644 test/services/vlc/install-vlc.sh
 create mode 100644 test/services/vlc/telegraf_vlc_template.conf

diff --git a/Vagrantfile b/Vagrantfile
index a7803b0..a76275d 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -91,13 +91,12 @@ Vagrant.configure("2") do |config|
           instance_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"
-          puts "installing service script: #{service_install_path}"
-          instance_config.vm.provision :shell, :path => service_install_path      
-          # agent install
+          instance_config.vm.provision :shell, :path => "test/services/#{host["service_name"]}/install-#{host["service_name"]}.sh"     
+          # CLMC agent install
           instance_config.vm.provision :shell, :path => "scripts/clmc-agent/install-clmc-agent.sh", :args => "/vagrant/test/services/#{host["service_name"]}/telegraf_#{host["service_name"]}_template.conf #{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"]}"
-
       end
+
+      
 	  end
   end
  
diff --git a/infra/streaming/rspec.yml b/infra/streaming/rspec.yml
index c07478d..752d41a 100644
--- a/infra/streaming/rspec.yml
+++ b/infra/streaming/rspec.yml
@@ -30,3 +30,20 @@ hosts:
     ipendpoint_id: "adaptive_streaming_I1_apache1"
     influxdb_url: "http://192.168.50.10:8086"
     database_name: "CLMCMetrics"
+  - name: vlc-client
+    cpus: 1
+    memory: 2048
+    disk: "10GB"
+    service_name: "vlc"
+    forward_ports:
+      - guest: 81
+        host: 8082
+    ip_address: "192.168.50.12"
+    location: "DC1"
+    sfc_id: "MS_Template_1"
+    sfc_id_instance: "MS_I1"
+    sf_id: "adaptive_streaming_client"
+    sf_id_instance: "adaptive_streaming_I1"
+    ipendpoint_id: "adaptive_streaming_I1_client1"
+    influxdb_url: "http://192.168.50.10:8086"
+    database_name: "CLMCMetrics"    
diff --git a/test/services/apache/install-apache.sh b/test/services/apache/install-apache.sh
index 9bb529d..8ae0181 100644
--- a/test/services/apache/install-apache.sh
+++ b/test/services/apache/install-apache.sh
@@ -26,11 +26,19 @@
 
 # Install apache
 sudo apt-get update
-sudo apt-get -y install apache2 zip
+sudo apt-get -y install apache2
+
+TEST_VIDEO="20180212104221flame-project-full.mp4"
+TEST_VIDEO_ARCHIVE=$TEST_VIDEO".gz"
+DEST_DIR="/var/www/html/" 
+DEST_FILE=$DEST_DIR"/"$TEST_VIDEO_ARCHIVE
 
 # Copy files for MPEG-DASH testing
-curl "ftp://ftp.it-innovation.soton.ac.uk/testdata/video/20180210-flame-project-video.zip" --user flame-rw:DR8ngj3ogSjd8gl -o "/var/www/html/20180210-flame-project-video.zip"
-unzip /var/www/html/20180210-flame-project-video.zip -d /var/www/html/
+curl "ftp://ftp.it-innovation.soton.ac.uk/testdata/video/"$TEST_VIDEO_ARCHIVE --user flame-rw:DR8ngj3ogSjd8gl -o $DEST_FILE
+tar -xvf $DEST_FILE -C /var/www/html/
+
+rm -rf $DEST_FILE
+mv $DEST_DIR"/"$TEST_VIDEO $DEST_DIR"/"test_video
 
 # start apache
 apachectl -k start
diff --git a/test/services/ffmpeg/telegraf_ffmpeg_template.conf b/test/services/ffmpeg/telegraf_ffmpeg_template.conf
index 32640e1..3e30465 100644
--- a/test/services/ffmpeg/telegraf_ffmpeg_template.conf
+++ b/test/services/ffmpeg/telegraf_ffmpeg_template.conf
@@ -58,7 +58,7 @@
   ## 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"
+  logfile = "/var/log/telegraf/telegraf.log"
 
   ## Override default hostname, if empty use os.Hostname()
   hostname = ""
diff --git a/test/services/ffmpeg/transcode.sh b/test/services/ffmpeg/transcode.sh
index 929952e..877472b 100644
--- a/test/services/ffmpeg/transcode.sh
+++ b/test/services/ffmpeg/transcode.sh
@@ -12,20 +12,23 @@ INPUT=$1
 OUTPUT_iFRAMES="$1-iFrames.mp4"
 OUTPUT_FRAGMENTED="$OUTPUT_iFRAMES-Fragmented.mp4"
 
-rm -rf output
+OUTPUT_FOLDER_NAME=$(date +%Y%m%d%H%M%S)$1
+echo "OUTPUT_FOLDER_NAME: "$OUTPUT_FOLDER_NAME
+
+rm -rf $OUTPUT_FOLDER_NAME
+mkdir $OUTPUT_FOLDER_NAME
 
 # Insert Correct number of I frames
 #ffmpeg -y -i $INPUT -profile:v baseline -level 3.0 -c:a libfdk_aac -ac 2 -ab 128k -c:v libx264 -x264opts 'keyint=24:min-keyint=24:no-scenecut' -b:v 400k -maxrate 400k -bufsize 1000k -vf "scale=-1:360" $OUTPUT_iFRAMES
 
-ffmpeg -y -i $INPUT -profile:v baseline -level 3.0 -c:a aac -ac 2 -ab 128k -c:v libx264 -x264opts 'keyint=24:min-keyint=24:no-scenecut' -b:v 400k -maxrate 400k -bufsize 1000k -vf "scale=-1:360" -strict experimental $OUTPUT_iFRAMES
+ffmpeg -y -i $INPUT -profile:v baseline -level 3.0 -c:a aac -ac 2 -ab 128k -c:v libx264 -x264opts 'keyint=24:min-keyint=24:no-scenecut' -b:v 400k -maxrate 400k -bufsize 1000k -vf "scale=-1:360" -strict experimental $OUTPUT_FOLDER_NAME"/"$OUTPUT_iFRAMES
 
 # fragment MP4
-/opt/Bento4-SDK-1-5-1-621.x86_64-unknown-linux/bin/mp4fragment --timescale 1000 $OUTPUT_iFRAMES $OUTPUT_FRAGMENTED
+/opt/Bento4-SDK-1-5-1-621.x86_64-unknown-linux/bin/mp4fragment --timescale 1000 $OUTPUT_FOLDER_NAME"/"$OUTPUT_iFRAMES $OUTPUT_FOLDER_NAME"/"$OUTPUT_FRAGMENTED
 
 # Option 1 with Bento4
-/opt/Bento4-SDK-1-5-1-621.x86_64-unknown-linux/bin/mp4dash --mpd-name=stream.mpd --use-segment-list --use-compat-namespace $OUTPUT_FRAGMENTED 
+/opt/Bento4-SDK-1-5-1-621.x86_64-unknown-linux/bin/mp4dash --mpd-name=stream.mpd --use-segment-list --use-compat-namespace -o $OUTPUT_FOLDER_NAME"/"$OUTPUT_FOLDER_NAME $OUTPUT_FOLDER_NAME"/"$OUTPUT_FRAGMENTED 
 
-# not sure what this is for
-mv output/audio/en/mp4a/* output/audio/en
+cd $OUTPUT_FOLDER_NAME
+tar -cvzf $OUTPUT_FOLDER_NAME".gz" $OUTPUT_FOLDER_NAME
 
-rm -rf output/audio/en/mp4
diff --git a/test/services/ipendpoint/telegraf_ipendpoint_template.conf b/test/services/ipendpoint/telegraf_ipendpoint_template.conf
index 32640e1..3e30465 100644
--- a/test/services/ipendpoint/telegraf_ipendpoint_template.conf
+++ b/test/services/ipendpoint/telegraf_ipendpoint_template.conf
@@ -58,7 +58,7 @@
   ## 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"
+  logfile = "/var/log/telegraf/telegraf.log"
 
   ## Override default hostname, if empty use os.Hostname()
   hostname = ""
diff --git a/test/services/mongo/telegraf_mongo_template.conf b/test/services/mongo/telegraf_mongo_template.conf
index e65c22f..f28b234 100644
--- a/test/services/mongo/telegraf_mongo_template.conf
+++ b/test/services/mongo/telegraf_mongo_template.conf
@@ -58,7 +58,7 @@
   ## 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"
+  logfile = "/var/log/telegraf/telegraf.log"
 
   ## Override default hostname, if empty use os.Hostname()
   hostname = ""
diff --git a/test/services/vlc/install-vlc.sh b/test/services/vlc/install-vlc.sh
new file mode 100644
index 0000000..149406d
--- /dev/null
+++ b/test/services/vlc/install-vlc.sh
@@ -0,0 +1,29 @@
+#!/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 :          12/02/2018
+#//      Created for Project :   FLAME
+#//
+#/////////////////////////////////////////////////////////////////////////
+
+sudo add-apt-repository ppa:videolan/master-daily
+sudo apt-get update
+apt-get -y install vlc
\ No newline at end of file
diff --git a/test/services/vlc/telegraf_vlc_template.conf b/test/services/vlc/telegraf_vlc_template.conf
new file mode 100644
index 0000000..3e30465
--- /dev/null
+++ b/test/services/vlc/telegraf_vlc_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 = "/var/log/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