November 11, 2013

Useful AIX commands

SEA adapter configuration
# lsdev -Cc adapter |grep Shared|awk '{print $1}' |while read SEA; do echo ========= $SEA =========; lsattr -a ctl_chan,pvid,pvid_adapter,real_adapter,virt_adapters -El $SEA ; entstat -d $SEA |grep -Ei "\(ent|Hardware Address|PVID|Port VLAN ID|VLAN Tag|Link Status|Operating mode|Device Type"; echo;echo; done
Recover root password from NIM
# lsnim -l |grep -i LPAR
# /usr/lpp/bos.sysmgt/nim/methods/c_rsh AIXLPAR "\"echo "root:PassWoRd"|/usr/bin/chpasswd -f NOCHECK"\"

You can also run any command as root

# /usr/lpp/bos.sysmgt/nim/methods/c_rsh AIXLPAR "\"/usr/bin/id;/usr/bin/uname -a"\"
To see whether the disk is in FlashCopy or not

To see the flashcopy lines that the -s adds to the output of each disk

# pcmpath query device -s | grep -i flashcopy
To determine vhost for vscsi right from AIX
# echo "cvai" | kdb -script |grep vscsi
read vscsi_scsi_ptrs OK, ptr = 0xF1000000C01CD111
vscsi0     0x000007 0x0000000000 0x0                VIO2-VIOS2_B2->vhost0
vscsi1     0x000007 0x0000000000 0x0                VIO1-VIOS1_B2->vhost0
vscsi2     0x000007 0x0000000000 0x0                VIO1-VIOS1_B2->vhost7
vscsi3     0x000007 0x0000000000 0x0                VIO2-VIOS2_B2->vhost7
Get dyntrk and fc_error_recov active values

To see whether dyntrk and fc_error_recov fscsi adapter parameters were applied in the running kernel or only changed in ODM

# DDI=$(echo "qlfscsi fscsi0 |grep ddi" |kdb -script |grep qlfscsi_ddi |awk '{print $NF}') ; echo "dd $DDI+20 2" |kdb -script ;\
# DDI=$(echo "qlfscsi fscsi1 |grep ddi" |kdb -script |grep qlfscsi_ddi |awk '{print $NF}') ; echo "dd $DDI+20 2" |kdb -script ;

The output will be following

F1000A0500A56030: 0101020202010400 000000B400000014  ................
                          FFDD     NNNNNNNN
F1000A0500A5A030: 0101020202010400 000000B400000014  ................
                          FFDD     NNNNNNNN

In our case

  • fc_error_recov is currently set to fast_fail (FF=02 = fc_error_recov = fast_fail).
  • dyntrk is currently set to yes (DD=01 = dyntrk = enabled).
  • num_cmd_elems is currently set to 200 (NNNNNNNN=B4 = num_cmd_elems = 180 + 20 = 200).
FF = fc_error_recov: 01=delayed_fail  02=fast_fail
DD = dyntrk: 00=disabled  01=enabled
NNNN=num_cmd_elems - 20 (20 reserved)

e.g. 200 - 20 = 180 = B4

Removing a device that is in the diagnose state
# rmdev -Rdl ent12
rmdev: 0514-534 Cannot perform requested function because the
        specified device is in the diagnose state.

# lscfg |grep ent12
+ ent12            U78A0.001.XXXXXX0-P1-C3-T2         10 Gb Ethernet-SR PCI Express Dual Port Adapter (771000801410b003)

# lsdev -C |grep ent12
ent12      Diagnose  03-01       10 Gb Ethernet-SR PCI Express Dual Port Adapter (771000801410b003)
# /usr/lib/methods/ucfgdiag -l ent12
# lsdev -C |grep ent12
ent12      Defined   03-01       10 Gb Ethernet-SR PCI Express Dual Port Adapter (771000801410b003)
# rmdev -Rdl ent12
ent12 deleted
Finding a switch port Ethernet adapter is connected to

A way of catching CDP (Cisco Discovery Protocol) packets

  • CDP must be enabled on a switch
  • IP is not necessary, only interface must be up
  • Takes about 5 minutes
# ifconfig en11 up
# tcpdump -nn -vvv -i en11 -s 1500 -c 1 'ether[20:2] == 0x2000'

After done

# ifconfig en11 down detach

Data gathering

Get the list of all Running servers on pSeries

$ for i in $(lssyscfg -r sys -F name); do lssyscfg -r lpar -m $i -F name,state |grep Running ; done |cut -f1 -d","

Get OS type

$ for i in $LIST; do printf ${i}":\t" ; ssh -n -oBatchMode=yes -oConnectTimeout=5 sshaccount@${i} "uname" ;done

Get Default GW per server

$ for i in $LIST; do printf ${i}":\t" ; ssh -n -oBatchMode=yes -oConnectTimeout=5 sshaccount@${i} "netstat -nr |grep default" ;done

Get All IPs per server

$ for i in $LIST; do ssh -n -oBatchMode=yes -oConnectTimeout=5 sshaccount@${i} "netstat -ni |grep -v link |grep ^en" | while read line; do printf ${i}":\t"; echo "${line}" ; done; done