Your Ad Here

IBM AIX/UNIX system storage administration ksh/perl scripting

Thursday, March 12, 2009

Solaris script (get_all_nic_settings.sh) - bash script to get all NIC settings (even unplumbed, but slower).

#!/bin/bash

##########################################################################
# script: get_all_nic_settings.sh
# date: 14:30, thu, mar 13 2008
# author: brad hudson
# description: script to get the ndd settings on all NICs (Sun specific)
##########################################################################

# you have to be root
[[ $UID -ne 0 ]] && {
echo ""
echo "You must be root to run $0!"
echo ""
exit
}

# disclaimer
echo ""
echo "**************************************************"
echo "Disclaimer: unplumb'd NICs are very slow to query!"
echo "**************************************************"
sleep 3

# declare an array of NIC modules
declare -a MODULES
MODULES=(bge ce eri hme qfe)

# loop through the modules to get ndd settings
for ((i=0; i < ${#MODULES[@]}; i++)) {
kstat -m ${MODULES[$i]} > /dev/null 2>&1
if [ $? -eq 0 ]
then
# get all NIC instances for the NIC module
declare -a INSTANCES
INSTANCES=(`kstat -m ${MODULES[$i]} | grep instance: | sort -u | awk '{print $NF}'`)
for ((x=0; x < ${#INSTANCES[@]}; x++)) {
echo ""

# account for non-standard bge method for ndd
if [ "${MODULES[$i]}" = "bge" ]
then
module="${MODULES[$i]}${INSTANCES[$x]}"
echo "***** $module settings *****"
else
module="${MODULES[$i]}"
ndd -set /dev/$module instance ${INSTANCES[$x]}
echo "***** $module${INSTANCES[$x]} settings *****"
fi

# get the module parameters
declare -a MOD_PARMS
MOD_PARMS=(`ndd -get /dev/$module \? | grep -v ^? | awk '{print $1}'`)
for ((z=0; z < ${#MOD_PARMS[@]}; z++)) {
parm_name=${MOD_PARMS[$z]}
parm_setting=`ndd -get /dev/$module $parm_name`
printf "%20s = %s\n" $parm_name $parm_setting
}
unset MOD_PARMS
}
unset INSTANCES
fi
}

echo ""
unset MODULES




Sun BigAdmin Link

No comments:

Labels

Blog Archive

BlogCatalog