1717# It will list:
1818# o Region
1919# o File System ID
20- # o File System Name - optional with -n option
20+ # o File System Name - optional. Comes with -n option
2121# o Storage Virtual Machine ID
22- # o Storage Virtual Machine Name - optional with -n option
22+ # o Storage Virtual Machine Name - optional. Comes with -n option
2323# o Volume ID
2424# o Volume Status
25- # o Volume Size in MB - optional - optional with -x option
26- # o Volume Used in MB - optional - optional with -x option
25+ # o Volume Size in MB - optional. Comes with -x option
26+ # o Volume Used in MB - optional. Comes with -x option
2727# o Volume Name
2828#
2929# ###############################################################################
@@ -37,12 +37,12 @@ Usage $(basename $0) [-r region] [-a] [-o] [-f fileSystemName] [-i fileSystemId]
3737 Where: volume_pattern - Only volumes that match the egrep pattern will be included.
3838 -r region allows you to specify the region you want the list from.
3939 -a means all regions.
40- -n means include the file system ans SVM names. Not capable with the -x option.
40+ -n means include the file system ans SVM names. Not compatible with the -x option.
4141 -f fileSystemName means to only include volumes that are under the named file system.
4242 -i fileSystemId means to only include volumes that are under the file system with the specified file system ID.
4343 -s svmID - Only show volumes that are under the specified SVM ID.
4444 -o means to exclude svm root volumes. Only works in conjunction with the -s option.
45- -x means to provide capacity information. Not capable with the -n option.
45+ -x means to provide capacity information. Not compatible with the -n option.
4646EOF
4747 exit 1
4848}
@@ -105,8 +105,8 @@ if [ ! -z "$1" ]; then
105105 volumePattern=" $1 "
106106fi
107107
108- if [ ! -z " $fileSystenName " -a ! -z " $fsid " ]; then
109- echo " Error, you can't provide both -f and -n options." 1>&2
108+ if [ ! -z " $fileSystemName " -a ! -z " $fsid " ]; then
109+ echo " Error, you can't provide both -f and -i options." 1>&2
110110 exit 1
111111fi
112112
154154jqFields=' \(.FileSystemId),\(.Name),\(.VolumeId),\(.Lifecycle),\(.OntapConfiguration.SizeInMegabytes),\(.OntapConfiguration.StorageVirtualMachineId)'
155155#
156156# Loop on all the regions.
157- fields=' \(.FileSystemId),\(.Name),\(.VolumeId),\(.Lifecycle),\(.OntapConfiguration.StorageVirtualMachineId)'
158157for region in ${regions[*]} ; do
159158 #
160159 # Check that the fsx service is supported in thie region
217216 aws cloudwatch get-metric-data --region $region --metric-data-queries file://$cloudwatchQueryFile --start-time=$( date -u -d ' 5 minutes ago' +" %Y-%m-%dT%H:%M:%SZ" ) --end-time=$( date -u +" %Y-%m-%dT%H:%M:%SZ" ) --output=json > $cloudwatchOutputFile 2>&1
218217 for volId in $volIds ; do
219218 volId2=$( echo $volId | sed -e ' s/-/_/g' )
220- capacity=$( jq -r ' .MetricDataResults[] | select(.Id == "m' $volId2 ' ") | .Values[0]' < $cloudwatchOutputFile )
219+ capacity=$( jq -r ' .MetricDataResults[] | select(.Id == "m' $volId2 ' ") | .Values[0] // 0 ' < $cloudwatchOutputFile )
221220 echo " $volId ,$capacity " >> $volCapacityFile
222221 done
223222 awk -F, -v region=$region -v volCapacityFile=$volCapacityFile ' BEGIN {first=1; formatStr="%12s %21s %21s %24s %10s %16s %15s %s\n"; while (getline < volCapacityFile) {volidCapacities[$1]=sprintf("%10.0f",$2/1024/1024)}}; {if(first) {printf "\n"; printf formatStr, "Region", "FileSystem ID", "SVM", "Volume ID", "State", "Volume Size (MB)", "Used (MB)", "Volume Name"; first=0}; printf formatStr, region, $1, $6, $3, $4, $5, volidCapacities[$3], $2}' < $volumeList
0 commit comments