#!/bin/sh

# Copyright C 2005 by Isilon Systems, Inc. All rights not expressly
# granted herein are reserved.
# Created in the United States of America.
# 
# This digital media is protected by U.S. and international copyright and
# intellectual property laws. Unless otherwise specified, all information
# and screens appearing as part of this digital medium, including
# software, services, documents, text, images, icons, and logos design;
# the selection, assembly, arrangement, and design thereof; and the code
# that enables its presentation, are the sole property of Isilon Systems,
# Inc.
# 
# Except as otherwise required by applicable law, no part of any
# copyrighted material may be reproduced, modified, translated,
# distributed, published, or transmitted by any means, electronic or
# mechanical, for any purpose, without the prior written consent of Isilon
# Systems. 
#  
# Isilon and Isilon Systems are registered trademarks of Isilon Systems,
# Inc.  Legion is a trademark of Isilon Systems, Inc.  All other
# trademarks and registered trademarks are the property of their
# respective holders.

PATH=$PATH:/usr/bin/isi_hwtools
export PATH

tailfiles() {
    local file

    for file in $*; do
	# This "if" guards against patterns that match no files.  Such
	# patterns expand to themselves, causing the "tail" command to
	# fail.
	if [ -r "$file" ]; then
	    echo "= $file tail ===================="
	    tail -100 $file
	else
	    echo "= no file \"$file\" exists to tail ===================="
	fi
    done
}

echo '= isi_ib_info output ===================='
isi_ib_info
echo '= IB sysctls ===================='
ibtype=$(sysctl isi.hw.net.infiniband.device.0.name | cut -d' ' -f2)
sysctl isi.hw.net.infiniband
if [ x$ibtype = x"ib_mthca0" ]; then
    sysctl dev.ib_mthca
fi
if [ x$ibtype = x"mlx4_core0" ]; then
    sysctl dev.mlx4_core
fi
sysctl sys.class.infiniband_mad
if [ x$ibtype = x"ib_mthca0" ]; then
    sysctl sys.class.infiniband.mthca0
fi
if [ x$ibtype = x"mlx4_core0" ]; then
    sysctl sys.class.infiniband.mlx4_0
fi
sysctl sys.class.infiniband_verbs
sysctl sys.class.infiniband_cm
sysctl net.inet.sdp
echo '= ARP table ===================='
arp -an
echo '= opensm processes ===================='
ps -auxwww | grep opensm
echo '= network stats ===================='
netstat -ss
echo '= zone allocator stats ===================='
vmstat -z
tailfiles /var/log/opensm /var/log/opensm-*.log /var/log/opensm-*.topo \
    /var/log/messages
