collectd-btrfs-exec-plugin
Inspired from https://github.com/soellman/docker-collectd/blob/master/btrfs-data.py.
Installation
$ go get "github.com/flaccid/collectd-btrfs-exec-plugin"
Usage
See exec-btrfs help
. Configure collectd to use the plugin
as per https://collectd.org/wiki/index.php/Plugin:Exec.
Btrfs in Loopback
For testing, you may like to use an image mounted in loopback to save
the need to create a partition and filesystem on a physical disk.
dd if=/dev/zero of=/tmp/btrfs-vol0.img bs=1G count=1
losetup /dev/loop0 /tmp/btrfs-vol0.img
sudo mkfs.btrfs /dev/loop0
mkdir /tmp/btrfs-loop
mount /dev/loop0 /tmp/btrfs-loop
Build
$ go install github.com/flaccid/collectd-btrfs-exec-plugin
Or, build the binary locally within the repository folder:
$ go build exec-btrfs.go
Cross-compiling
Of course, BTRFS is mostly native to Linux, but perhaps you can FUSE or similar.
See https://golang.org/doc/install/source#environment for possibilities.
Mac OS X:
$ GOOS=darwin GOARCH=amd64 go build exec-btrfs.go
Linux:
$ GOOS=linux GOARCH=amd64 go build exec-btrfs.go
Microsoft Windows:
$ GOOS=windows GOARCH=amd64 go build exec-btrfs.go
Additional References
License and Authors
Copyright 2016, Chris Fordham
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.