^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #! /bin/sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # collate and present sysfs information about AoE storage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) # A more complete version of this script is aoe-stat, in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) # aoetools.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) set -e
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) format="%8s\t%8s\t%8s\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) me=`basename $0`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) sysd=${sysfs_dir:-/sys}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) # printf "$format" device mac netif state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) # Suse 9.1 Pro doesn't put /sys in /etc/mtab
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #test -z "`mount | grep sysfs`" && {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) test ! -d "$sysd/block" && {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) echo "$me Error: sysfs is not mounted" 1>&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) for d in `ls -d $sysd/block/etherd* 2>/dev/null | grep -v p` end; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) # maybe ls comes up empty, so we use "end"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) test $d = end && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) dev=`echo "$d" | sed 's/.*!//'`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) printf "$format" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) "$dev" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) "`cat \"$d/netif\"`" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) "`cat \"$d/state\"`"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) done | sort