#!/bin/ksh # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # bos720 src/bos/usr/sbin/perf/diag_tool/pv_.sh 1.12.1.5 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 1992,1993 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG # @(#)97 1.12.1.5 src/bos/usr/sbin/perf/diag_tool/pv_.sh, pdt, bos720 1/19/06 11:34:06 # # COMPONENT_NAME: pdt # # FUNCTIONS: none # # ORIGINS: 27 # # # (C) COPYRIGHT International Business Machines Corp. 1992, 1993 # All Rights Reserved # Licensed Materials - Property of IBM # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # # pv_ # Obtain physical volume configuration information, and record it in the # SM database # # first, get date information currentdate=`(gettime_)` curr=`echo $currentdate | tr ' ' '-'` # # Awk script to extract info from the lscfg command, and to provide a # formatted output of the obtained PV and SAD information # # Produces several kinds of SM records: # CU phys_address - physical address of the controller (e.g., 00-01) # CU ndisks - number of disks on the controller # CU sdisks - total size of disk space on the controller # AD phys_address - physical address of the adapter # AD ndisks - number of disks on the adapter # AD sdisks - total size of disk space on the adapter # PV locCU - controller id for the physical volume # PV locAD - adapter id for physical volume (serial only) # PV type - type of device (scsi, serial) # PPAD phys_address - address of parallel port adapter # LP type - type of printer # LP loc - name of controller for printer # # # Input: a file containing the output of the 'lscfg' command. # # obtain physical volume config information, and format output lscfg | \ awk ' BEGIN { } { x=gsub(/-/," ",c) x=gsub(/-/,",",t) # check all SSA devices if ($0 ~ /[Ss][Ss][Aa]/) { # accumulate controller data if ($0 ~ /Adapter/) { CU_AT_ADDR[substr($3,4,2)]=$2 print "CU", $2, c, "phys_address", $3, 1.0, "T" } # accumulate disk data if ($0 ~ /Logical Disk/) { dsize=$4 if (substr($4,length($4)-1,2)=="GB") dsize=substr($4,1,length($4)-2) * 1024 addr = substr($3,4,2) NDISKS_ON_CU[addr]++ SDISKS_ON_CU[addr]+=dsize CU_ADDR_FOR_PV[$2]=addr print "PV", $2, c, "type", "SSA", 1.0, "T" } } # check all SCSI devices if ($0 ~ /[Ss][Cc][Ss][Ii]/) { if ($0 ~ /Controller/) { CU_AT_ADDR[substr($3,2,4)]=$2 print "CU", $2, c, "phys_address", $3, 1.0, "T" } if ($0 ~ /Disk/) { dsize=$4 if ($5=="GB") dsize=1024*dsize addr = substr($3,2,4) NDISKS_ON_CU[addr]++ SDISKS_ON_CU[addr]+=dsize CU_ADDR_FOR_PV[$2]=addr print "PV", $2, c, "type", "SCSI", 1.0, "T" } } if ($0 ~ /Serial-Link/) { if ($0 ~ /Controller/) { CU_AT_ADDR[substr($3,2,7)]=$2 print "CU", $2, c, "phys_address", $3, 1.0, "T" } if ($0 ~ /Adapter/) { AD_AT_ADDR[substr($3,2,4)]=$2 print "AD", $2, c, "phys_address", $3, 1.0, "T" } if ($0 ~ /Disk/) { dsize=$4 if (substr($4,length($4)-1,2)=="GB") dsize=substr($4,1,length($4)-2) * 1024 if ($5=="GB") dsize=1024*dsize cuaddr = substr($3,2,7) adaddr = substr($3,2,4) if (CU_AT_ADDR[cuaddr] != "") { NDISKS_ON_CU[cuaddr]++ SDISKS_ON_CU[cuaddr]+=dsize CU_ADDR_FOR_PV[$2]=cuaddr } if (AD_AT_ADDR[adaddr] != "") { NDISKS_ON_AD[adaddr]++ SDISKS_ON_AD[adaddr]+=dsize AD_ADDR_FOR_PV[$2]=adaddr } print "PV", $2, c, "type", "Serial", 1.0, "T" } } if ($3 ~ /^00-00-0P$/) { print "PPAD", $2, c, "phys_address", $3, 1.0, "T" } if ($3 ~ /^00-00-0P-00/) { print "LP", $2, c, "type", "Parallel", 1.0, "T" } } END { for (address in NDISKS_ON_CU) { # # 5. the number of disks on the controller print "CU", CU_AT_ADDR[address], c, "ndisks", NDISKS_ON_CU[address], 1.0, "I(" t ",DISKS)" # # 6. the total size of diskspace on the controller print "CU", CU_AT_ADDR[address], c, "sdisks", SDISKS_ON_CU[address], 1.0, "I(" t ",MB)" } for (hdisk in CU_ADDR_FOR_PV) { # # 7. the controller name for the disk print "PV", hdisk, c, "locCU", CU_AT_ADDR[CU_ADDR_FOR_PV[hdisk]], 1.0, "T" } for (hdisk in AD_ADDR_FOR_PV) { # # 8. the adaptor for the disk print "PV", hdisk, c, "locAD", AD_AT_ADDR[AD_ADDR_FOR_PV[hdisk]], 1.0, "T" } }' c=$curr t="0-0-1" >>$pdt_SM # # Identify physical volumes and volume group mappings. # Only list PVs that belong to varried on VG. # lsvg -o | while read vg do lsvg -p $vg | awk -v vg=$vg 'NR > 2 { print $1, vg }' done > $pdt_tmp/.pvs lsps -a > $pdt_tmp/.pgs # # Awk script to issue a system command from within # an awk script. The command is lspv $1 # # Input: a file containing physical volume names in the # first column. (E.g., lspv creates such a file) # # Awk script to extract info from the lspv command, and to provide a # formatted output of the obtained information. # Produces two kinds of SM records for each paging space on the # physical volume: # PS nPPclumps - number of clumps of paging PPs on the volume # # Input: the output of the lspv command # awk ' { system("lspv " $1) }' < $pdt_tmp/.pvs | \ awk ' BEGIN { } { x=gsub(/-/," ",c) x=gsub(/-/,",",t) if ($0 ~ /^PHYSICAL VOLUME/) { # get volume name for future ref. # pvname = $3} else if ($0 ~ /^PP SIZE/) { # get size of physical partition ppsize = $3 print "PV", pvname, c, "PPsize", ppsize, 1.0, "I(" t ",MB)" } else if ($0 ~ /^TOTAL PPs/) { # get total size of physical volume pvsize = $3 print "PV", pvname, c, "nPPs", pvsize, 1.0, "I(" t ",PPS)" } else if ($0 ~ /^FREE PPs/) { # get number of PPs available pvavail = $3 print "PV", pvname, c, "pctavail", 100.0 * pvavail/pvsize, 1.0, "I(" t ",pct)" print "PV", pvname, c, "stgavail", pvavail*ppsize, 1.0, "I(" t ",MB)" } } END { }' c=$curr t="0-0-1" >>$pdt_SM # # obtain physical volume page space info, and format output awk ' { system("lspv -p " $1) }' < $pdt_tmp/.pvs | \ awk ' BEGIN { contigous=0 TMP=" " } { x=gsub(/-/," ",c) x=gsub(/-/,",",t) y=gsub(/inner /,"inner-",$0) y=gsub(/outer /,"outer-",$0) if (($5 ~ /paging/ && TMP!= $4) || ($5 ~ /paging/ && contigous==0)) { # count the number of clumps of physical partitions for each # paging space on this physical volume # LVCOUNT[$4]++ contigous=1 } else { contigous=0 } TMP=$4 } END { for (pp in LVCOUNT) { # # 1. the number of PP clumps for the paging LV print "PS", pp, c, "nPPclumps", LVCOUNT[pp], 1.0, "I(" t ",N)" } }' c=$curr t="0-0-1" >>$pdt_SM # # obtain no. of mirror copies of paging space awk ' { if (NR==1) next system("lslv "$1) }' < $pdt_tmp/.pgs | \ awk ' { x=gsub(/-/," ",c) x=gsub(/-/,",",t) if ($1 ~ /LOGICAL/) { VAR=$3 } if ($1 ~ /COPIES:/) { print "PS", VAR, c, "COPIES", $2, 1.0, "I(" t ",N)" } }' c=$curr t="0-0-1" >>$pdt_SM # # obtain volume group mapping for each physical volume awk ' BEGIN { } { x=gsub(/-/," ",c) x=gsub(/-/,",",t) print "PV", $1, c, "vg", $2, 1.0, "T" } END { }' c=$curr t="0-0-1" < $pdt_tmp/.pvs >>$pdt_SM # # obtain physical volume i/o activity iostat -d 2 20 | \ awk ' BEGIN { } { x=gsub(/-/," ",c) x=gsub(/-/,",",t) # skip blank lines and lines containing header information if (NF > 1) if ($1 !~ /^Disks:/) { # count the first record for each phys. volume, but later # we will not include it in the average NRECS[$1]++ if (NRECS[$1] > 1) { KBPS[$1]+=$3 UTIL[$1]+=$2 } } } END { for (pv in UTIL) { print "PV", pv, c, "util", UTIL[pv]/(NRECS[pv]-1), 1.0, "I(" t ",pct)" print "PV", pv, c, "kbps", KBPS[pv]/(NRECS[pv]-1), 1.0, "I(" t ",KBPS)" } }' c=$curr t="2-2-20" >>$pdt_SM