For single-line outputs, some standardization could be good here, specifically, perhaps adding the -F flag to LVM and VPD queries.
Device commands do have a standardized way to get this:
#################
For lsdev, you can use -F
#################
# lsdev -H -Ccadapter -F 'name;class;subclass;type;location;physloc;description'
name;class;subclass;type;location;physloc;description
ent0;adapter;pciex;df1020e2e304;02-00;U78D2.001.XXXXXXX-P1-C9-T1;PCIe3 4-Port 10GbE SR Adapter (df1020e21410e304)
…
#################
For lsattr, you can do the same
#################
#lsattr -El sys0 -H -F 'attribute:value:description:user_settable'
attribute:value:description:user_settable
SW_dist_intr:false:Enable SW distribution of interrupts:True
autorestart:true:Automatically REBOOT OS after a crash:True
boottype:disk:N/A:False
capacity_inc:0.01:Processor capacity increment:False
capped:false:Partition is capped:False
chown_restrict:true:Chown Restriction Mode:True
clouddev:0:Recreate ODM devices on next boot:True
conslogin:enable:System Console Login :False
cpuguard:enable:CPU Guard:True
However, VPD is less standardized.
#################
lscfg -vl is brutal to parse, and ODM does not have all of this. You can get useful data with:
#################
# lsvpd | while read type data ; do if [[ "${type}" == "*YL" ]] ; then echo "" ; fi ; echo "$type $data" ; done | more | grep -p fcs0
*YL U78D2.001.XXXXXXX-P1-C9-T4
*FC ????????
*DS PCIe3 4-Port 16Gb FC Adapter (df1000e314101406)
*AX fcs0
*PL 03-00
*CD 10140614
*PN 01FT695
*SN Y050HY95A012
*EC P14609
*CC 578E
*MF 001D
*FN 01FT699
*ZM 3
*Z0 0000000C
*Z1 00000001
*Z2 00000000
*Z3 08090000
*Z4 01000001
*Z5 2E343135
*Z6 2E343135
*Z7 C0022C40
*Z8 20000010XXXXXXXX
*Z9 11.4.415.5
*ZA 11.4.415.5
*ZB 00000000
*ZC 00040000
*ZD 000000FF
In this case, it’s missing “Network Address”, but you can usually convert Z8. This doesn’t work on virtual though. I usually do something more like this to get the data I want:
for fcs in
lsdev -C | grep fcs | cut -f 1 -d \
; do
fscsi=lsdev -p$fcs | grep -i scsi | cut -f 1 -d \
; hn=hostname
;
echo $hostname lscfg -vsl $fcs | egrep 'fcs|Address' | tr . \ | tr -s [:space:]
FC ID: lsattr -a scsi_id -F value -El $fscsi
; done
vio2a fcs0 U78AE 001 XXXXXXX-P1-C19-L1-T1 Network Address 10000090FXXXXXXX FC ID: 0x450200
vio2a fcs1 U78AE 001 XXXXXXX-P1-C19-L1-T2 Network Address 10000090FXXXXXXX FC ID: 0x460200
That works on virtual hosts also.
LVM is the worst, and requires transformation
Other than cutting out specific data that you need, the AIX way is to use mkvgdata, and then parse the image.data file it produces.
Alternatively, you can do something like this:
# (lsvg rootvg | cut -c 1-45 ; lsvg rootvg | cut -c 46-999 ) | cut -f 1 -d ( | tr -d \ | tr : \ | while read variable value ; do echo ${variable}=${value} ; done | egrep -v '=$' | sort -r
VOLUMEGROUP=rootvg
VGSTATE=active
VGPERMISSION=read/write
VGIDENTIFIER=00XXXXX00000YYYYY0000ZZZZZZZZZZZ
…
This same works with lslv, or often you can get key info from “lsvg -l rootvg” or similar.