aoe-stat 782 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. # collate and present sysfs information about AoE storage
  3. set -e
  4. format="%10s %15s %6s %-14s\n"
  5. me=`basename $0`
  6. sysd=${sysfs_dir:-/sys}
  7. # printf "$format" device mac netif state
  8. # Suse 9.1 Pro doesn't put /sys in /etc/mtab
  9. #test -z "`mount | grep sysfs`" && {
  10. test ! -d "$sysd/block" && {
  11. echo "$me Error: sysfs is not mounted" 1>&2
  12. exit 1
  13. }
  14. for d in `ls -d $sysd/block/etherd* 2>/dev/null | grep -v p` end; do
  15. # maybe ls comes up empty, so we use "end"
  16. test $d = end && continue
  17. dev=`echo "$d" | sed 's/.*!//'`
  18. sectors="`cat \"$d/size\"`"
  19. psize=$(((512000 * sectors) / (1000 * 1000 * 1000)))
  20. psize=`printf "%04d\n" $psize | sed 's!\(...\)$!.\1!'`
  21. printf "$format" \
  22. "$dev" \
  23. "${psize}GB" \
  24. "`cat \"$d/netif\"`" \
  25. "`cat \"$d/state\"`"
  26. done | sort