[ofa-general] [PATCH] infiniband-diags/scripts: Fix Bug 239 Error Reporting

davem at systemfabricworks.com davem at systemfabricworks.com
Tue Jul 31 17:09:54 PDT 2007



   Fix Bug 239 OpenIB diag scripts don't return error when lacking umad
   permissions.  Returning the error from the head of a shell pipeline is a
   problem, so this fix causes the awk scripts to pass error messages through.
   This will pass all standard error messages.

   This patch needs [ofa-general] [PATCH] infiniband-diags: Add common flags
   -P, -C, and -t (posted Tue Jul 31 13:39:27 PDT 2007) applied first.

Signed-off-by: David A. McMillen <davem at systemfabricworks.com>
---
 infiniband-diags/scripts/ibcheckerrors.in    |   11 +++++++++--
 infiniband-diags/scripts/ibcheckerrs.in      |   13 ++++++++++---
 infiniband-diags/scripts/ibchecknet.in       |   16 ++++++++++++++--
 infiniband-diags/scripts/ibcheckport.in      |   11 +++++++++--
 infiniband-diags/scripts/ibcheckportstate.in |   11 +++++++++--
 infiniband-diags/scripts/ibcheckportwidth.in |   11 +++++++++--
 infiniband-diags/scripts/ibcheckstate.in     |   10 +++++++++-
 infiniband-diags/scripts/ibcheckwidth.in     |   10 +++++++++-
 infiniband-diags/scripts/ibclearcounters.in  |   10 +++++++++-
 infiniband-diags/scripts/ibclearerrors.in    |   10 +++++++++-
 infiniband-diags/scripts/ibdatacounters.in   |   11 +++++++++--
 infiniband-diags/scripts/ibdatacounts.in     |   11 +++++++++--
 infiniband-diags/scripts/ibhosts.in          |    9 ++++++++-
 infiniband-diags/scripts/ibrouters.in        |    9 ++++++++-
 infiniband-diags/scripts/ibswitches.in       |    9 ++++++++-
 15 files changed, 138 insertions(+), 24 deletions(-)

diff --git a/infiniband-diags/scripts/ibcheckerrors.in b/infiniband-diags/scripts/ibcheckerrors.in
index 01c7a99..ebf44ec 100644
--- a/infiniband-diags/scripts/ibcheckerrors.in
+++ b/infiniband-diags/scripts/ibcheckerrors.in
@@ -73,7 +73,9 @@ else
 	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
-eval $netcmd | awk '
+text="`eval $netcmd`"
+rv=$?
+echo "$text" | awk '
 BEGIN {
 	ne=0
 }
@@ -129,10 +131,15 @@ function check_node(lid)
 			}
 }
 
+/^ib/	{print $0}
+/ibpanic:/	{print $0}
+/ibwarn:/	{print $0}
+/iberror:/	{print $0}
+
 END {
 	printf "\n## Summary: %d nodes checked, %d bad nodes found\n", nnodes, ne
 	printf "##          %d ports checked, %d ports have errors beyond threshold\n", nports, pcnterr
 	exit (ne + pcnterr)
 }
 '
-exit $?
+exit $rv
diff --git a/infiniband-diags/scripts/ibcheckerrs.in b/infiniband-diags/scripts/ibcheckerrs.in
index 99d45cd..aa29525 100644
--- a/infiniband-diags/scripts/ibcheckerrs.in
+++ b/infiniband-diags/scripts/ibcheckerrs.in
@@ -151,9 +151,11 @@ else
 	fi
 fi
 
-nodename=`smpquery $ca_info nodedesc $lid | sed -e "s/^Node Description:\.*\(.*\)/\1/"`
+nodename=`$IBPATH/smpquery $ca_info nodedesc $lid | sed -e "s/^Node Description:\.*\(.*\)/\1/"`
 
-if $IBPATH/perfquery $ca_info $lid $portnum | awk -v mono=$bw -v brief=$brief -F '[.:]*' '
+text="`eval $IBPATH/perfquery $ca_info $lid $portnum`"
+rv=$?
+if echo "$text" | awk -v mono=$bw -v brief=$brief -F '[.:]*' '
 function blue(s)
 {
 	if (brief == "yes") {
@@ -184,6 +186,11 @@ BEGIN {
 
 /^CounterSelect/ {next}
 
+/^ib/  {print $0}
+/ibpanic:/     {print $0}
+/ibwarn:/      {print $0}
+/iberror:/     {print $0}
+
 /^PortSelect/	{ if ($2 != '$portnum') {err = err "error: lid '$lid' port " $2 " does not match query ('$portnum')\n"; exit -1}}
 
 $1 ~ "(Xmt|Rcv)(Pkts|Data)" { next }
@@ -201,7 +208,7 @@ END {
 		exit -1
 	}
 	exit 0
-}' 2>&1 ; then
+}' 2>&1 && test $rv -eq 0 ; then
 	if [ "$verbose" = "yes" ]; then
 		echo -n "Error check on lid $lid ($nodename) port $portname: "
 		green OK
diff --git a/infiniband-diags/scripts/ibchecknet.in b/infiniband-diags/scripts/ibchecknet.in
index e2f7fb8..a47ab8e 100644
--- a/infiniband-diags/scripts/ibchecknet.in
+++ b/infiniband-diags/scripts/ibchecknet.in
@@ -65,7 +65,9 @@ else
 	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
-eval $netcmd | awk '
+text="`eval $netcmd`"
+rv=$?
+echo "$text" | awk '
 BEGIN {
 	ne=0
 	pe=0
@@ -130,6 +132,11 @@ function check_node(lid)
 			}
 }
 
+/^ib/	{print $0}
+/ibpanic:/	{print $0}
+/ibwarn:/	{print $0}
+/iberror:/	{print $0}
+
 END {
 	printf "\n## Summary: %d nodes checked, %d bad nodes found\n", nnodes, ne
 	printf "##          %d ports checked, %d bad ports found\n", nports, pe
@@ -137,4 +144,9 @@ END {
 	exit (ne + pe + pcnterr)
 }
 '
-exit $?
+av=$?
+if [ $av -ne 0 ] ; then
+	exit $av
+else
+	exit $rv
+fi
diff --git a/infiniband-diags/scripts/ibcheckport.in b/infiniband-diags/scripts/ibcheckport.in
index 3c7c396..94cfc6c 100644
--- a/infiniband-diags/scripts/ibcheckport.in
+++ b/infiniband-diags/scripts/ibcheckport.in
@@ -89,7 +89,9 @@ else
 fi
 
 
-if $IBPATH/smpquery $ca_info portinfo $lid $portnum | awk -v mono=$bw -F '[.:]*' '
+text="`eval $IBPATH/smpquery $ca_info portinfo $lid $portnum`"
+rv=$?
+if echo "$text" | awk -v mono=$bw -F '[.:]*' '
 function blue(s)
 {
 	if (mono)
@@ -114,6 +116,11 @@ function blue(s)
 
 #/^LocalPort/	{ if ($2 != '$portnum') {err = err "#error: port " $2 " does not match query ('$portnum')\n"; exit -1}}
 
+/^ib/	{print $0}
+/ibpanic:/	{print $0}
+/ibwarn:/	{print $0}
+/iberror:/	{print $0}
+
 END {
 	if (err != "") {
 		blue(err)
@@ -124,7 +131,7 @@ END {
 		exit -1
 	}
 	exit 0
-}' 2>&1 ; then
+}' 2>&1 && test $rv -eq 0 ; then
 	if [ "$verbose" = "yes" ]; then
 		echo -n "Port check lid $lid port $portnum: "
 		green "OK"
diff --git a/infiniband-diags/scripts/ibcheckportstate.in b/infiniband-diags/scripts/ibcheckportstate.in
index f3a5f05..2931f06 100644
--- a/infiniband-diags/scripts/ibcheckportstate.in
+++ b/infiniband-diags/scripts/ibcheckportstate.in
@@ -89,7 +89,9 @@ else
 fi
 
 
-if $IBPATH/smpquery $ca_info portinfo $lid $portnum | awk -v mono=$bw -F '[.:]*' '
+text="`eval $IBPATH/smpquery $ca_info portinfo $lid $portnum`"
+rv=$?
+if echo "$text" | awk -v mono=$bw -F '[.:]*' '
 function blue(s)
 {
 	if (mono)
@@ -106,6 +108,11 @@ function blue(s)
 
 /^LinkState/{ if ($2 != "Active") warn = warn "#warn: Logical link state is " $2 "  lid '$lid' port '$portnum'\n"}
 
+/^ib/	{print $0}
+/ibpanic:/	{print $0}
+/ibwarn:/	{print $0}
+/iberror:/	{print $0}
+
 END {
 	if (err != "") {
 		blue(err)
@@ -116,7 +123,7 @@ END {
 		exit -1
 	}
 	exit 0
-}' 2>&1 ; then
+}' 2>&1 && test $rv -eq 0 ; then
 	if [ "$verbose" = "yes" ]; then
 		echo -n "Port check lid $lid port $portnum: "
 		green "OK"
diff --git a/infiniband-diags/scripts/ibcheckportwidth.in b/infiniband-diags/scripts/ibcheckportwidth.in
index fdc75d1..84f1ef7 100644
--- a/infiniband-diags/scripts/ibcheckportwidth.in
+++ b/infiniband-diags/scripts/ibcheckportwidth.in
@@ -89,7 +89,9 @@ else
 fi
 
 
-if $IBPATH/smpquery $ca_info portinfo $lid $portnum | awk -v mono=$bw -F '[.:]*' '
+text="`eval $IBPATH/smpquery $ca_info portinfo $lid $portnum`"
+rv=$?
+if echo "$text" | awk -v mono=$bw -F '[.:]*' '
 function blue(s)
 {
 	if (mono)
@@ -104,6 +106,11 @@ function blue(s)
 /^LinkWidthSupported/{ if ($2 != "1X") { next } }
 /^LinkWidthActive/{ if ($2 == "1X") warn = warn "#warn: Link configured as 1X  lid '$lid' port '$portnum'\n"}
 
+/^ib/	{print $0}
+/ibpanic:/	{print $0}
+/ibwarn:/	{print $0}
+/iberror:/	{print $0}
+
 END {
 	if (err != "") {
 		blue(err)
@@ -114,7 +121,7 @@ END {
 		exit -1
 	}
 	exit 0
-}' 2>&1 ; then
+}' 2>&1 && test $rv -eq 0 ; then
 	if [ "$verbose" = "yes" ]; then
 		echo -n "Port check lid $lid port $portnum: "
 		green "OK"
diff --git a/infiniband-diags/scripts/ibcheckstate.in b/infiniband-diags/scripts/ibcheckstate.in
index 944e139..6ce0854 100644
--- a/infiniband-diags/scripts/ibcheckstate.in
+++ b/infiniband-diags/scripts/ibcheckstate.in
@@ -67,7 +67,9 @@ else
 	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
-eval $netcmd | awk '
+text="`eval $netcmd`"
+rv=$?
+echo "$text" | awk '
 BEGIN {
 	ne=0
 	pe=0
@@ -120,8 +122,14 @@ function check_node(lid)
 		}
 }
 
+/^ib/	{print $0}
+/ibpanic:/	{print $0}
+/ibwarn:/	{print $0}
+/iberror:/	{print $0}
+
 END {
 	printf "\n## Summary: %d nodes checked, %d bad nodes found\n", nnodes, ne
 	printf "##          %d ports checked, %d ports with bad state found\n", nports, pe
 }
 '
+exit $rv
diff --git a/infiniband-diags/scripts/ibcheckwidth.in b/infiniband-diags/scripts/ibcheckwidth.in
index 8ad0f7f..f8f6a8b 100644
--- a/infiniband-diags/scripts/ibcheckwidth.in
+++ b/infiniband-diags/scripts/ibcheckwidth.in
@@ -67,7 +67,9 @@ else
 	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
-eval $netcmd | awk '
+text="`eval $netcmd`"
+rv=$?
+echo "$text" | awk '
 BEGIN {
 	ne=0
 	pe=0
@@ -120,8 +122,14 @@ function check_node(lid)
 		}
 }
 
+/^ib/	{print $0}
+/ibpanic:/	{print $0}
+/ibwarn:/	{print $0}
+/iberror:/	{print $0}
+
 END {
 	printf "\n## Summary: %d nodes checked, %d bad nodes found\n", nnodes, ne
 	printf "##          %d ports checked, %d ports with 1x width in error found\n", nports, pe
 }
 '
+exit $rv
diff --git a/infiniband-diags/scripts/ibclearcounters.in b/infiniband-diags/scripts/ibclearcounters.in
index b3c009e..1818c42 100644
--- a/infiniband-diags/scripts/ibclearcounters.in
+++ b/infiniband-diags/scripts/ibclearcounters.in
@@ -61,7 +61,9 @@ else
 	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
-eval $netcmd | awk '
+text="`eval $netcmd`"
+rv=$?
+echo "$text" | awk '
 
 function clear_counters(lid)
 {
@@ -100,7 +102,13 @@ function clear_port_counters(lid, port)
 			}
 		}
 
+/^ib/	{print $0}
+/ibpanic:/	{print $0}
+/ibwarn:/	{print $0}
+/iberror:/	{print $0}
+
 END {
 	printf "\n## Summary: %d nodes cleared %d errors\n", nnodes, nodeerr
 }
 '
+exit $rv
diff --git a/infiniband-diags/scripts/ibclearerrors.in b/infiniband-diags/scripts/ibclearerrors.in
index 097c3fe..c63283a 100644
--- a/infiniband-diags/scripts/ibclearerrors.in
+++ b/infiniband-diags/scripts/ibclearerrors.in
@@ -61,7 +61,9 @@ else
 	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
-eval $netcmd | awk '
+text="`eval $netcmd`"
+rv=$?
+echo "$text" | awk '
 
 function clear_errors(lid, port)
 {
@@ -93,7 +95,13 @@ function clear_errors(lid, port)
 			}
 		}
 
+/^ib/	{print $0}
+/ibpanic:/	{print $0}
+/ibwarn:/	{print $0}
+/iberror:/	{print $0}
+
 END {
 	printf "\n## Summary: %d nodes cleared %d errors\n", nnodes, nodeerr
 }
 '
+exit $rv
diff --git a/infiniband-diags/scripts/ibdatacounters.in b/infiniband-diags/scripts/ibdatacounters.in
index bee9bd8..902a865 100644
--- a/infiniband-diags/scripts/ibdatacounters.in
+++ b/infiniband-diags/scripts/ibdatacounters.in
@@ -73,7 +73,9 @@ else
 	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
-eval $netcmd | awk '
+text="`eval $netcmd`"
+rv=$?
+echo "$text" | awk '
 BEGIN {
 	ne=0
 }
@@ -128,10 +130,15 @@ function check_node(lid)
 			}
 }
 
+/^ib/	{print $0}
+/ibpanic:/	{print $0}
+/ibwarn:/	{print $0}
+/iberror:/	{print $0}
+
 END {
 	printf "\n## Summary: %d nodes checked, %d bad nodes found\n", nnodes, ne
 	printf "##          %d ports checked\n", nports
 	exit (ne )
 }
 '
-exit $?
+exit $rv
diff --git a/infiniband-diags/scripts/ibdatacounts.in b/infiniband-diags/scripts/ibdatacounts.in
index 927a978..bbdff71 100644
--- a/infiniband-diags/scripts/ibdatacounts.in
+++ b/infiniband-diags/scripts/ibdatacounts.in
@@ -108,7 +108,9 @@ fi
 
 nodename=`smpquery $ca_info nodedesc $lid | sed -e "s/^Node Description:\.*\(.*\)/\1/"`
 
-if $IBPATH/perfquery $ca_info $lid $portnum | awk -v mono=$bw -v brief=$brief -F '[.:]*' '
+text="`eval $IBPATH/perfquery $ca_info $lid $portnum`"
+rv=$?
+if echo "$text" | awk -v mono=$bw -v brief=$brief -F '[.:]*' '
 function blue(s)
 {
 	if (brief == "yes") {
@@ -128,6 +130,11 @@ function blue(s)
 
 /^CounterSelect/ {next}
 
+/^ib/	{print $0}
+/ibpanic:/	{print $0}
+/ibwarn:/	{print $0}
+/iberror:/	{print $0}
+
 /^PortSelect/	{ if ($2 != '$portnum') {err = err "error: lid '$lid' port " $2 " does not match query ('$portnum')\n"; exit -1}}
 
 $1 ~ "(Xmt|Rcv)(Pkts|Data)" { print $1 ":........................." $2 }
@@ -142,7 +149,7 @@ END {
 		exit -1
 	}
 	exit 0
-}' 2>&1 ; then
+}' 2>&1 && test $rv -eq 0 ; then
 	if [ "$verbose" = "yes" ]; then
 		echo -n "Error on lid $lid ($nodename) port $portname: "
 		green OK
diff --git a/infiniband-diags/scripts/ibhosts.in b/infiniband-diags/scripts/ibhosts.in
index 0d6b1bc..a287edf 100644
--- a/infiniband-diags/scripts/ibhosts.in
+++ b/infiniband-diags/scripts/ibhosts.in
@@ -47,7 +47,14 @@ else
 	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
-eval $netcmd | awk '
+text="`eval $netcmd`"
+rv=$?
+echo "$text" | awk '
 /^Ca/	{print $1 "\t: 0x" substr($3, 4, 16) " ports " $2 " "\
 		substr($0, match($0, "#[ \t]*")+RLENGTH)} 
+/^ib/	{print $0}
+/ibpanic:/	{print $0}
+/ibwarn:/	{print $0}
+/iberror:/	{print $0}
 '
+exit $rv
diff --git a/infiniband-diags/scripts/ibrouters.in b/infiniband-diags/scripts/ibrouters.in
index fea72bb..e053794 100644
--- a/infiniband-diags/scripts/ibrouters.in
+++ b/infiniband-diags/scripts/ibrouters.in
@@ -47,7 +47,14 @@ else
 	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
-eval $netcmd | awk '
+text="`eval $netcmd`"
+rv=$?
+echo "$text" | awk '
 /^Rt/	{print $1 "\t: 0x" substr($3, 4, 16) " ports " $2 " "\
 		substr($0, match($0, "#[ \t]*")+RLENGTH)} 
+/^ib/	{print $0}
+/ibpanic:/	{print $0}
+/ibwarn:/	{print $0}
+/iberror:/	{print $0}
 '
+exit $rv
diff --git a/infiniband-diags/scripts/ibswitches.in b/infiniband-diags/scripts/ibswitches.in
index 859aacd..0476d0e 100644
--- a/infiniband-diags/scripts/ibswitches.in
+++ b/infiniband-diags/scripts/ibswitches.in
@@ -47,7 +47,9 @@ else
 	netcmd="$IBPATH/ibnetdiscover $ca_info"
 fi
 
-eval $netcmd | awk '
+text="`eval $netcmd`"
+rv=$?
+echo "$text" | awk '
 /^Switch/	{
 			l=$0
 			desc=substr(l, match(l, "#[ \t]*")+RLENGTH)
@@ -69,4 +71,9 @@ eval $netcmd | awk '
 			else
 				print $1 "\t: 0x" substr($3, 4, 16) " ports " $2 " "\
 					desc " " type " " pinfo}
+/^ib/	{print $0}
+/ibpanic:/	{print $0}
+/ibwarn:/	{print $0}
+/iberror:/	{print $0}
 '
+exit $rv



More information about the general mailing list