Your Ad Here

IBM AIX/UNIX system storage administration ksh/perl scripting

Showing posts with label network. Show all posts
Showing posts with label network. Show all posts

Wednesday, May 06, 2009

Determine which process is using a specific network port on AIX with or without lsof

Method 1. Using lsof.

It will be easy if you have lsof installed.

# lsof -i:32876
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
oracle 135744 oracle7 13u IPv4 0x70bbe200 0t11 UDP loopback:32876

# ps -ef|grep 135744
oracle7 135744 1 0 Apr 21 - 2:45 ora_pmon_ftc_p01

Method 2. Using netstat and rmsock

# netstat -Aan|grep 9991
f100020000626b98 tcp4 0 0 *.9991 *.* LISTEN

# rmsock f100020000626b98 tcpcb
The socket 0x626808 is being held by proccess 200928 (sysscand).

#ps -ef|grep 200928
root 200928 1 0 Apr 21 - 0:01 /opt/sysscan/bin/sysscand


Method 3: Using netstat and kdb.

# netstat -Aan|grep 9991
f100020000626b98 tcp4 0 0 *.9991 *.* LISTEN

# kdb
The specified kernel file is a 64-bit kernel
Preserving 1418431 bytes of symbol table
First symbol __mulh
START END
0000000000001000 0000000003E0D050 start+000FD8
F00000002FF47600 F00000002FFDC940 __ublock+000000
000000002FF22FF4 000000002FF22FF8 environ+000000
000000002FF22FF8 000000002FF22FFC errno+000000
F100070F00000000 F100070F10000000 pvproc+000000
F100070F10000000 F100070F18000000 pvthread+000000
PFT:
PVT:
id....................0002
raddr.....0000000000724000 eaddr.....F200800030000000
size..............00040000 align.............00001000
valid..1 ros....0 fixlmb.1 seg....0 wimg...2
ERROR: Unable to acess nfs_syms

(0)> sockinfo f100020000626b98 tcpcb
.................
..............

on last a few lines.

proc/fd: 49/0
proc/fd: fd: 0
SLOT NAME STATE PID PPID ADSPACE CL #THS

pvproc+00C400 49*sysscand ACTIVE 00310E0 0000001 00000000285C7400 0 0001



(0)> hcal 00310E0
Value hexa: 000310E0 Value decimal: 200928

(0)> quit

# ps -ef|grep 200928
root 200928 1 0 Apr 21 - 0:01 /opt/sysscan/bin/sysscand

Friday, March 27, 2009

Remove IP Configuration for enX Device

The procedure is to remove IP configuration from en1 device on AIX.

  1. Use the ifconfig command to disable and remove the interface from the network. Enter:
    ifconfig en1 down detach
  2. Remove device from the system with rmdev command. Enter:
    rmdev -dl en1

Thursday, March 12, 2009

Solaris script(get_active_nic_settings.sh) - bash script to get the ndd settings for all active NICs

#!/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

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

Monday, January 12, 2009

Etherchannel and switch requirement

In AIX, you can configure multiple EtherChannels per system, but it is required that all the links in one EtherChannel are attached to a single switch. Because the EtherChannel cannot be spread across two switches, the entire EtherChannel is lost if the switch is unplugged or fails. To solve this problem, a new backup option available in AIX 5.2 and later keeps the service running when the main EtherChannel fails. The backup and EtherChannel adapters should be attached to different network switches, which must be inter-connected for this setup to work properly. In the event that all of the adapters in the EtherChannel fail, the backup adapter will be used to send and receive all traffic. When any link in the EtherChannel is restored, the service is moved back to the EtherChannel.

For example, ent0 and ent1 could be configured as the main EtherChannel adapters, and ent2 as the backup adapter, creating an EtherChannel called ent3. Ideally, ent0 and ent1 would be connected to the same EtherChannel-enabled switch, and ent2 would be connected to a different switch. In this example, all traffic sent over en3 (the EtherChannel's interface) would be sent over ent0 or ent1 by default (depending on the EtherChannel's packet distribution scheme), whereas ent2 will be idle. If at any time both ent0 and ent1 fail, all traffic would be sent over the backup adapter, ent2. When either ent0 or ent1 recover, they will once again be used for all traffic.

http://publib16.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixbman/commadmn/tcp_etherchannel.htm

http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.commadmn/doc/commadmndita/etherchannel_intro.htm

Wednesday, July 02, 2008

ssh: w.x.y.z: Hostname and service name not provided or found

Error when run "ssh -l username w.x.y.z"
ssh: w.x.y.z: Hostname and service name not provided or found

Cause:

When you connect using a TCP/IP address, ssh expects to be able to perform a DNS reverse-lookup for the address provided. If the host name cannot be resolved or resolved to wrong hostname, this error is returned. To resolve the problem, have your DNS admin to correct the reverse DNS lookup.

# nslookup w.x.y.x
make sure it returns the correct hostname


Cause2:

If user root can ssh to remote server while normal user can't, then it means file /etc/resolv.conf does not have enough permisson to normal users.
# ls -l /etc/resolv.conf
# chmod o+r /etc/resolv.conf

Friday, June 13, 2008

How to test ftp throughput in UNIX

When you have performance issue with the network or ftp transfer, you can use test the throughput by using pipe and dd command.

The following example transfer a 10000 X 32k blocksize of data to /dev/null in remote server. So no file will be overwritten.

$ ftp remote_server

ftp> bin

200 Type set to I.

ftp> put "|dd if=/dev/zero bs=32k count=10000" /dev/null

200 PORT command successful.

150 Opening data connection for /dev/null.

10000+0 records in.

10000+0 records out.

226 Transfer complete.

327680000 bytes sent in 28.91 seconds (1.107e+04 Kbytes/s)

local: dd if=/dev/zero bs=32k count=10000 remote: /dev/null

ftp> bye

in the test above we get 1.107e+04 Kbytes/s, which is 11070Kb/s. And it is a 100Mb/s NIC card. So the network throughput is normal.

Labels

BlogCatalog