From df5f351ac879409fb25b580f8ec47a17bedc2cb3 Mon Sep 17 00:00:00 2001 From: Simon Crowle <sgc@it-innovation.soton.ac.uk> Date: Wed, 3 Jan 2018 16:42:53 +0000 Subject: [PATCH] Decouples InfluxTICK stack installation and configuration --- Vagrantfile | 106 +++++++++++--------- scripts/influx/configure-tick-stack-vm.sh | 34 +++++++ scripts/influx/install-tick-stack-vm.sh | 9 +- scripts/influx/start-tick-stack-services.sh | 35 +++++++ scripts/influx/telegraf.conf | 103 +++++++++++++++++++ 5 files changed, 233 insertions(+), 54 deletions(-) create mode 100644 scripts/influx/configure-tick-stack-vm.sh create mode 100644 scripts/influx/start-tick-stack-services.sh create mode 100644 scripts/influx/telegraf.conf diff --git a/Vagrantfile b/Vagrantfile index c8326ad..4c66d3b 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,46 +1,60 @@ -#///////////////////////////////////////////////////////////////////////// -#// -#// (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 : 13/12/2017 -#// Created for Project : FLAME -#// -#///////////////////////////////////////////////////////////////////////// - -Vagrant.configure("2") do |config| - config.vm.box = "ubuntu/xenial64" - - config.vm.define "influx" do |my| - my.vm.provider "virtualbox" do |v| - v.customize ["modifyvm", :id, "--memory", 2048] - v.customize ["modifyvm", :id, "--cpus", 1] - end - - # open InfluxDB port - config.vm.network "forwarded_port", guest: 8086, host: 8086 - - # open Chronograf port - config.vm.network "forwarded_port", guest: 8888, host: 8888 - - # open TICK Kapacitor port - config.vm.network "forwarded_port", guest: 9092, host: 9092 - - config.vm.provision :shell, :path => 'scripts/influx/install-tick-stack-vm.sh' - end -end +#///////////////////////////////////////////////////////////////////////// +#// +#// (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 : 13/12/2017 +#// Created for Project : FLAME +#// +#///////////////////////////////////////////////////////////////////////// + +Vagrant.configure("2") do |config| + config.vm.box = "ubuntu/xenial64" + + config.vm.define "influx" do |my| + my.vm.provider "virtualbox" do |v| + v.customize ["modifyvm", :id, "--memory", 2048] + v.customize ["modifyvm", :id, "--cpus", 1] + end + + # copy resource files into VM + config.vm.provision "file", source: "./scripts/influx/telegraf.conf", destination: "$HOME/config/telegraf/telegraf.conf" + + # open InfluxDB port + config.vm.network "forwarded_port", guest: 8086, host: 8086 + + # open Chronograf port + config.vm.network "forwarded_port", guest: 8888, host: 8888 + + # open TICK Kapacitor port + config.vm.network "forwarded_port", guest: 9092, host: 9092 + + # open local Telegraf port + config.vm.network "forwarded_port", guest: 8186, host: 8186 + + # install the TICK stack + config.vm.provision :shell, :path => 'scripts/influx/install-tick-stack-vm.sh' + + # configure the TICK stack + config.vm.provision :shell, :path => 'scripts/influx/configure-tick-stack-vm.sh' + + # start the TICK stack + config.vm.provision :shell, :path => 'scripts/influx/start-tick-stack-services.sh' + + end +end diff --git a/scripts/influx/configure-tick-stack-vm.sh b/scripts/influx/configure-tick-stack-vm.sh new file mode 100644 index 0000000..433e036 --- /dev/null +++ b/scripts/influx/configure-tick-stack-vm.sh @@ -0,0 +1,34 @@ +#!/bin/bash +#///////////////////////////////////////////////////////////////////////// +#// +#// (c) University of Southampton IT Innovation Centre, 2018 +#// +#// 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 : Simon Crowle +#// Created Date : 03/11/2018 +#// Created for Project : FLAME +#// +#///////////////////////////////////////////////////////////////////////// + +echo Configuring TICK stack services... + +# Configure Telegraf +systemctl stop telegraf + +cp ./config/telegraf/telegraf.conf /etc/telegraf/ + +systemctl start telegraf \ No newline at end of file diff --git a/scripts/influx/install-tick-stack-vm.sh b/scripts/influx/install-tick-stack-vm.sh index 370b4ff..0a49031 100644 --- a/scripts/influx/install-tick-stack-vm.sh +++ b/scripts/influx/install-tick-stack-vm.sh @@ -27,22 +27,15 @@ # install influx wget https://dl.influxdata.com/influxdb/releases/influxdb_1.2.4_amd64.deb dpkg -i influxdb_1.2.4_amd64.deb -systemctl start influxdb # install kapacitor wget https://dl.influxdata.com/kapacitor/releases/kapacitor_1.3.1_amd64.deb dpkg -i kapacitor_1.3.1_amd64.deb -systemctl start kapacitor # install Telegraf wget https://dl.influxdata.com/telegraf/releases/telegraf_1.3.2-1_amd64.deb dpkg -i telegraf_1.3.2-1_amd64.deb -systemctl start telegraf # install Chronograf wget https://dl.influxdata.com/chronograf/releases/chronograf_1.3.3.0_amd64.deb -dpkg -i chronograf_1.3.3.0_amd64.deb -systemctl start chronograf - -# test influx -#curl "http://localhost:8086/query?q=show+databases" \ No newline at end of file +dpkg -i chronograf_1.3.3.0_amd64.deb \ No newline at end of file diff --git a/scripts/influx/start-tick-stack-services.sh b/scripts/influx/start-tick-stack-services.sh new file mode 100644 index 0000000..ce453d4 --- /dev/null +++ b/scripts/influx/start-tick-stack-services.sh @@ -0,0 +1,35 @@ +#!/bin/bash +#///////////////////////////////////////////////////////////////////////// +#// +#// (c) University of Southampton IT Innovation Centre, 2018 +#// +#// 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 : Simon Crowle +#// Created Date : 03/11/2018 +#// Created for Project : FLAME +#// +#///////////////////////////////////////////////////////////////////////// + +echo Starting TICK stack services... + +systemctl start influxdb +systemctl start kapacitor +systemctl start telegraf +systemctl start chronograf + +# test influx +#curl "http://localhost:8086/query?q=show+databases" \ No newline at end of file diff --git a/scripts/influx/telegraf.conf b/scripts/influx/telegraf.conf new file mode 100644 index 0000000..abeb11e --- /dev/null +++ b/scripts/influx/telegraf.conf @@ -0,0 +1,103 @@ +# 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] + # dc = "us-east-1" # will tag all metrics with dc=us-east-1 + # rack = "1a" + +# 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 = ["http://localhost:8086"] # required + # The target database for metrics (telegraf will create it if not exists) + database = "CLMCMetrics" # 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