Skip to content

don't reject targets file in start.sh #915

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions scripts/grafana/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ usage() {
echo "Usage: $0 http(s)://target_address:port"
echo
echo "target_address is the hostname or IP address of the system that runs pcm-sensor-server"
echo
echo "Alternative usage: $0 filename"
echo
echo "Specify filename containing http(s)://target_address:port in each line"
echo
exit 1
}

Expand All @@ -31,8 +36,6 @@ if [ "$#" -ne 1 ]; then
usage
fi

validate_url "$1"

mkdir -p grafana_volume/dashboards || { echo "Error creating grafana_volume/dashboards directory"; exit 1; }
mkdir -p influxdb_volume || { echo "Error creating influxdb_volume directory"; exit 1; }

Expand All @@ -48,6 +51,7 @@ if [ -f "$1" ]; then
echo "creating telegraf.conf for hosts in targets file";
head -n -7 "telegraf.conf.template" > telegraf.conf || { echo "Error creating telegraf.conf"; exit 1; }
while IFS='' read -r line || [[ -n "$line" ]]; do
validate_url "$line"
# Split the line at the : character to get the IP and port
ip=$(echo "$line" | cut -d ':' -f 1)
port=$(echo "$line" | cut -d ':' -f 2)
Expand All @@ -59,6 +63,7 @@ if [ -f "$1" ]; then
echo Downloading PCM dashboard
curl -o grafana_volume/dashboards/pcm-dashboard.json $(head -1 "$1")/dashboard || { echo "Error downloading PCM dashboard"; exit 1; }
else
validate_url "$1"
echo "creating telegraf.conf for $1 ";
sed "s#PCMSENSORSERVER#$1#g" telegraf.conf.template > telegraf.conf || { echo "Error creating telegraf.conf"; exit 1; }
echo Downloading PCM dashboard
Expand Down
Loading