@@ -73,7 +73,7 @@ def getFSxNInfo(region):
7373 fsxnId = fsxn ['FileSystemId' ]
7474 count += 1
7575 metrics .append ({
76- "Id" : f"{ fsxnId .replace ('fs-' , 'm_' )} " ,
76+ "Id" : f"{ fsxnId .replace ('fs-' , 'm_' )} _StorageUsed " ,
7777 "MetricStat" : {
7878 "Metric" : {
7979 "Namespace" : "AWS/FSx" ,
@@ -97,15 +97,31 @@ def getFSxNInfo(region):
9797 },
9898 "ReturnData" : True
9999 })
100- if count > 100 :
100+
101+ metrics .append ({
102+ "Id" : f"{ fsxnId .replace ('fs-' , 'm_' )} _StorageSavings" ,
103+ "MetricStat" : {
104+ "Metric" : {
105+ "Namespace" : "AWS/FSx" ,
106+ "MetricName" : "StorageEfficiencySavings" ,
107+ "Dimensions" : [{
108+ "Name" : "FileSystemId" ,
109+ "Value" : fsxnId
110+ }]
111+ },
112+ "Period" : 300 ,
113+ "Stat" : "Average"
114+ },
115+ "ReturnData" : True
116+ })
117+ #
118+ # The maximum is 500 metrics per request. This loop has 2 metric per iteration.
119+ if count > 200 :
101120 response = cwClient .get_metric_data (MetricDataQueries = metrics ,
102121 StartTime = datetime .now () - timedelta (minutes = 10 ),
103122 EndTime = datetime .now ())
104123 for metric in response ['MetricDataResults' ]:
105- fsxnId = metric ['Id' ].replace ('m_' , 'fs-' )
106- fsxnUsageInfo [fsxnId ] = {
107- 'UsedCapacity' : metric ['Values' ][0 ] if len (metric ['Values' ]) > 0 else 'N/A' ,
108- 'StorageCapacity' : fsxn ['StorageCapacity' ]}
124+ fsxnUsageInfo [metric ['Id' ]] = metric
109125 count = 0
110126 metrics = []
111127
@@ -114,10 +130,8 @@ def getFSxNInfo(region):
114130 StartTime = datetime .now () - timedelta (minutes = 10 ),
115131 EndTime = datetime .now ())
116132 for metric in response ['MetricDataResults' ]:
117- fsxnId = metric ['Id' ].replace ('m_' , 'fs-' )
118- fsxnUsageInfo [fsxnId ] = {
119- 'UsedCapacity' : metric ['Values' ][0 ] if len (metric ['Values' ]) > 0 else 'N/A' ,
120- 'StorageCapacity' : fsxn ['StorageCapacity' ]}
133+ fsxnUsageInfo [metric ['Id' ]] = metric
134+
121135 #
122136 # Retrieve all the SVMs
123137 svmsData = fsxClient .describe_storage_virtual_machines ()
@@ -206,7 +220,8 @@ def getFSxNInfo(region):
206220 },
207221 "ReturnData" : True
208222 })
209-
223+ #
224+ # The maximum is 500 metrics per request. This loop has 6 metric per iteration.
210225 if count > 70 :
211226 response = cwClient .get_metric_data (MetricDataQueries = metrics ,
212227 StartTime = datetime .now () - timedelta (minutes = 10 ),
@@ -222,6 +237,7 @@ def getFSxNInfo(region):
222237 EndTime = datetime .now ())
223238 for metric in response ['MetricDataResults' ]:
224239 volumeUsageInfo [metric ['Id' ]] = metric
240+
225241################################################################################
226242# This function is used to generate a html version of the report.
227243################################################################################
@@ -238,20 +254,23 @@ def generateHTMLReport(region):
238254 fsxnId = fsxn ['FileSystemId' ]
239255 name = getTag ('Name' , fsxn .get ('Tags' , []))
240256 ontapConfig = fsxn ['OntapConfiguration' ]
241- if fsxnUsageInfo [fsxnId ][ 'UsedCapacity' ] != 'N/A' :
242- fileSystemUsedCapacity = int (fsxnUsageInfo [fsxnId ]['UsedCapacity' ]/ 1024 / 1024 / 1024 )
257+ if len ( fsxnUsageInfo [fsxnId . replace ( 'fs-' , 'm_' ) + '_StorageUsed' ][ 'Values' ]) > 0 :
258+ fileSystemUsedCapacity = int (fsxnUsageInfo [fsxnId . replace ( 'fs-' , 'm_' ) + '_StorageUsed' ]['Values' ][ 0 ]/ 1024 / 1024 / 1024 )
243259 percentUsed = f"{ ((fileSystemUsedCapacity / fsxn ['StorageCapacity' ]) * 100 ):.2f} %"
244260 fileSystemUsedCapacity = f"{ fileSystemUsedCapacity } GB"
245261 else :
246262 fileSystemUsedCapacity = 'N/A'
247263 percentUsed = 'N/A'
264+ fileSystemStorageSavings = f"{ fsxnUsageInfo [fsxnId .replace ('fs-' , 'm_' ) + '_StorageSavings' ]['Values' ][0 ]/ 1024 / 1024 / 1024 :.2f} GB" if len (fsxnUsageInfo [fsxnId .replace ('fs-' , 'm_' ) + '_StorageSavings' ]['Values' ]) > 0 else 'N/A'
248265 htmlBody += f'<tr><td colspan=11 style="{ tableCellStyle } "><b>ID:</b> { fsxnId } <br>\n '
249266 htmlBody += f"<b>Name:</b> { name } <br>\n "
250267 htmlBody += f"<b>Region:</b> { region } <br>\n "
251268 htmlBody += f"<b>Availability:</b> { ontapConfig ['DeploymentType' ]} <br>\n "
269+ htmlBody += f"<b>Provisioned Throughput Capacity:</b> { ontapConfig ['ThroughputCapacity' ]} MB/s<br>\n "
252270 htmlBody += f"<b>Provisioned Performance Tier Storage:</b> { fsxn ['StorageCapacity' ]} GB<br>\n "
253271 htmlBody += f"<b>Used Performance Tier Storage:</b> { fileSystemUsedCapacity } <br>\n "
254272 htmlBody += f"<b>Percent Used Performance Tier:</b> { percentUsed } <br>\n "
273+ htmlBody += f"<b>Storage Savings:</b> { fileSystemStorageSavings } <br>\n "
255274 htmlBody += "</td></tr>\n "
256275 htmlBody += f'<tr><td colspan=11 style="{ tableCellStyle } "><b>Volumes:</b></td></tr>\n '
257276 htmlBody += f'<tr><th style="{ tableCellStyle } ">Name</th><th style="{ tableCellStyle } ">SVM</th><th style="{ tableCellStyle } ">ID</th>\n '
@@ -306,15 +325,17 @@ def generateTextReport(region):
306325 backupConfig = fsxn .get ('AutomaticBackupRetentionDays' , 'N/A' )
307326 textReport += f"{ indent } Backup Configuration: { backupConfig } \n { indent } Maintenance Schedule: { ontapConfig ['WeeklyMaintenanceStartTime' ]} \n "
308327 textReport += f"{ indent } Provisioned Capacity: { fsxn ['StorageCapacity' ]} GB\n "
309- if fsxnUsageInfo [fsxnId ][ 'UsedCapacity' ] != 'N/A' :
310- fileSystemUsedCapacity = int (fsxnUsageInfo [fsxnId ]['UsedCapacity' ]/ 1024 / 1024 / 1024 )
328+ if len ( fsxnUsageInfo [fsxnId . replace ( 'fs-' , 'm_' ) + '_StorageUsed' ][ 'Values' ]) > 0 :
329+ fileSystemUsedCapacity = int (fsxnUsageInfo [fsxnId . replace ( 'fs-' , 'm_' ) + '_StorageUsed' ]['Values' ][ 0 ]/ 1024 / 1024 / 1024 )
311330 percentUsed = f"{ ((fileSystemUsedCapacity / fsxn ['StorageCapacity' ]) * 100 ):.2f} %"
312331 fileSystemUsedCapacity = f"{ fileSystemUsedCapacity } GB"
313332 else :
314333 fileSystemUsedCapacity = 'N/A'
315334 percentUsed = 'N/A'
316335 textReport += f"{ indent } Used Capacity: { fileSystemUsedCapacity } \n "
317336 textReport += f"{ indent } Percent Capacity Used: { percentUsed } \n "
337+ fileSystemStorageSavings = f"{ fsxnUsageInfo [fsxnId .replace ('fs-' , 'm_' ) + '_StorageSavings' ]['Values' ][0 ]/ 1024 / 1024 / 1024 :.2f} GB" if len (fsxnUsageInfo [fsxnId .replace ('fs-' , 'm_' ) + '_StorageSavings' ]['Values' ]) > 0 else 'N/A'
338+ textReport += f"{ indent } Storage Savings: { fileSystemStorageSavings } \n "
318339
319340 textReport += f"{ indent } Storage Virtual Machines:\n "
320341 for svm in svms :
0 commit comments