btrfs-progs: Add a basic monitoring script.
Subsystems (3)
PATCH 1/1 btrfs-progs: Add a basic monitoring script.
This adds a minimalistic Python 3 based monitoring script to the standard tools called btrfs-status. The script itself depends only on a working Python 3 installation, the btrfs command, and a regular blkid command (the version of blkid in Busybox may not work, currently untested).
When called, btrfs-status runs some really basic monitoring checks on the filesystems passed to it, and then exits 0 if they all passed, 1 if any failed, or 2 if there was an internal error performing the checks. If any checks fail, a message regarding that check will be printed to stdout.
In order, it checks:
1. That each filesystem it is passed is not mounted degraded (done by parsing the contents of /proc/self/mountinfo).
2. That device error counters for each filesystem are all zero (done by calling out to btrfs device stats --check).
3. That chunk-level allocations aren't getting dangerously close to full (done by parsing data from /sys/fs/btrfs).
btrfs-status is intended to simplify automation of basic monitoring. It can be run as part of a systemd timer unit, as a cron job (in which case you only get mail if something is wrong), or even just as a basic check run by other monitoring software that doesn't natively support BTRFS.
This is _NOT_ intended to be a final monitoring solution, it's supposed to be a stop-gap until we have something better. There are a lot of problems it won't catch (device failures for one), and the chunk allocation check is unreliable in some cases (for example, three device raid1 volumes with three different sized devices).
---
Sorry about the duplicate David, I screwed up the ML address on the first one...
This ended up being ready sooner than I anticipated. I've been working on it for a couple of weeks now and testing the checks as I go. The last extant issue I had was related to trying to figure out the UUID of a volume reliably, but that's gone since I just switched to calling out to blkid -o value -s UUID instead of trying to look it up directly from Python.
I've included a rudimentary man page and added btrfs-status to the default install list, but if desired I can update the patch to just add it to the source tree.
Documentation/Makefile.in | 1 + Documentation/btrfs-status.asciidoc | 56 +++++++++ Makefile | 2 +- btrfs-status | 225 ++++++++++++++++++++++++++++++++++++ 4 files changed, 283 insertions(+), 1 deletion(-) create mode 100644 Documentation/btrfs-status.asciidoc create mode 100755 btrfs-status
Documentation/Makefile.in +1 -0
@@ -11,6 +11,7 @@ MAN8_TXT += btrfs-select-super.asciidoc MAN8_TXT += btrfstune.asciidoc MAN8_TXT += fsck.btrfs.asciidoc MAN8_TXT += mkfs.btrfs.asciidoc +MAN8_TXT += btrfs-status.asciidoc # Sub commands for btrfs MAN8_TXT += btrfs-subvolume.asciidoc
Documentation/btrfs-status.asciidoc new file +56 -0
56 lines not on this page · raw message
Makefile +1 -1
@@ -194,7 +194,7 @@ progs = $(progs_install) btrfsck btrfs-corrupt-block progs_install = btrfs mkfs.btrfs btrfs-debug-tree \ btrfs-map-logical btrfs-image btrfs-zero-log \ btrfs-find-root btrfstune \ - btrfs-select-super + btrfs-select-super btrfs-status # other tools, not built by default progs_extra = btrfs-fragments btrfs-calc-size btrfs-show-super
btrfs-status new file +225 -0
225 lines not on this page · raw message
Signature · 1 line
2.16.2