Skip to content

Python script that collects BTRFS information for telegraf/InfluxDB

License

Notifications You must be signed in to change notification settings

matthiasstraka/telegraf-btrfs-collector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

telegraf-btrfs-collector

About

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.

What data is collected

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):

  • bytes_used
  • total_bytes
  • disk_total
  • disk_used

Example output

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

Related information

https://godoc.org/github.com/prometheus/procfs/btrfs

Usage

  1. Copy btrfs_collector.py to a location accessible by telegraf. For example /etc/telegraf/btrfs_collector.py.
  2. Update /etc/telegraf/telegraf.conf to call the script:
    [[inputs.exec]]
    commands = [
        "/etc/telegraf/btrfs_collector.py"
        ]
    timeout = "5s"
    data_format = "influx"
  1. Restart the telegraf service (e.g. sudo systemctl restart telegraf.service)

System Requirements

The following list of requirements basically shows the test-system. Older versions of the components are likely supported as well.

  • Linux (tested with Debian 10)
  • Python (tested with version 3.7)
  • BTRFS filesystem (tested with version 4.20.1)
  • telegraf (tested with version 1.14.3)
  • InfluxDB

Contributing

There are many ways to contribute:

  • Fix and report bugs
  • Implement more features
  • Improve the documentation
  • Review the code

About

Python script that collects BTRFS information for telegraf/InfluxDB

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages