#!/bin/sh # # This simple script will collect outputs of ibroute for all switches # on the subnet and drop it on stdout. It can be used for LFTs dump # generation. # proc usage { echo Usage: $[basename $0] "[-h] [-D] [-C ca_name]" \ "[-P ca_port] [-t(imeout) timeout_ms]" exit 2 } proc dump_by_lid { for sw_lid in [$[ibswitches $ca_info \ | sed -ne 's/^.* lid \([0-9a-f]*\) .*$/\1/p]] { ibroute $ca_info $sw_lid } } proc dump_by_dr_path { for sw_dr in [$[ibnetdiscover $ca_info -v \ | sed -ne '/^DR path .* switch /s/^DR path \([,|0-9]\+\) ->.*{\([0-9|a-f]\+\)}.*$/\2 \1/p' \ | sort -u \ | awk 'BEGIN {guid=0;} {if ($1 != guid) { guid=$1; print $2; }}]] { ibroute $ca_info -D $(sw_dr) } } setglobal use_d = ''"" setglobal ca_info = ''"" while test $1 { match $1 { with -D setglobal use_d = '"-D'" with -h usage with -P | -C | -t | -timeout match $2 { with -* usage } if test x$2 = x { usage } setglobal ca_info = ""$ca_info $1 $2"" shift with -* usage with * usage } shift } if test $use_d = "-D" { dump_by_dr_path } else { dump_by_lid } exit