Last active
June 2, 2020 12:45
-
-
Save RooieRakkert/1da84d28ae75d543508f59248033582d to your computer and use it in GitHub Desktop.
Install Telegraf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Custom script to install Telegraf | |
# telegraf user | |
sudo useradd -s /bin/false telegraf | |
# Create the systemd directory. | |
# | |
# .conf files in this directory will override the default configuration. | |
# You should include such a file in the boot script for a given instance. | |
# | |
# If you decide not to do this the service will be disabled! | |
# | |
# If you don't intend to put something in the directory, | |
# Comment out the line below. | |
sudo mkdir /etc/systemd/system/telegraf.service.d | |
# Before adding Influx repository, run this so that apt will be able to read the repository. | |
until sudo apt-get update -y | |
do | |
sleep 1 | |
echo "apt-get update - trying again..." | |
done | |
until sudo apt-get install -y apt-transport-https | |
do | |
sleep 1 | |
echo "apt-get install apt-transport-https - trying again..." | |
done | |
# Add the InfluxData key | |
wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add - || \ | |
{ echo "Could not add InfluxData key to apt..."; exit 1; } | |
source /etc/os-release | |
test $VERSION_ID = "7" && echo "deb https://repos.influxdata.com/debian wheezy stable" | sudo tee /etc/apt/sources.list.d/influxdb.list | |
test $VERSION_ID = "8" && echo "deb https://repos.influxdata.com/debian jessie stable" | sudo tee /etc/apt/sources.list.d/influxdb.list | |
test $VERSION_ID = "9" && echo "deb https://repos.influxdata.com/debian stretch stable" | sudo tee /etc/apt/sources.list.d/influxdb.list | |
test $VERSION_ID = "10" && echo "deb https://repos.influxdata.com/debian buster stable" | sudo tee /etc/apt/sources.list.d/influxdb.list | |
# Install Telegraf | |
until sudo apt-get update -y | |
do | |
sleep 1 | |
echo "apt-get update - trying again..." | |
done | |
until sudo apt-get install -y telegraf | |
do | |
sleep 1 | |
echo "apt-get installing telegraf - trying again..." | |
done | |
# Give Telegraf permission to acces the docker daemon unix socket | |
sudo usermod -aG docker telegraf | |
# Enable Telegraf | |
sudo systemctl enable telegraf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment