Re: Set Full Duplex on AIX
From: MoshiachNow (lev.weissman_at_creo.com)
Date: 03/22/05
- Next message: sysboy_at_gmail.com: "Re: AIX 5.3 paging issues"
- Previous message: alephnull: "hpmcount for AIX 5.2"
- In reply to: AIX_USER: "Re: Set Full Duplex on AIX"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 22 Mar 2005 06:04:46 -0800
HI,
Actually I have written the following script that interactively
displays all options available per interface and changes them without
reboot.
-------------------------------------------------------------------------
#!/bin/ksh
##########################################################################
# Written on11/11/04
# Updated on 30 Jan 2005
# Version 1.2
# This script enables changing the speed of a chozen network
interface without a need for reboot
# The script displays a list of the existing ent interfaces with
their current speed and IP setting .
# Once you choose the interfaces,you then choose the desired
speed.
# WARNING: THIS OPERATION WILL CUT OFF ANY APPLETALK/NFS/TCPIP
CONNECTIVITY FOR SEVERAL SECONDS !
# Note: 1.If you are changing the speed of the default interface -
you telnet communication will be cut off for a several
# seconds then it will restore back.
# 2. If you work remotely ,then choose the default interface and
change it's speed to the one which is not
# supported by your swith - the script may stick and leave you with a
disabled network.Then you have to change the
# interface settings localy on your machine
# usage : chent.sh
#####################################################################
CHENT="/usr/CHENT.sh"
export LOG="/tmp/chent.log"
MYTERM1=`who -m|awk '{ print \$2 }'`
export MYTERM=/dev/$MYTERM1
#collect all ENTs info into file
for ENT in `lsdev -Cs pci|grep ent | awk '{ print $1 }'`;do
EN=`echo $ENT|cut -c 1,2,4`
mktcpip -S $EN 2>&1|grep -v host|awk -F: '{ printf ("%-4s %-15s %-15s
%-12s ",$4,$2,$3,$7 )}'
SPEED=`lsattr -El $ENT | grep -iE "media_|speed"| awk '{ print
$2 }'`
if [[ -z $SPEED ]] ;then
printf "%-18s" ""
else
printf "%-18s" "$SPEED"
fi
lsdev -Cspci | grep $ENT|awk '{print $4,$5}'
done > /tmp/EN
COUNT=`wc -l /tmp/EN|awk '{ print $1 }'` #get the number of interfaces
integer A=1
oldIFS=$IFS #change field separator to "end-of-line"
IFS='\n'
while (( $A <= $COUNT )) ;do #fill up the array from the file
INTERFACE[A]=`head -n $A /tmp/EN|tail -1`
A=$A+1
done
A=$A-1
echo "---------------------------------------------------"
IFS='!' #change field separator to non-existing one just for "select"
echo "\nWARNING: THIS OPERATION WILL CUTT OFF ANY APPLETALK/NFS/TCPIP
CONNECTIVITY FOR SEVERALL SECONDS !\n"
echo "---------------------------------------------------"
echo "Select the destination interface : \n"
printf "%-2s %-4s %-15s %-15s %-12s %-17s %-20s\n" " " "Int"
"IP_address" "Mask" "Gateway" "Speed" "Type"
printf "%-2s %-4s %-15s %-15s %-12s %-17s %-20s\n" " " "---"
"----------" "----" "-------" "--------" "----------"
#Select the INTERFACE
PS3="choose the interface >>"
select DEST_INTERFACE in ${INTERFACE[*]}
do
if [[ -z $DEST_INTERFACE ]]
then
printf -- "Choose the right number \n\n"
else
break
fi
done
IFS=$oldIFS #change field separator back to default !
FINAL_INT=`echo $DEST_INTERFACE|awk '{print $1}'|cut -c 3`
#Get the specific boards options
if lsdev -Cspci | grep ent$FINAL_INT |grep 3Com >/dev/null ;then
DEVICE="3C905"
ATTRIBUTE="media_type"
elif lsdev -Cspci | grep ent$FINAL_INT |grep "SK-9821" >/dev/null ;then
DEVICE="48112150"
ATTRIBUTE="all_speeds"
else
DEVICE=`lsdev -Cspci | grep ent$FINAL_INT | awk -F "(" '{print $2
}'|tr -d ")"`
ATTRIBUTE="media_speed"
fi
#Select the speed
odmget -q uniquetype="adapter/pci/$DEVICE" PdAt|grep $ATTRIBUTE
>/dev/null #Check if this interface is configurable
if [[ $? != 0 ]] ; then
echo "\nThis interface speed can not be changed !\n"
exit
fi
echo "\nSelect the required new speed :\n"
PS3="choose speed>>"
select SPEED_SET in `odmget -q uniquetype="adapter/pci/$DEVICE"
PdAt|grep -p $ATTRIBUTE|awk -F \" '/values/ {print $2}' | tr , ' ' `
Exit ;do
if [[ -z $SPEED_SET ]] ;then
printf -- "Choose the right number \n\n"
elif [[ $SPEED_SET = "Exit" ]] ;then
exit
else
break
fi
done
echo "\nThis operation may take severall minutes ..."
echo "Now unmounting all NFS mounts ..."
umount allr >/dev/null 2>&1
echo "Now stopping tcpip ..."
stopsrc -g tcpip >/dev/null 2>&1
#Now create a background script
echo '#!/bin/ksh' > $CHENT
echo "chdev -l en$FINAL_INT -a state='down' > \$LOG 2>&1" >>
$CHENT
echo "chdev -l et$FINAL_INT -a state='down' >> \$LOG 2>&1" >>
$CHENT
echo "chdev -l en$FINAL_INT -a state='detach' >> \$LOG 2>&1" >>
$CHENT
echo "chdev -l et$FINAL_INT -a state='detach' >> \$LOG 2>&1" >>
$CHENT
if [[ $DEVICE = "48112150" ]] ;then #support SYskonnect GIGA
ATTRIBUTE="speed"
fi
echo "chdev -l ent$FINAL_INT -a $ATTRIBUTE=$SPEED_SET 2>&1 >\$MYTERM
|tee -a \$LOG" >> $CHENT
echo "echo \$? >> \$LOG" >> $CHENT
echo "if [[ \$? != 0 ]] ;then " >> $CHENT
echo "echo \"Failed to change the required speed !\"
>\$MYTERM" >> $CHENT
echo "exit 1" >> $CHENT
echo "fi" >> $CHENT
echo "chdev -l en$FINAL_INT -a state=up >> \$LOG 2>&1" >>
$CHENT
echo "chdev -l et$FINAL_INT -a state=up >> \$LOG 2>&1" >>
$CHENT
echo "Now restarting tcpip and atalk ..." >> $CHENT
echo "mkdev -l inet0 >> \$LOG 2>&1" >> $CHENT
echo "sleep 1" >> $CHENT
echo "startsrc -g tcpip >> \$LOG 2>&1" >> $CHENT
echo "/usr/local/es/start-atalk & >> \$LOG 2>&1" >> $CHENT
chmod 777 $CHENT
nohup $CHENT >$MYTERM 2>/dev/null
NEWSPEED=`lsattr -El ent$FINAL_INT | grep -iE "media_|speed" | awk '{
print $2 }'`
echo "The new speed is \"$NEWSPEED\""
- Next message: sysboy_at_gmail.com: "Re: AIX 5.3 paging issues"
- Previous message: alephnull: "hpmcount for AIX 5.2"
- In reply to: AIX_USER: "Re: Set Full Duplex on AIX"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|