Python script that collects BTRFS information for telegraf/InfluxDB
Telegraf is an open-source collector for various metrics.
These metrics are usually stored in an Influx database.
So far, there is no explicit support for BTRFS filesystems.
Only generic data can be collected by the disk
plugin.
This Python script collects data about BTRFS from a linux system by reading information from /sys/fs/btrfs/
.
It does not require root
rights to do so (and can be run directly from the telegraf service).
The output consists of data items in Influx Line Protocol format, which can be directly used to insert the data into influx databases.
Currently, we evaluate only allocation specific data.
This is similar to what can be queried by btrfs filesystem df /mnt
.
Colleting more non-root-accessible data is planned.
The following data items are collected for each allocation type (data, metadata, system):
btrfs,uuid=25c1fbee-f3ef-4b71-a925-55b8e7667968,label=DATA,profile=single,type=globalreserve total_bytes=536870912i
btrfs,uuid=25c1fbee-f3ef-4b71-a925-55b8e7667968,label=DATA,profile=raid1,type=data bytes_used=721085935616i,total_bytes=795642691584i,disk_total=1591285383168i,disk_used=1442171871232i
btrfs,uuid=25c1fbee-f3ef-4b71-a925-55b8e7667968,label=DATA,profile=raid1,type=metadata bytes_used=1041514496i,total_bytes=2147483648i,disk_total=4294967296i,disk_used=2083028992i
btrfs,uuid=25c1fbee-f3ef-4b71-a925-55b8e7667968,label=DATA,profile=raid1,type=system bytes_used=147456i,total_bytes=67108864i,disk_total=134217728i,disk_used=294912i
https://godoc.org/github.com/prometheus/procfs/btrfs
btrfs_collector.py
to a location accessible by telegraf. For example /etc/telegraf/btrfs_collector.py
./etc/telegraf/telegraf.conf
to call the script:
[[inputs.exec]]
commands = [
"/etc/telegraf/btrfs_collector.py"
]
timeout = "5s"
data_format = "influx"
sudo systemctl restart telegraf.service
)The following list of requirements basically shows the test-system.
Older versions of the components are likely supported as well.
There are many ways to contribute: