]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/ofed/management/infiniband-diags/scripts/ibhosts.in
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / ofed / management / infiniband-diags / scripts / ibhosts.in
1 #!/bin/sh
2
3 IBPATH=${IBPATH:-@IBSCRIPTPATH@}
4
5 function usage() {
6         echo Usage: `basename $0` "[-h] [<topology-file> | -C ca_name" \
7             "-P ca_port -t(imeout) timeout_ms]"
8         exit -1
9 }
10
11 topofile=""
12 ca_info=""
13
14 while [ "$1" ]; do
15         case $1 in
16         -h)
17                 usage
18                 ;;
19         -P | -C | -t | -timeout)
20                 case $2 in
21                 -*)
22                         usage
23                         ;;
24                 esac
25                 if [ x$2 = x ] ; then
26                         usage
27                 fi
28                 ca_info="$ca_info $1 $2"
29                 shift
30                 ;;
31         -*)
32                 usage
33                 ;;
34         *)
35                 if [ "$topofile" ]; then
36                         usage
37                 fi
38                 topofile="$1"
39                 ;;
40         esac
41         shift
42 done
43
44 if [ "$topofile" ]; then
45         netcmd="cat $topofile"
46 else
47         netcmd="$IBPATH/ibnetdiscover $ca_info"
48 fi
49
50 text="`eval $netcmd`"
51 rv=$?
52 echo "$text" | awk '
53 /^Ca/   {print $1 "\t: 0x" substr($3, 4, 16) " ports " $2 " "\
54                 substr($0, match($0, "#[ \t]*")+RLENGTH)}
55 /^ib/   {print $0; next}
56 /ibpanic:/      {print $0}
57 /ibwarn:/       {print $0}
58 /iberror:/      {print $0}
59 '
60 exit $rv