简体   繁体   English

使用 XML 文件同时为多个虚拟机启用 Windows Azure 诊断扩展 (WAD)

[英]Enable Windows Azure Diagnostics extension (WAD) with XML file to multiple vms at the same time

I'm trying to enable Azure Diagnostics extension (WAD) with Powershell / Azurebook using XML file.我正在尝试使用 XML 文件通过 Powershell/Azurebook 启用 Azure 诊断扩展 (WAD)。 I'm able to get this working only on single vm at time because XML file has this line in there (without it don't work, atleast i think so link to it ) where i specify vm's name and resource group.我当时只能在单个 vm 上使用它,因为 XML 文件中有这一行(没有它不起作用,至少我认为链接到它),我在其中指定了 vm 的名称和资源组。

<Metrics resourceId="/subscriptions/11111111-1111-1111-1111111111111111/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/MyWindowsVM" >

My XML file which is stored in Azure storage account.我的 XML 文件存储在 Azure 存储帐户中。

<?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="PT60S" unit="Percent">
        <annotation displayName="CPU utilization" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% Privileged Time" sampleRate="PT60S" unit="Percent">
        <annotation displayName="CPU privileged time" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% User Time" sampleRate="PT60S" unit="Percent">
        <annotation displayName="CPU user time" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\Processor Information(_Total)\Processor Frequency" sampleRate="PT60S" unit="Count">
        <annotation displayName="CPU frequency" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\System\Processes" sampleRate="PT60S" unit="Count">
        <annotation displayName="Processes" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\Process(_Total)\Thread Count" sampleRate="PT60S" unit="Count">
        <annotation displayName="Threads" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\Process(_Total)\Handle Count" sampleRate="PT60S" unit="Count">
        <annotation displayName="Handles" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\Memory\% Committed Bytes In Use" sampleRate="PT60S" unit="Percent">
        <annotation displayName="Memory usage" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\Memory\Available Bytes" sampleRate="PT60S" unit="Bytes">
        <annotation displayName="Memory available" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\Memory\Committed Bytes" sampleRate="PT60S" unit="Bytes">
        <annotation displayName="Memory committed" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\Memory\Commit Limit" sampleRate="PT60S" unit="Bytes">
        <annotation displayName="Memory commit limit" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\Memory\Pool Paged Bytes" sampleRate="PT60S" unit="Bytes">
        <annotation displayName="Memory paged pool" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\Memory\Pool Nonpaged Bytes" sampleRate="PT60S" unit="Bytes">
        <annotation displayName="Memory non-paged pool" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\% Disk Time" sampleRate="PT60S" unit="Percent">
        <annotation displayName="Disk active time" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\% Disk Read Time" sampleRate="PT60S" unit="Percent">
        <annotation displayName="Disk active read time" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\% Disk Write Time" sampleRate="PT60S" unit="Percent">
        <annotation displayName="Disk active write time" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Disk Transfers/sec" sampleRate="PT60S" unit="CountPerSecond">
        <annotation displayName="Disk operations" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Disk Reads/sec" sampleRate="PT60S" unit="CountPerSecond">
        <annotation displayName="Disk read operations" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Disk Writes/sec" sampleRate="PT60S" unit="CountPerSecond">
        <annotation displayName="Disk write operations" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Disk Bytes/sec" sampleRate="PT60S" unit="BytesPerSecond">
        <annotation displayName="Disk speed" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Disk Read Bytes/sec" sampleRate="PT60S" unit="BytesPerSecond">
        <annotation displayName="Disk read speed" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Disk Write Bytes/sec" sampleRate="PT60S" unit="BytesPerSecond">
        <annotation displayName="Disk write speed" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Avg. Disk Queue Length" sampleRate="PT60S" unit="Count">
        <annotation displayName="Disk average queue length" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Avg. Disk Read Queue Length" sampleRate="PT60S" unit="Count">
        <annotation displayName="Disk average read queue length" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\PhysicalDisk(_Total)\Avg. Disk Write Queue Length" sampleRate="PT60S" unit="Count">
        <annotation displayName="Disk average write queue length" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\LogicalDisk(_Total)\% Free Space" sampleRate="PT60S" unit="Percent">
        <annotation displayName="Disk free space (percentage)" locale="en-us"/>
      </PerformanceCounterConfiguration>
      <PerformanceCounterConfiguration counterSpecifier="\LogicalDisk(_Total)\Free Megabytes" sampleRate="PT60S" unit="Count">
        <annotation displayName="Disk free space (MB)" locale="en-us"/>
      </PerformanceCounterConfiguration>
    </PerformanceCounters>
    **<Metrics resourceId="/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/MyWindowsVM" >**
        <MetricAggregation scheduledTransferPeriod="PT1H"/>
        <MetricAggregation scheduledTransferPeriod="PT1M"/>
    </Metrics>
    <WindowsEventLog scheduledTransferPeriod="PT1M">
      <DataSource name="Application!*[System[(Level=1 or Level=2 or Level=3)]]"/>
      <DataSource name="Security!*[System[(Level=0 or Level=1)]]"/>
      <DataSource name="System!*[System[(Level=1 or Level=2 or Level=3)]]"/>
    </WindowsEventLog>
      </DiagnosticMonitorConfiguration>
            <SinksConfig>
<Sink name="AzureMonitorSink">
            <AzureMonitor> 
           </AzureMonitor>
        </Sink>
 </SinksConfig>
    </WadCfg>
    <StorageAccount>storage account name</StorageAccount>
</PublicConfig>

Then I found this diagnostics-configuration-variables where it stated I could somehow maybe be possible to insert more vm names or somehow dodge that line so I could mass install that without needed to change xml after every install but things it that my xml and another scripting skills kinda ended already...然后我发现了这个诊断配置变量,它说我可以以某种方式插入更多的虚拟机名称或以某种方式避开该行,这样我就可以批量安装它而无需在每次安装后更改 xml 但它是我的 xml 和另一个脚本技能已经结束了......

Do you have ideas how could this be done so I could use that xml (or maybe json?) file to install that extension to many vm's at the same time using Powershell / Runbooks?您是否知道如何做到这一点,以便我可以使用该 xml(或者可能是 json?)文件使用 Powershell/Runbooks 同时将该扩展安装到许多虚拟机?

Script that I use to deploy extension which work with one vm at the time.我用来部署扩展的脚本,当时它与一个虚拟机一起工作。

$SAResourceGroupName="rg name"
$StorageAccountName="storage account name"

$StorageAccountKey = (Get-AzStorageAccountKey -ResourceGroupName $SAResourceGroupName -AccountName $StorageAccountName).Value[1]
$Context=New-AzStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey

$tmpStart = Get-Date
$tmpEnd = $tmpStart.AddHours(2.0)
$SASToken = New-AzStorageBlobSASToken -Blob "DiagnosticsPubConfig.xml" -Container "scripts" -Context $Context -Permission r -StartTime $tmpStart -ExpiryTime $tmpEnd -FullURI



Set-AzVMDiagnosticsExtension -ResourceGroupName COMMVM-SUB2012-RG -VMName nalle9002 -DiagnosticsConfigurationPath "$SASToken" -StorageAccountName storage account name 

I got it somehow working with using this in xml.我以某种方式在 xml 中使用它。

<Metrics resourceId="/subscriptions/subscription().subscriptionId/resourceGroups/resourceGroup().name/providers/Microsoft.Compute/virtualMachines/vmName">

When using Powershell I get error but it still works (at least for now).使用 Powershell 时出现错误,但它仍然有效(至少目前是这样)。

WARNING: The resourceId defined in the config file does not match the actual resource's id.警告:配置文件中定义的 resourceId 与实际资源的 ID 不匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM