|author||Austin S. Hemmelgarn <email@example.com>||2016-12-05 13:35:20 -0500|
|committer||David Sterba <firstname.lastname@example.org>||2016-12-14 15:06:35 +0100|
btrfs-progs: dev stats: add dev stats returncode option
Currently, `btrfs device stats` returns non-zero only when there was an error getting the counter values. This is fine for when it gets run by a user directly, but is a serious pain when trying to use it in a script or for monitoring since you need to parse the (not at all machine friendly) output to check the counter values. This patch adds an option ('-s') which causes `btrfs device stats` to set bit 6 in the return code if any of the counters are non-zero. This greatly simplifies checking from a script or monitoring software if any errors have been recorded. In the event that this switch is passed and an error occurs reading the stats, the return code will have bit 0 set (so if there are errors reading counters, and the counters which were read were non-zero, the return value will be 65). Signed-off-by: Austin S. Hemmelgarn <email@example.com> Signed-off-by: David Sterba <firstname.lastname@example.org>
Diffstat (limited to 'Documentation/btrfs-device.asciidoc')
1 files changed, 7 insertions, 1 deletions
diff --git a/Documentation/btrfs-device.asciidoc b/Documentation/btrfs-device.asciidoc
index 239c99bc..d398b6d2 100644
@@ -98,7 +98,7 @@ remain as such. Reloading the kernel module will drop this information. There's
an alternative way of mounting multiple-device filesystem without the need for
prior scanning. See the mount option 'device'.
-*stats* [-z] <path>|<device>::
+*stats* [-zs] <path>|<device>::
Read and print the device IO error statistics for all devices of the given
filesystem identified by <path> or for a single <device>. See section *DEVICE
STATS* for more information.
@@ -108,6 +108,9 @@ STATS* for more information.
Print the stats and reset the values to zero afterwards.
+Set bit 6 of the return-code if any error statistics are non-zero.
*usage* [options] <path> [<path>...]::
Show detailed information about internal allocations in devices.
@@ -231,6 +234,9 @@ EXIT STATUS
*btrfs device* returns a zero exit status if it succeeds. Non zero is
returned in case of failure.
+If the '-s' option is used, *btrfs device stats* will add 64 to the
+exit status if any of the error counters is non-zero.
*btrfs* is part of btrfs-progs.