Skip to content

Instantly share code, notes, and snippets.

@prestelpirate
Last active December 7, 2016 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prestelpirate/e05f734661c71b87eda9d87dbb353786 to your computer and use it in GitHub Desktop.
Save prestelpirate/e05f734661c71b87eda9d87dbb353786 to your computer and use it in GitHub Desktop.
Tired of remembering and typing in the ndd variables to check the speed and duplex settings of an ethernet port? This script automates the drudge work – just give it an interface type (hme, ce, bge) and an instance number, and it will tell you how that port is configured.
#!/bin/ksh
# See http://www.gaeltd.com/scripts-and-tools/ for more details
# 2004-01-20 Tom Kranz (tom@siliconbunny.com)
# This script is distributed under the GNU Public License (GPL) with the
# following extra conditions:
# - attritbution must be maintained
# - CD-ROM or similar media for commercial distribution without the prior
# approval of the author
# This script will take 2 arguments - first one being the interface name
# (ce, hme etc.) and the second one the instance number
# We'll then call ndd and pull up some information about speed and
# duplex settings
# Path to ndd
NDD=/usr/sbin/ndd
# Make sure we got our command line args
if [[ ${1} == "" ]] || [[ ${2} == "" ]]
then
echo ""
echo "Usage:"
echo "int_check.ksh <interface> <instance number>"
echo ""
echo "eg. int_check.ksh ce 0"
echo ""
exit 1
fi
# The parameters we want to check - all the usual suspects
PARMS="adv_autoneg_cap adv_1000fdx_cap adv_1000hdx_cap adv_100fdx_cap adv_100hdx_cap adv_10fdx_cap adv_10hdx_cap"
# Output time!
echo ""
echo "Port speed/duplex settings for ${1} instance ${2}:"
# We need to set the correct instance first
${NDD} -set /dev/${1} instance ${2}
# Loop through the ndd parameters, retrieve the values, and spit them out
for VAR in ${PARMS}
do
VALUE=$(${NDD} -get /dev/${1} ${VAR})
echo "${1}:${2} ${VAR} ${VALUE}"
done
echo ""
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment