##安装步骤
apt install curl -y
curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
source /etc/lsb-release
echo "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt-get update && sudo apt-get install telegraf -y
##hostname 名字看自己主机名字,会写入influx 作为一个key值
sed -i 's/hostname = ""/hostname = "xxx"/g' /etc/telegraf/telegraf.conf
##usrs对应写对应influx服务器的地址,8086是influx的端口号
sed -i 's/\# urls = \[\"http\:\/\/127\.0\.0\.1\:8086\"\]/urls = \[\"http\:xxxx:8086\"\]/g' /etc/telegraf/telegraf.conf
##databases可以指定数据库名,默认是telegraf
sed -i 's/\# database = \"telegraf\"/database = \"xxx\"/g' /etc/telegraf/telegraf.conf
##启动端口和网络监控
sed -i 's/\# \[\[inputs\.net\]\]/\[\[inputs.net\]\]/g' /etc/telegraf/telegraf.conf
sed -i 's/\# \[\[inputs\.netstat\]\]/\[\[inputs\.netstat\]\]/g' /etc/telegraf/telegraf.conf
##安装修改完配置文件,需要重启
service telegraf restart