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

12 lines
304 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
2022-04-05 18:24:02 +02:00
echo "Checking healt for $path..."
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