Skip to content

Commit d5b0d69

Browse files
committed
add metrics for managed os disk
1 parent d3752bc commit d5b0d69

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

src/ResourceManager/Compute/Commands.Compute/Extension/AEM/AEMExtensionConstants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public static class AEMExtensionConstants
4040

4141
public const string DISK_TYPE_STANDARD = "Standard";
4242
public const string DISK_TYPE_PREMIUM = "Premium";
43+
public const string DISK_TYPE_PREMIUM_MD = "PremiumMD";
4344
public const string WadTableName = "WADPerformanceCountersTable";
4445
public const string AzureEndpoint = "core.windows.net";
4546
public const int ContentAgeInMinutes = 5;

src/ResourceManager/Compute/Commands.Compute/Extension/AEM/AEMHelper.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ internal bool IsPremiumStorageAccount(string accountName)
104104

105105
internal int? GetDiskSizeGbFromBlobUri(string sBlobUri)
106106
{
107+
if (String.IsNullOrEmpty(sBlobUri))
108+
{
109+
return null;
110+
}
111+
107112
var blobMatch = Regex.Match(sBlobUri, "https?://(\\S*?)\\..*?/(.*)");
108113
if (!blobMatch.Success)
109114
{
@@ -321,7 +326,7 @@ internal bool IsPremiumStorageAccount(StorageAccount account)
321326
{
322327
if (account.AccountType.HasValue)
323328
{
324-
return (account.AccountType.Value.ToString().StartsWith("Premium"));
329+
return (account.AccountType.Value == AccountType.PremiumLRS);
325330
}
326331

327332
WriteError("No AccountType for storage account {0} found", account.Name);
@@ -330,19 +335,19 @@ internal bool IsPremiumStorageAccount(StorageAccount account)
330335

331336
internal AzureSLA GetDiskSLA(OSDisk osdisk)
332337
{
333-
return this.GetDiskSLA(osdisk.DiskSizeGB, osdisk.Vhd.Uri);
338+
return this.GetDiskSLA(osdisk.DiskSizeGB, osdisk.Vhd);
334339
}
335340

336341
internal AzureSLA GetDiskSLA(DataDisk datadisk)
337342
{
338-
return this.GetDiskSLA(datadisk.DiskSizeGB, datadisk.Vhd.Uri);
343+
return this.GetDiskSLA(datadisk.DiskSizeGB, datadisk.Vhd);
339344
}
340345

341-
internal AzureSLA GetDiskSLA(int? diskSize, string vhdUri)
346+
internal AzureSLA GetDiskSLA(int? diskSize, VirtualHardDisk vhd)
342347
{
343-
if (!diskSize.HasValue)
348+
if (!diskSize.HasValue && vhd != null)
344349
{
345-
diskSize = this.GetDiskSizeGbFromBlobUri(vhdUri);
350+
diskSize = this.GetDiskSizeGbFromBlobUri(vhd.Uri);
346351
}
347352
if (!diskSize.HasValue)
348353
{
@@ -363,7 +368,7 @@ internal AzureSLA GetDiskSLA(int? diskSize, string vhdUri)
363368
sla.IOPS = 2300;
364369
sla.TP = 150;
365370
}
366-
else if (diskSize > 0 && diskSize < 1025)
371+
else if (diskSize > 0 && diskSize < 1024)
367372
{
368373
// P30
369374
sla.IOPS = 5000;

src/ResourceManager/Compute/Commands.Compute/Extension/AEM/SetAzureRmVMAEMExtension.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,18 +207,36 @@ public override void ExecuteCmdlet()
207207
sapmonPublicConfig.Add(new KeyValuePair() { Key = "osdisk.connhour", Value = (accountName + ".hour") });
208208
}
209209
}
210+
else if (osdisk.ManagedDisk.StorageAccountType == StorageAccountTypes.PremiumLRS)
211+
{
212+
WriteVerbose("OS Disk Storage Account is a premium account - adding SLAs for OS disk");
213+
var sla = this._Helper.GetDiskSLA(osdisk);
214+
sapmonPublicConfig.Add(new KeyValuePair() { Key = "osdisk.type", Value = AEMExtensionConstants.DISK_TYPE_PREMIUM_MD });
215+
sapmonPublicConfig.Add(new KeyValuePair() { Key = "osdisk.sla.throughput", Value = sla.TP });
216+
sapmonPublicConfig.Add(new KeyValuePair() { Key = "osdisk.sla.iops", Value = sla.IOPS });
217+
}
210218
else
211219
{
212-
this._Helper.WriteWarning("[WARN] Managed Disks are not yet supported. Extension will be installed but no disk metrics will be available.");
220+
this._Helper.WriteWarning("[WARN] Standard Managed Disks are not supported. Extension will be installed but no disk metrics will be available.");
213221
}
214222

215223
// Get Storage accounts from disks
216224
var diskNumber = 1;
217225
foreach (var disk in disks)
218226
{
219-
if (disk.ManagedDisk != null)
227+
228+
if (disk.ManagedDisk != null && disk.ManagedDisk.StorageAccountType == StorageAccountTypes.PremiumLRS)
229+
{
230+
this._Helper.WriteVerbose("Data Disk {0} is a Premium Managed Disk - adding SLAs for disk", diskNumber.ToString());
231+
var sla = this._Helper.GetDiskSLA(disk);
232+
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.type." + diskNumber, Value = AEMExtensionConstants.DISK_TYPE_PREMIUM_MD });
233+
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.sla.throughput." + diskNumber, Value = sla.TP });
234+
sapmonPublicConfig.Add(new KeyValuePair() { Key = "disk.sla.iops." + diskNumber, Value = sla.IOPS });
235+
this._Helper.WriteVerbose("Done - Data Disk {0} is a Premium Managed Disk - adding SLAs for disk", diskNumber.ToString());
236+
}
237+
else if (disk.ManagedDisk != null)
220238
{
221-
this._Helper.WriteWarning("[WARN] Managed Disks are not yet supported. Extension will be installed but no disk metrics will be available.");
239+
this._Helper.WriteWarning("[WARN] Standard Managed Disks are not supported. Extension will be installed but no disk metrics will be available.");
222240
continue;
223241
}
224242

0 commit comments

Comments
 (0)