Официалният сайт има инструкции за инсталиране, които работят за Raspberry Pi. Моите са с Raspbian, въпросът е кой от всички… Downloads страницата на Raspberry Pi има детайлите – актуалният е Buster. Значи, трябва ни:
curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
echo "deb https://repos.influxdata.com/debian buster stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
Да проверим какво е станало:
ls /etc/apt/sources.list.d/
В списъка с файлове трябва да има influxdb.list
След това, въпросът е кой е нашият Debian. Според официалната страница, това е версия 10. Значи ни трябват стъпките за версия 8+:
sudo apt update
sudo apt install telegraf
Има две разлики – последната команда, която пуска Telegraf е за след малко (след като нагласим конфигурацията). Другата разлика е, че съм разделил apt-get комнадите (&& ще ги изпълни една след друга ако първата е успешна).
Време за конфигурация, като първо копираме оригиналият файл за всеки случай:
cd /etc/telegraf/
sudo cp telegraf.conf telegraf.conf-originalsudo nano telegraf.conf
Моите настройки са по-долу. Те са една много малка част (сигурно 0.0001%) от възможностите на Telegraf и определено са за домашна употреба. Пример – HTTP вместо HTTPS за връзката към InfluxDB означава, че данните са в чист вид по мрежата, а това е лошо.
Защо тези настройки:
– interval – Нямам нужда мерене на температурата на всеки 10 секунди, това не е нещо което се променя толкова често.
– flush interval – да съвпадне с interval
– jitter- без промяна. Имам 4 Pi-та, на всяко се мерят две неща (температура и натоварване на процесора). Няма смисъл от jitter – няма да има натоварване на самото Pi или голямо количество клиенти които едновременно да пращат данни.
– urls – имам InfluxDB който е на отделна машина (машина е малко силно казано, това всъщност е малък NAS)
– database – мииии, идеята беше да е test, пък то всичко си проработи и така си остана (story of my life)
– user_agent – не съм сигурен, сигурно за стил
Прескачаме много, много, ама наистина много настройки и търсим “INPUT PLUGINS”
– [[inputs.disk]] коментираме ги, поне на мен не ми трябват
interval = "60s"
flush_interval = "60s"
urls = ["http://192.168.1.11:8086"]
database = "k3s-test"
user_agent = "telegraf-pi"
… голямо количество настройки за по-сериозни неща…
Температурата всъщност може да се прочете от “файл”[[inputs.file]]
files = ["/sys/class/thermal/thermal_zone0/temp"]
name_override = "cpu_temperature"
data_format = "value"
data_type = "integer"
Копираме новият ни файл където telegraf го очаква:sudo cp telegraf.conf ./telegraf.d/
Накрая стартираме telegraf:sudo systemctl start telegraf
проверяваме дали всичко е наред – Active полето трябва да е “active (running)” и да няма странни грешки:sudo systemctl status telegraf
И се радваме на новите данни. Синята линия е новото Pi. До сега предните три са изпращали данни, затова и има четири линии.

Крайният резултат
# Global tags can be specified here in key="value" format.
[global_tags]
dc = "bg-sof-01" # will tag all metrics with dc=us-east-1
rack = "pi-01"
# Configuration for telegraf agent
[agent]
## Default data collection interval for all inputs
interval = "60s"
## Rounds collection interval to 'interval'
## ie, if interval="10s" then always collect on :00, :10, :20, etc.
round_interval = true
## Telegraf will send metrics to outputs in batches of at most
## metric_batch_size metrics.
## This controls the size of writes that Telegraf sends to output plugins.
metric_batch_size = 1000
## Maximum number of unwritten metrics per output. Increasing this value
## allows for longer periods of output downtime without dropping metrics at the
## cost of higher maximum memory usage.
metric_buffer_limit = 10000
## Collection jitter is used to jitter the collection by a random amount.
## Each plugin will sleep for a random time within jitter before collecting.
## This can be used to avoid many plugins querying things like sysfs at the
## same time, which can have a measurable effect on the system.
collection_jitter = "0s"
## Default flushing interval for all outputs. Maximum flush_interval will be
## flush_interval + flush_jitter
flush_interval = "60s"
## Jitter the flush interval by a random amount. This is primarily to avoid
## large write spikes for users running a large number of telegraf instances.
## ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s
flush_jitter = "0s"
## By default or when set to "0s", precision will be set to the same
## timestamp order as the collection interval, with the maximum being 1s.
## ie, when interval = "10s", precision will be "1s"
## when interval = "250ms", precision will be "1ms"
## Precision will NOT be used for service inputs. It is up to each individual
## service input to set the timestamp at the appropriate precision.
## Valid time units are "ns", "us" (or "µs"), "ms", "s".
precision = ""
## Override default hostname, if empty use os.Hostname()
hostname = ""
## If set to true, do no set the "host" tag in the telegraf agent.
omit_hostname = false
###############################################################################
# OUTPUT PLUGINS #
###############################################################################
# Configuration for sending metrics to InfluxDB
[[outputs.influxdb]]
## The full HTTP or UDP URL for your InfluxDB instance.
##
## Multiple URLs can be specified for a single cluster, only ONE of the
## urls will be written to each interval.
urls = ["http://192.168.1.11:8086"]
## The target database for metrics; will be created as needed.
## For UDP url endpoint database needs to be configured on server side.
database = "k3s-mon"
## HTTP User-Agent
user_agent = "telegraf-pi"
###############################################################################
# INPUT PLUGINS #
###############################################################################
# Read metrics about cpu usage
[[inputs.cpu]]
## Whether to report per-cpu stats or not
percpu = true
## Whether to report total system cpu stats or not
totalcpu = true
## If true, collect raw CPU time metrics.
collect_cpu_time = false
## If true, compute and report the sum of all non-idle CPU states.
report_active = false
# Read metrics about disk usage by mount point
[[inputs.disk]]
## By default stats will be gathered for all mount points.
## Set mount_points will restrict the stats to only the specified mount points.
mount_points = ["/"]
## Ignore mount points by filesystem type.
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
# Read metrics about memory usage
[[inputs.mem]]
# no configuration
[[inputs.file]]
files = ["/sys/class/thermal/thermal_zone0/temp"]
name_override = "cpu_temperature"
data_format = "value"
data_type = "integer"