Available Storage on FSx

0

I am using the CLI and Boto3 trying to get the current available storage for an FSx. Using the describe_file_systems function I can get the capacity but I am looking to get either current storage or available storage. How can I get one of these items programmatically?

gefragt vor einem Jahr407 Aufrufe
2 Antworten
0

The documentation here suggests that "describe-file-systems" can be used to check the status of the file.
https://docs.aws.amazon.com/fsx/latest/WindowsGuide/file-system-lifecycle-states.html

Since there is no option to filter by status in the request, we can use an if statement to display only those whose "Lifecycle" is "AVAILABLE".
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/fsx/client/describe_file_systems.html

This is a sample, but I thought the following would show only the available file storage capacity.

import boto3

client = boto3.client('fsx')

response = client.describe_file_systems()

file_systems_list = response['FileSystems']

for file_system in file_systems_list:
  if file_system['Lifecycle'] == 'AVAILABLE':
    print(file_system['FileSystemId'])
    print(file_system['StorageCapacity'])
profile picture
EXPERTE
beantwortet vor einem Jahr
0

Hi,

You can get this information from CloudWatch Metrics programmatically.

Documentation on how you can get this with the CLI is available here:

https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/get-metric-statistics.html

The metric names will differ slightly based on which FSx you are using. You can list the available metrics using aws cloudwatch list-metrics --namespace AWS/FSx

Below is an example for FSx ONTAP, which will show the minimum storage used in the past 24hrs, you can change your start / end time and period to suit your needs.

aws cloudwatch get-metric-statistics --namespace AWS/FSx --metric-name StorageUsed --start-time "$(date -d '-1 day' '+%F %T')" --end-time "$(date -d '-1 hour' '+%F %T')" --period 86400 --statistics Minimum --region
 eu-west-2 --dimensions Name=FileSystemId,Value=<<File System ID HERE>>
AWS
Tom-B
beantwortet vor einem Jahr

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen