From 464ce45414c782773350f0f47b0899a474482984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Otterstr=C3=B6m?= Date: Tue, 31 Mar 2020 10:24:58 +0200 Subject: [PATCH] Make ccm helper script more generic --- ..._for_test.sh => generate-cert-for-test.sh} | 0 bin/install-ccm.sh | 32 +++++++++++++++++++ install-ccm.sh | 12 ------- 3 files changed, 32 insertions(+), 12 deletions(-) rename bin/{generate_cert_for_test.sh => generate-cert-for-test.sh} (100%) create mode 100755 bin/install-ccm.sh delete mode 100755 install-ccm.sh diff --git a/bin/generate_cert_for_test.sh b/bin/generate-cert-for-test.sh similarity index 100% rename from bin/generate_cert_for_test.sh rename to bin/generate-cert-for-test.sh diff --git a/bin/install-ccm.sh b/bin/install-ccm.sh new file mode 100755 index 0000000..5a64e4d --- /dev/null +++ b/bin/install-ccm.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +shopt -s extglob + +SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" +CCM_CONFIG=${CCM_CONFIG_DIR:=~/.ccm} +JAR_FILE=$(eval echo "${SCRIPT_PATH}/../agent/target/cassandra-exporter-agent-*.jar") + +if [ ! -f ${CCM_CONFIG}/CURRENT ]; then + echo "Unable to find an active ccm cluster" + exit 2 +fi + +if [ ! -f ${JAR_FILE} ]; then + echo "No jar file found. Build project and try again." + exit 3 +fi + +CCM_CLUSTER_NAME=`cat ${CCM_CONFIG}/CURRENT` +echo "Installing cassandra-exporter into ${CCM_CLUSTER_NAME}" + +CLUSTER_PATH=${CCM_CONFIG}/${CCM_CLUSTER_NAME} + +find ${CLUSTER_PATH} -path '*/node*/conf/cassandra-env.sh' | while read file; do + node=$(echo ${file} | sed 's/[^0-9]*//g') + port=$((19499+${node})) + + echo " http://127.0.0.${node}:${port}/metrics" + sed -i -e "/cassandra-exporter/d" "${file}" + + echo "JVM_OPTS=\"\$JVM_OPTS -javaagent:${JAR_FILE}=--listen=:${port},--enable-collector-timing\"" >> "${file}" +done; diff --git a/install-ccm.sh b/install-ccm.sh deleted file mode 100755 index a86c7fc..0000000 --- a/install-ccm.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -find . -path '*/node*/conf/cassandra-env.sh' | while read file; do - echo "Processing $file" - - port=$((19499+$(echo ${file} | sed 's/[^0-9]*//g'))) - - sed -i -e "/cassandra-exporter/d" "${file}" - - echo "JVM_OPTS=\"\$JVM_OPTS -javaagent:/home/adam/Projects/cassandra-exporter/agent/target/cassandra-exporter-agent-0.9.4-SNAPSHOT.jar=--listen=:${port},--cache=true,--enable-collector-timing\"" >> \ - "${file}" -done; \ No newline at end of file