computer-playbook/roles/btrfs-health-check/files/btrfs-health-check.sh

12 lines
305 B
Bash
Raw Normal View History

2022-01-30 13:22:47 +01:00
#!/bin/bash
2022-04-05 18:24:02 +02:00
exit_code=0
2022-01-30 13:22:47 +01:00
for path in $(btrfs filesystem show | awk '/ path /{print $NF}')
do
echo "Checking health for $path..."
2022-04-05 18:24:02 +02:00
result=$(btrfs device stats $path)
echo "$result"
regex='\.(.*)_errs(\s*)[1-9]'
[[ "$result" =~ $regex ]] && echo "Errors found!" && exit_code=1;
2022-01-30 13:22:47 +01:00
done
2022-04-05 18:24:02 +02:00
exit $exit_code