Azure云平台创建经典虚拟机(Windows)后,发现仪表板的监测项下默认是没有针对磁盘空间进行检测的指标的
本地机器安装Windows Azure Powershell模块,并通过如下命令登陆并查看到默认的诊断扩展是没有Disk Free Space参数的
Add-AzureAccount -Environment AzureChinaCloud $vm = Get-AzureVM -ServiceName hlmcloudsn1-*** -Name hlmwin12n1-*** $PublicConfiguration = (Get-AzureVMDiagnosticsExtension -VM $vm).PublicConfiguration $encodedconfig = (ConvertFrom-Json -InputObject $PublicConfiguration).xmlCfg $xmlconfig = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($encodedconfig)) Write-Host $xmlconfig
参考Azure官网(https://docs.microsoft.com/zh-cn/azure/virtual-machines/extensions/diagnostics-windows#sample-diagnostics-configuration)说明,了解到可以对诊断扩展的参数进行自定义,因此在原有的配置文件中加入针对单块盘的指控指标即可对单块磁盘的使用量进行检测,编辑后的配置文件见下(标黄内容为新添加的内容,需要根据实际环境进行替换)
<?xml version="1.0" encoding="utf-8"?> <PublicConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration"> <WadCfg> <DiagnosticMonitorConfiguration overallQuotaInMB="4096"> <DiagnosticInfrastructureLogs scheduledTransferLogLevelFilter="Error"/> <PerformanceCounters scheduledTransferPeriod="PT1M"> <PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% Processor Time" sampleRate="PT15S" unit="Percent"> <annotation displayName="CPU utilization" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% Privileged Time" sampleRate="PT15S" unit="Percent"> <annotation displayName="CPU privileged time" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% User Time" sampleRate="PT15S" unit="Percent"> <annotation displayName="CPU user time" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\Processor Information(_Total)\Processor Frequency" sampleRate="PT15S" unit="Count"> <annotation displayName="CPU frequency" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\System\Processes" sampleRate="PT15S" unit="Count"> <annotation displayName="Processes" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\Process(_Total)\Thread Count" sampleRate="PT15S" unit="Count"> <annotation displayName="Threads" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\Process(_Total)\Handle Count" sampleRate="PT15S" unit="Count"> <annotation displayName="Handles" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\Memory\% Committed Bytes In Use" sampleRate="PT15S" unit="Percent"> <annotation displayName="Memory usage" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\Memory\Available Bytes" sampleRate="PT15S" unit="Bytes"> <annotation displayName="Memory available" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\Memory\Committed Bytes" sampleRate="PT15S" unit="Bytes"> <annotation displayName="Memory committed" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\Memory\Commit Limit" sampleRate="PT15S" unit="Bytes"> <annotation displayName="Memory commit limit" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\Memory\Pool Paged Bytes" sampleRate="PT15S" unit="Bytes"> <annotation displayName="Memory paged pool" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\Memory\Pool Nonpaged Bytes" sampleRate="PT15S" unit="Bytes"> <annotation displayName="Memory non-paged pool" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\% Disk Time" sampleRate="PT15S" unit="Percent"> <annotation displayName="Disk active time" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\% Disk Read Time" sampleRate="PT15S" unit="Percent"> <annotation displayName="Disk active read time" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\% Disk Write Time" sampleRate="PT15S" unit="Percent"> <annotation displayName="Disk active write time" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Disk Transfers/sec" sampleRate="PT15S" unit="CountPerSecond"> <annotation displayName="Disk operations" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Disk Reads/sec" sampleRate="PT15S" unit="CountPerSecond"> <annotation displayName="Disk read operations" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Disk Writes/sec" sampleRate="PT15S" unit="CountPerSecond"> <annotation displayName="Disk write operations" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Disk Bytes/sec" sampleRate="PT15S" unit="BytesPerSecond"> <annotation displayName="Disk speed" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Disk Read Bytes/sec" sampleRate="PT15S" unit="BytesPerSecond"> <annotation displayName="Disk read speed" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Disk Write Bytes/sec" sampleRate="PT15S" unit="BytesPerSecond"> <annotation displayName="Disk write speed" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Avg. Disk Queue Length" sampleRate="PT15S" unit="Count"> <annotation displayName="Disk average queue length" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Avg. Disk Read Queue Length" sampleRate="PT15S" unit="Count"> <annotation displayName="Disk average read queue length" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Avg. Disk Write Queue Length" sampleRate="PT15S" unit="Count"> <annotation displayName="Disk average write queue length" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\LogicalDisk(_Total)\% Free Space" sampleRate="PT15S" unit="Percent"> <annotation displayName="Disk free space (percentage)" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\LogicalDisk(_Total)\Free Megabytes" sampleRate="PT15S" unit="Count"> <annotation displayName="Disk free space (MB)" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\LogicalDisk(C:)\Free Megabytes" sampleRate="PT15S" unit="Count"> <annotation displayName="C: free space (MB)" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\LogicalDisk(D:)\Free Megabytes" sampleRate="PT15S" unit="Count"> <annotation displayName="D: free space (MB)" locale="en-us"/> </PerformanceCounterConfiguration> <PerformanceCounterConfiguration counterSpecifier="\LogicalDisk(F:)\Free Megabytes" sampleRate="PT15S" unit="Count"> <annotation displayName="F: free space (MB)" locale="en-us"/> </PerformanceCounterConfiguration> </PerformanceCounters> <Metrics resourceId="/subscriptions/0b4b20c5-29b3-4dd9-bfdc-40b75f1dc4c9/resourceGroups/hlmrgn1/providers/Microsoft.ClassicCompute/virtualMachines/hlmwin12n1-cla1" > <MetricAggregation scheduledTransferPeriod="PT1H"/> <MetricAggregation scheduledTransferPeriod="PT1M"/> </Metrics> <WindowsEventLog scheduledTransferPeriod="PT1M"> <DataSource name="Application!*[System[(Level = 1 or Level = 2)]]"/> <DataSource name="Security!*[System[(Level = 1 or Level = 2)]"/> <DataSource name="System!*[System[(Level = 1 or Level = 2)]]"/> </WindowsEventLog> </DiagnosticMonitorConfiguration> </WadCfg> <StorageAccount>hlmston1t2cla</StorageAccount> </PublicConfig>
使用如下命令,跟新诊断扩展(将如上文件保存为DiagnosticsPubConfig.xml文件)
$vm = Get-AzureVM -ServiceName hlmcloudsn1-*** -Name hlmwin12n1-***$Config_Path = "C:\Users\he.liming\Desktop\DiagnosticsPubConfig.xml" $Storage_Context = New-AzureStorageContext -StorageAccountName "hlmston1t2***" -StorageAccountKey "qlIs3Oc9vPqpkCQsf9Lk6oqKfbHbrPUNz3xNqm9VgcUPug8U7XfX***" $vm_Update = Set-AzureVMDiagnosticsExtension -DiagnosticsConfigurationPath $Config_Path -VM $vm -StorageContext $Storage_Context Update-AzureVM -ServiceName hlmcloudsn1-*** -Name hlmwin12n1-*** -VM $vm_Update.VM
查看虚拟机的仪表板,发现已经可以查看自定义的盘符分区大小了
I hear and I forget. I see and I remeber. I do and I understand!