Skip to content

Commit 89a8885

Browse files
committed
Added capacity information.
1 parent 84bb189 commit 89a8885

2 files changed

Lines changed: 12 additions & 13 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Usage $(basename $0) [-r region] [-a] [-n] [-c] [-s] [-b] [-i fileSystemId] [-f
4949
-c means to display a hierarchical view of each filesystem including svms and volumes.
5050
-i allows you to limit the display to the file system with the id provided.
5151
-f allows you to limit the display to the file system with the name provided.
52-
-b means to display the backup retenion period. Not compoatible with the -x or -c options.
52+
-b means to display the backup retenion period. Not compatible with the -x or -c options.
5353
-s means to display the current status of a volume. Only relative with the -c option.
5454
-n means to show the AWS ARN for the file system. Not compatible with -x or -c options.
5555
-x means include additional information: vpc, subnet, Size, Deployement Type, Throughput, provisioned IOPS, usage.
@@ -69,7 +69,7 @@ cloudwatchQueryFile=/tmp/list_fss-cloudwatch-query.$$
6969
fsCapacityFile=/tmp/list_fss-fscapacity.$$
7070
trap 'rm -f $tmpout $fileSystemsFile $svmsFile $volumesFile $cloudwatchOutputFile $cloudwatchQueryFile $fsCapacityFile' exit
7171
#
72-
# Ensure all the required ultilities are installed.
72+
# Ensure all the required utilities are installed.
7373
if which aws jq > /dev/null 2>&1; then
7474
:
7575
else
@@ -299,7 +299,7 @@ EOF
299299
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
300300
for fsid in $fsxIds; do
301301
fsid2=$(echo $fsid | sed -e 's/-/_/g')
302-
storageUsed=$(jq -r '.MetricDataResults[] | if(.Id == "'${fsid2}_StorageUsed'") then .Values[0] else empty end' $cloudwatchOutputFile)
302+
storageUsed=$(jq -r '.MetricDataResults[] | if(.Id == "'${fsid2}_StorageUsed'") then .Values[0] // 0 else empty end' $cloudwatchOutputFile)
303303
echo "$fsid,$storageUsed" >> $fsCapacityFile
304304
done
305305

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
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.
4646
EOF
4747
exit 1
4848
}
@@ -105,8 +105,8 @@ if [ ! -z "$1" ]; then
105105
volumePattern="$1"
106106
fi
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
111111
fi
112112

@@ -154,7 +154,6 @@ fi
154154
jqFields='\(.FileSystemId),\(.Name),\(.VolumeId),\(.Lifecycle),\(.OntapConfiguration.SizeInMegabytes),\(.OntapConfiguration.StorageVirtualMachineId)'
155155
#
156156
# Loop on all the regions.
157-
fields='\(.FileSystemId),\(.Name),\(.VolumeId),\(.Lifecycle),\(.OntapConfiguration.StorageVirtualMachineId)'
158157
for region in ${regions[*]}; do
159158
#
160159
# Check that the fsx service is supported in thie region
@@ -217,7 +216,7 @@ EOF
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

Comments
 (0)