diff --git a/scripts/clmc-agent/configure_template.sh b/scripts/clmc-agent/configure_template.sh new file mode 100644 index 0000000000000000000000000000000000000000..04d1229646e57e5d8415ea9addcae315141ca671 --- /dev/null +++ b/scripts/clmc-agent/configure_template.sh @@ -0,0 +1,79 @@ +#!/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 : 19/03/2018 +#// Created for Project : FLAME +#// +#///////////////////////////////////////////////////////////////////////// + +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" + +echo "Checking Telegraf installation" + +# Check the target telegraf directory exists +if [ ! -d "$TELEGRAF_CONF_DIR" ]; then + echo "Error: Telegraf conf directory does not exist on target machine. Check that telegraf is installed "$TELEGRAF_CONF_DIR + exit 1 +fi + +# Check the target telegraf directory exists +if [ ! -d $TELEGRAF_INCLUDE_CONF_DIR ]; then + echo "Error: Telegraf conf include directory does not exist on target machine. Check that telegraf is installed "$TELEGRAF_INCLUDE_CONF_DIR + exit 1 +fi + +# Copy configuration +echo "Telegraf general config file: " $TELEGRAF_CONF_FILE +(cat <<'EOF' +[global_tags] + location="$LOCATION" + sfc="$SFC_ID" + sfc_i="$SFC_ID_INSTANCE" + sf="$SF_ID" + sf_i="$SF_ID_INSTANCE" + ipendpoint="$IP_ENDPOINT_ID" +[agent] + interval = "10s" + round_interval = true + metric_buffer_limit = 1000 + flush_buffer_when_full = true + collection_jitter = "0s" + flush_interval = "10s" + flush_jitter = "0s" + debug = false + quiet = false + logfile = "/var/log/telegraf/telegraf.log" + hostname = "" +EOF +) > $TELEGRAF_CONF_FILE + +echo "Telegraf output config file: " $TELEGRAF_OUTPUT_CONF_FILE +(cat <<'EOF' +[[outputs.influxdb]] + urls = ["$INFLUXDB_URL"] + database = "$DATABASE_NAME" + precision = "s" + timeout = "5s" +EOF +) > $TELEGRAF_OUTPUT_CONF_FILE