如何使用 Windows 操作系统 (OS) Azure Monitor 代理疑难解答

Azure Monitor 代理 (AMA) 疑难解答旨在帮助识别代理问题并执行常规运行状况评估。 它可以执行各种检查,以确保正确安装和连接代理,还可以从被诊断的计算机收集与 AMA 相关的日志。

注意

Windows AMA 疑难解答是一个命令行可执行文件,版本高于 1.12.0.0 的所有代理都附带了该文件。

先决条件

检查疑难解答是否存在

检查要诊断的计算机上是否存在 AMA 代理疑难解答目录,以确认是否安装了代理疑难解答:

C:/Packages/Plugins/Microsoft.Azure.Monitor.AzureMonitorWindowsAgent

若要验证代理疑难解答是否存在,请复制以下命令并在 PowerShell 中以管理员身份运行:

Test-Path -Path "C:/Packages/Plugins/Microsoft.Azure.Monitor.AzureMonitorWindowsAgent"

如果目录存在,则 Test-Path cmdlet 将返回 True

Screenshot of the PowerShell window, which shows the result of Test-Path PowerShell cmdlet.

如果目录不存在或安装失败,请按照基本故障排除步骤操作。

是,该目录存在。 继续运行疑难解答

运行疑难解答

请在要诊断的计算机上运行代理疑难解答。

若要启动代理疑难解答,请复制以下命令并在 PowerShell 中以管理员身份运行:

$currentVersion = ((Get-ChildItem -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Azure\HandlerState\" `
    | where Name -like "*AzureMonitorWindowsAgent*" `
    | ForEach-Object {$_ | Get-ItemProperty} `
    | where InstallState -eq "Enabled").PSChildName -split('_'))[1]

$troubleshooterPath = "C:\Packages\Plugins\Microsoft.Azure.Monitor.AzureMonitorWindowsAgent\$currentVersion\Troubleshooter"
Set-Location -Path $troubleshooterPath
Start-Process -FilePath $troubleshooterPath\AgentTroubleshooter.exe -ArgumentList "--ama"
Invoke-Item $troubleshooterPath

它会运行一系列最多可能需要 15 分钟完成的活动。 请耐心等待该过程完成。

Screenshot of the PowerShell window, which shows the result of the AgentTroubleshooter.

日志文件是在 AgentTroubleshooter.exe 所在的目录中创建的。

Screenshot of the Windows explorer window, which shows the output of the AgentTroubleshooter.

常见问题

是否可以将疑难解答从较新的代理复制到较旧的代理,并在较旧的代理上运行以诊断旧代理的问题?

无法通过复制代理来使用疑难解答诊断旧版代理。 必须拥有最新版本的代理,才能正常运行疑难解答。

后续步骤