4.5 KiB
telegraf-bcachefs-input
Telegraf bcachefs monitoring
Installation
Run once from the checkout:
sudo ./install.sh
This links /etc/telegraf/bcachefs*.sh to this checkout. Existing files are
preserved in a printed /etc/telegraf/bcachefs-backup.* directory. Re-running
is safe; unchanged links are skipped. You can pass a different destination
directory as the first argument. Keep the checkout at the same path and readable
and executable by the Telegraf service. Edits take effect on the next collection;
no copy or service restart is needed. To roll back, replace the links with the
files in the backup directory (remove any newly installed links separately).
On the original host, Telegraf runs as root with ProtectHome=no. Thus edits
here become code executed as root. On another host, check service permissions
and sandbox settings before installing into a home directory.
The original host loads its configuration from InfluxDB using TELEGRAF_OPTS
and INFLUX_TOKEN in /etc/default/telegraf. Keep these credentials outside Git.
The existing hosted commands can remain unchanged with this installation;
a new systemd environment variable is unnecessary.
Collectors
The scripts retain the deployed host's /mnt mount point and, in several cases,
its filesystem UUID. Adapt those values before using them on another host.
bcachefs_reconcile.sh already accepts FSPATH (or a positional mount path) and
BCACHEFS_UUID overrides.
bcachefs.sh: filesystem usage; imported version selects usage sections explicitly.bcachefs_fs_top.sh: parses the collector's/fs_topendpoint (/sformat).bcachefs_options.sh: sysfs options.bcachefs_perf.sh: collector's/perf_jsonendpoint.bcachefs_reconcile.sh: reconcile status.bcachefs_snapshot_delete_status.sh: snapshot deletion progress.bcachefs_time_stats.sh: sysfs time statistics.bcachefs_timestats.sh: JSON time statistics from bcachefs-tools; different measurement/schema.bcachefs_device_time_stats.sh: compatibility symlink tobcachefs_time_stats.sh; the old workspace file was identical and did not collect extra device metrics. Do not configure both aliases, as that would duplicate collection.
The old _not_finished human-readable prototype was removed; Git retains its
history. _not_maintained_anymore remains as an archive.
Add the desired inputs to your Telegraf TOML configuration (local or hosted):
[[inputs.exec]]
commands = ["/etc/telegraf/bcachefs.sh"]
data_format = "influx"
[[inputs.exec]]
commands = ["/etc/telegraf/bcachefs_fs_top.sh"]
data_format = "influx"
[[inputs.exec]]
commands = ["/etc/telegraf/bcachefs_options.sh"]
data_format = "influx"
[[inputs.exec]]
commands = ["/etc/telegraf/bcachefs_perf.sh"]
data_format = "influx"
[[inputs.exec]]
commands = ["/etc/telegraf/bcachefs_time_stats.sh"]
data_format = "influx"
Support reports and pastes
Run ./kent_report.sh from the directory where you want kent_report.log and
trace output saved. It performs the existing lengthy diagnostics and uploads
the report to the paste server, printing a URL for manually sharing on IRC.
It does not send an IRC message. The diagnostics retain the original host's
Arch packages, bcachefs source checkout, device and encryption-file paths;
review those and the collected information before running on another host.
paste_log.sh contains the shared function and can also be run directly:
./paste_log.sh path/to/log
To make paste_log available in interactive Bash, add:
source "$HOME/telegraf-bcachefs-input/paste_log.sh"
kent_report.sh sources the same file relative to its own location; it does not
rely on interactive shell functions being exported. Uploads use the current
kubectl context/namespace and require exactly one pod named brunner-ninja*.
Failed uploads return an error without printing a misleading URL. Temporary
name reservations are cleaned up, and function errors do not exit your shell.
Building the performance collector
Requires Qt 6 Core, Network, WebSockets and HttpServer development packages:
mkdir -p /tmp/bcachefs-collector-build
cd /tmp/bcachefs-collector-build
qmake6 /path/to/telegraf-bcachefs-input/perf-collector/perf-collector.pro
make
The collector listens on localhost:8000 and launches bcachefs fs top /mnt
and sudo perf trace. Building does not deploy or restart it.


