Skip to content

Commit de2c3c3

Browse files
committed
Made the width of the Status column to accommodate 'MISCONFIGURED'. Made the width of the 'Name' column dynamic based longest name.
1 parent b036eab commit de2c3c3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_filesystems

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ contents=false
7979
showStatus=false
8080
showARN=false
8181
showBackup=false
82-
region=$(aws configure list | egrep '^.*egion ' | awk '{print $2}')
82+
region=$(aws configure get region)
8383
#
8484
# Process command line arguments.
8585
while getopts "bhcxsanr:i:f:" option; do
@@ -250,14 +250,16 @@ for region in ${regions[*]}; do
250250
jq -r '.[] | if(.FileSystemType == "ONTAP") then .FileSystemId + "," + .ResourceARN + "," + .Name + "," + .Lifecycle + "," + .ManagementIp + "," + .VpcId + "," + .SubnetId + "," + if(.AutomaticBackupRetentionDays == null) then "Dissabled" else (.AutomaticBackupRetentionDays | tostring) end + "," + .DeploymentType + "," + (.DiskIopsConfiguration | tostring) + "," + (.ThroughputCapacity | tostring) + "," + (.StorageCapacity | tostring) else empty end' $fileSystemsFile > $tmpout
251251
fi
252252

253+
largestName=$(awk -F, 'BEGIN {max=0} {if(length($3) > max){max=length($3)}} END {print max}' < $tmpout)
254+
nameFieldWidth=$((largestName + 4))
253255
if [ "$includeExtraInfo" == "true" ]; then
254-
awk -F, -v region=$region 'BEGIN {first=1; formatStr="%12s %23s %35s %10s %15s %22s %25s %6s %12s %11s %6s\n"}; {if(first) {printf "\n"; printf formatStr, "Region", "FileSystem ID", "Name", "Status", "Management IP", "VPC ID", "Subnet ID", "Size", "Deployment", "Throughput", "Iops"; first=0}; printf formatStr, region, $1, "\"" $3 "\"", $4, $5, $6, $7, $(12), $9, $(11), $(10)}' < $tmpout
256+
awk -F, -v region=$region 'BEGIN {first=1; formatStr="%12s %23s %'$nameFieldWidth's %14s %15s %22s %25s %6s %12s %11s %6s\n"}; {if(first) {printf "\n"; printf formatStr, "Region", "FileSystem ID", "Name", "Status", "Management IP", "VPC ID", "Subnet ID", "Size", "Deployment", "Throughput", "Iops"; first=0}; printf formatStr, region, $1, "\"" $3 "\"", $4, $5, $6, $7, $(12), $9, $(11), $(10)}' < $tmpout
255257
else
256258
if [ "$showARN" == "true" ]; then
257-
awk -F, -v region=$region 'BEGIN {first=1; formatStr="%12s %23s %70s %35s %10s %15s\n"}; {if(first) {printf "\n"; printf formatStr, "Region", "FileSystem ID", "ARN", "Name", "Status", "Management IP"; first=0}; printf formatStr, region, $1, $2, "\"" $3 "\"", $4, $5}' < $tmpout
259+
awk -F, -v region=$region 'BEGIN {first=1; formatStr="%12s %23s %70s %'$nameFieldWidth's %14s %15s\n"}; {if(first) {printf "\n"; printf formatStr, "Region", "FileSystem ID", "ARN", "Name", "Status", "Management IP"; first=0}; printf formatStr, region, $1, $2, "\"" $3 "\"", $4, $5}' < $tmpout
258260
else
259-
formatStr='%12s %23s %35s %10s %15s\n'
260-
[ "$showBackup" == "true" ] && formatStr='%12s %23s %35s %10s %15s %17s\n'
261+
formatStr='%12s %23s %'$nameFieldWidth's %14s %15s\n'
262+
[ "$showBackup" == "true" ] && formatStr='%12s %23s %'$nameFieldWidth's %14s %15s %17s\n'
261263
awk -F, -v region=$region 'BEGIN {first=1; formatStr="'"${formatStr}"'"}; {if(first) {printf "\n"; printf formatStr, "Region", "FileSystem ID", "Name", "Status", "Management IP", "Backup Retention"; first=0}; printf formatStr, region, $1, "\"" $3 "\"", $4, $5, $8}' < $tmpout
262264
fi
263265
fi

0 commit comments

Comments
 (0)