#!/bin/bash
###########################################################################
# script: get_active_nic_settings.sh
# date: 14:30, fri., feb. 22 2008
# author: brad hudson
# description: script to get the ndd settings on active NICs (Sun specific)
###########################################################################
# you have to be root
[[ $UID -ne 0 ]] && {
echo ""
echo "You must be root to run $0!"
echo ""
exit
}
# declare an array of NICs
declare -a INTERFACES
# assign the NICs to the array
INTERFACES=(`ifconfig -a | grep ^[A-Za-z] | awk -F: '{print $1}' | grep -v lo0`)
for ((i=0; i < ${#INTERFACES[@]}; i++)) {
# set some interface specific variables
interface=${INTERFACES[$i]}
int_length=${#INTERFACES[$i]}
instance=${INTERFACES[$i]:$int_length-1}
module=${INTERFACES[$i]:0:$int_length-1}
# set the instance of the module to the current NIC
# account for goofy bge method
if [ "$module" = "bge" ]
then
module="${module}${instance}"
else
ndd -set /dev/$module instance $instance
fi
echo ""
echo "----- $interface settings -----"
# get the module parameters
declare -a MOD_PARMS
MOD_PARMS=(`ndd -get /dev/$module \? | grep -v ^? | awk '{print $1}'`)
for ((x=0; x < ${#MOD_PARMS[@]}; x++)) {
parm_name=${MOD_PARMS[$x]}
parm_setting=`ndd -get /dev/$module $parm_name`
printf "%20s = %s\n" $parm_name $parm_setting
}
unset MOD_PARMS
}
echo"" unset INTERFACES
No comments:
Post a Comment