Created
April 8, 2022 16:58
-
-
Save AlexTalker/1609b8493c769013d25905e5a1f2b850 to your computer and use it in GitHub Desktop.
Collect information about present multipath devices in sufficient for `awk` format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# vim: set number tabstop=4 shiftwidth=4 smarttab expandtab: | |
_transform_slaves() { | |
xargs -n1 -I{} realpath "/sys/block/{}/../../" | sort -u | tr '\n' ',' | |
} | |
iterate_dms() { | |
local dmname dmuuid dmslaves dmslavescnt | |
for dmpath in /sys/block/dm-*; do | |
dmname=$(grep '^mpath*' "$dmpath/dm/name") | |
[ -z "$dmname" ] && continue; | |
dmuuid=$(cat "$dmpath/dm/uuid") | |
dmslaves=$(ls -1 "$dmpath/slaves") | |
dmslavescnt=$(echo "$dmslaves" | wc -l) | |
echo "$dmuuid $dmname $dmslavescnt $(echo "$dmslaves" | _transform_slaves)" | |
done | |
} | |
iterate_dms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment