项目作者: matthiasstraka

项目描述 :
Python script that collects BTRFS information for telegraf/InfluxDB
高级语言: Python
项目地址: git://github.com/matthiasstraka/telegraf-btrfs-collector.git
创建时间: 2020-05-26T08:37:02Z
项目社区:https://github.com/matthiasstraka/telegraf-btrfs-collector

开源协议:GNU General Public License v3.0

下载


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

  1. btrfs,uuid=25c1fbee-f3ef-4b71-a925-55b8e7667968,label=DATA,profile=single,type=globalreserve total_bytes=536870912i
  2. 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
  3. 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
  4. 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

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:
  1. [[inputs.exec]]
  2. commands = [
  3. "/etc/telegraf/btrfs_collector.py"
  4. ]
  5. timeout = "5s"
  6. 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