From: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
To: Stefan Malte Schumacher <stefan.m.schumacher@gmail.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: Monitoring Btrfs
Date: Mon, 17 Oct 2016 13:41:03 -0400 [thread overview]
Message-ID: <20161017174103.GC21290@hungrycats.org> (raw)
In-Reply-To: <CAA3ktqmhhasyk8L+W3jz9ifYw7UMoL4ueg1HQp7Co3L39xYe9Q@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2539 bytes --]
On Mon, Oct 17, 2016 at 06:44:14PM +0200, Stefan Malte Schumacher wrote:
> Hello
>
> I would like to monitor my btrfs-filesystem for missing drives. On
> Debian mdadm uses a script in /etc/cron.daily, which calls mdadm and
> sends an email if anything is wrong with the array. I would like to do
> the same with btrfs. In my first attempt I grepped and cut the
> information from "btrfs fi show" and let the script send an email if
> the number of devices was not equal to the preselected number.
>
> Then I saw this:
>
> ubuntu@ubuntu:~$ sudo btrfs filesystem show
> Label: none uuid: 67b4821f-16e0-436d-b521-e4ab2c7d3ab7
> Total devices 6 FS bytes used 5.47TiB
> devid 1 size 1.81TiB used 1.71TiB path /dev/sda3
> devid 2 size 1.81TiB used 1.71TiB path /dev/sdb3
> devid 3 size 1.82TiB used 1.72TiB path /dev/sdc1
> devid 4 size 1.82TiB used 1.72TiB path /dev/sdd1
> devid 5 size 2.73TiB used 2.62TiB path /dev/sde1
> *** Some devices missing
>
> on this page: https://btrfs.wiki.kernel.org/index.php/Using_Btrfs_with_Multiple_Devices
> The number of devices is still at 6, despite the fact that one of the
> drives is missing, which means that my first idea doesnt work.
Using fi show for this isn't a good idea. By the time btrfs fi show
tells you something is different from the norm, you've probably already
crashed at least once and are now mounting with the 'degraded' option.
> I have
> two questions:
> 1) Has anybody already written a script like this? After all, there is
> no need to reinvent the wheel a second time.
> 2) What should I best grep for? In this case I would just go for the
> "missing". Does this cover all possible outputs of btrfs fi show in
> case of a damaged array? What other outputs do I need to consider for
> my script.
I monitor the device error counters, i.e. the output of
for fs in /fs1 /fs2 /fs3... ; do
btrfs dev stat "$fs" | grep -v " 0$"
done
and send an email when it isn't empty.
When there are errors I investigate in more detail (is it a failing disk?
failed disk? bad cables? bad RAM? One-off UNC sector that can be
ignored?), fix any problems (i.e. replace hardware, run scrub), and
reset the counters to zero with 'btrfs dev stat -z'.
> Yours sincerely
> Stefan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
next prev parent reply other threads:[~2016-10-17 17:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-17 16:44 Monitoring Btrfs Stefan Malte Schumacher
2016-10-17 17:23 ` Austin S. Hemmelgarn
2016-10-18 3:23 ` Anand Jain
2016-10-18 12:39 ` Austin S. Hemmelgarn
2016-10-18 21:36 ` Anand Jain
2016-10-19 11:15 ` Austin S. Hemmelgarn
2016-10-19 13:06 ` Anand Jain
2016-10-19 13:33 ` Austin S. Hemmelgarn
2016-10-19 21:38 ` Anand Jain
2016-10-17 17:41 ` Zygo Blaxell [this message]
2016-10-17 17:55 ` Kyle Manna
2016-10-17 20:40 ` Chris Murphy
2016-10-18 12:41 ` Austin S. Hemmelgarn
2016-10-19 22:46 ` Stefan Malte Schumacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161017174103.GC21290@hungrycats.org \
--to=ce3g8jdj@umail.furryterror.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=stefan.m.schumacher@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.