Azure Monitor VM 见解中的 Dependency Agent

Dependency Agent 收集有关虚拟机上运行的进程及其外部进程依赖项的数据。 更新包括漏洞修复或对新功能或特性的支持。 本文介绍 Dependency Agent 要求以及如何手动或通过自动化对其进行升级。

注意

Dependency Agent 将检测信号数据发送到 InsightsMetrics 表,此过程会产生数据引入费用。 此行为不同于 Azure Monitor 代理,后者会将代理运行状况数据发送到心跳表,不收取数据收集费用。

Dependency Agent 要求

  • Azure Monitor 代理必须安装在同一台计算机上。
  • 需要从虚拟机连接到地址 169.254.169.254。 该地址识别 Azure 元数据服务终结点。

支持的操作系统

VM 见解支持以下操作系统:

  • VM Insights 支持 Azure Monitor 代理所支持的所有操作系统。 请参阅 Azure Monitor 代理支持的操作系统和环境
  • 依赖项代理当前支持的 Windows 版本与 Azure Monitor 代理支持的 Windows 版本相同,涵盖到 Windows Server 2022,但不包括 Azure Stack HCI 和 Windows IoT Enterprise。 不支持 Windows Server Core。
  • 有关 Dependency Agent 的 Linux 支持,请参阅 Dependency Agent Linux 支持Linux 注意事项
  • Dependency Agent 仅支持 x64 体系结构。

Linux 注意事项

在 Linux 计算机上安装 VM Insights 依赖项代理之前,请考虑以下事项:

  • 仅默认版本和 SMP Linux 内核版本受支持。
  • 任何 Linux 发行版都不支持非标准内核版本,例如物理地址扩展 (PAE) 和 Xen。 例如,不支持版本字符串为 2.6.16.21-0.8-xen 的系统。
  • 不支持自定义内核(包括标准内核的重新编译)。
  • 对于 Debian 发行版,除 9.4 版本外,不支持地图功能。 性能功能仅适用于 Azure Monitor 菜单。 无法直接在 Azure VM 的左窗格中使用此功能。
  • 支持 CentOSPlus 内核。
  • 安装 Dependency Agent 会污染 Linux 内核,并且在机器重新启动之前,您可能会失去对 Linux 发行版的支持。

必须为 Spectre 和 Meltdown 漏洞修补 Linux 内核。 有关详细信息,请咨询 Linux 发行版供应商。 如果 Spectre/Meltdown 已缓解,运行以下命令检查可用性:

$ grep . /sys/devices/system/cpu/vulnerabilities/*

此命令的输出如下所示,并指定计算机是否容易出现任一问题。 如果缺少这些文件,则表明未修补计算机。

/sys/devices/system/cpu/vulnerabilities/meltdown:Mitigation: PTI
/sys/devices/system/cpu/vulnerabilities/spectre_v1:Vulnerable
/sys/devices/system/cpu/vulnerabilities/spectre_v2:Vulnerable: Minimal generic ASM retpoline

安装或升级 Dependency Agent

注意

在计算机上启用 VM Insights 以获取进程和连接数据时,会自动安装 Dependency Agent。 如果仅为性能数据启用了 VM Insights,则不会安装 Dependency Agent。

可以使用以下方法手动或自动升级适用于 Windows 和 Linux 的 Dependency Agent,具体取决于计算机运行的部署方案和环境:

环境 安装方法 升级方法
Azure VM 适用于 WindowsLinux 的 Dependency Agent VM 扩展 默认情况下 Agent 会自动升级,除非你通过将 autoUpgradeMinorVersion 属性设置为 false 来将 Azure 资源管理器模板配置为“选择退出”。 禁用自动升级的次要版本升级和主版本升级遵循相同的方法 - 卸载并重新安装扩展。
自定义 Azure VM 映像 手动安装 Dependency Agent(适用于 Windows/Linux) 将 VM 更新到最新版本的代理需要从命令行运行 Windows 安装程序包或 Linux 自解压和可安装的 shell 脚本包。
非 Azure 虚拟机 手动安装 Dependency Agent(适用于 Windows/Linux) 将 VM 更新到最新版本的代理需要从命令行运行 Windows 安装程序包或 Linux 自解压和可安装的 shell 脚本包。

在 Windows 上手动安装或升级 Dependency Agent

从命令提示符使用脚本或其他自动化解决方案,或者使用 InstallDependencyAgent-Windows.exe 安装向导更新 Windows VM 上的代理。

先决条件

使用安装向导

  1. 使用具有管理权限的帐户登录到计算机。

  2. 执行 InstallDependencyAgent-Windows.exe 以启动安装向导。

  3. 按照“Dependency Agent 安装向导”的要求卸载以前版本的 Dependency Agent,然后安装最新版本。

通过命令行

  1. 使用具有管理权限的帐户登录到计算机。

  2. 运行下面的命令:

    InstallDependencyAgent-Windows.exe /S /RebootMode=manual
    

    /RebootMode=manual 参数可防止此升级在某些进程使用以前版本的文件并对其进行锁定的情况下自动重启计算机。

  3. 若要确认升级是否成功,请查看 install.log,了解详细的安装信息。 日志目录为 %Programfiles%\Microsoft Dependency Agent\logs

在 Linux 上手动安装或升级 Dependency Agent

从 Linux 上的旧版 Dependency Agent 进行升级是受支持的操作,进行升级时使用与新安装相同的命令。

先决条件

curl -L -o DependencyAgent-Linux64.bin https://aka.ms/dependencyagentlinux

注意

curl 不会自动设置执行权限。 需要使用 chmod 手动设置它们:

chmod +x DependencyAgent-Linux64.bin

通过命令行

  1. 使用具有 sudo 特权的用户帐户登录计算机,以 root 身份执行命令。

  2. 运行下面的命令:

    sudo <path>/InstallDependencyAgent-Linux64.bin
    

如果 Dependency Agent 无法启动,请检查日志以获取详细的错误信息。 在 Linux 代理上,日志目录是 /var/opt/microsoft/dependency-agent/log

卸载依赖关系代理

注意

如果手动安装 Dependency Agent,则它不会显示在 Azure 门户中,必须手动卸载。 仅当通过 Azure 门户PowerShellARM 模板部署Azure Policy 安装时,才会显示它。

  1. 从 Azure 门户的“虚拟机”菜单中,选择虚拟机。

  2. 选择“扩展+应用程序”>“DependencyAgentWindows”“DependencyAgentLinux”>“卸载”

    显示虚拟机的“扩展和应用程序”屏幕的屏幕截图。

手动卸载 Windows 上的 Dependency Agent

方法 1:在 Windows 中,转到“添加和删除程序”,找到“Microsoft Dependency Agent”,单击省略号以打开上下文菜单,然后选择“卸载”

方法 2:使用位于 Microsoft Dependency Agent 文件夹中的卸载程序,例如 (其中 v.w.x.y 是版本号)。C:\Program Files\Microsoft Dependency Agent"\Uninstall_v.w.x.y.exe

手动卸载 Linux 上的 Dependency Agent

  1. 使用具有 sudo 特权的用户帐户登录计算机,以 root 身份执行命令。

  2. 运行下面的命令:

    sudo /opt/microsoft/dependency-agent/uninstall -s
    

Dependency Agent Linux 支持

由于 Dependency Agent 在内核级别工作,因此支持也依赖于内核版本。 从 Dependency Agent 版本 9.10.* 开始,代理支持 * 内核。 下表列出了 Dependency Agent 的主要和次要 Linux OS 版本以及支持的内核版本。

注意

使用 Dependency Agent 9.10.15 及更高版本时,不阻止安装不受支持的内核版本,但代理将运行在降级模式下。 在此模式下,不会收集存储在 VMConnection 和 VMBoundport 表中的连接和端口数据。 VMProcess 表可能包含一些数据,但数据量最少。

分发 OS 版本 内核版本
Red Hat Linux 8 8.6 4.18.0-372.*el8.x86_64、4.18.0-372.*el8_6.x86_64
8.5 4.18.0-348.*el8_5.x86_644.18.0-348.*el8.x86_64
8.4 4.18.0-305.*el8.x86_64、4.18.0-305.*el8_4.x86_64
8.3 4.18.0-240.*el8_3.x86_64
8.2 4.18.0-193.*el8_2.x86_64
8.1 4.18.0-147.*el8_1.x86_64
8.0 4.18.0-80.*el8.x86_64
4.18.0-80.*el8_0.x86_64
Red Hat Linux 7 7.9 3.10.0-1160
7.8 3.10.0-1136
7.7 3.10.0-1062
7.6 3.10.0-957
7.5 3.10.0-862
7.4 3.10.0-693
Red Hat Linux 6 6.10 2.6.32-754
6.9 2.6.32-696
CentOS Linux 8 8.6 4.18.0-372.*el8.x86_64、4.18.0-372.*el8_6.x86_64
8.5 4.18.0-348.*el8_5.x86_644.18.0-348.*el8.x86_64
8.4 4.18.0-305.*el8.x86_64、4.18.0-305.*el8_4.x86_64
8.3 4.18.0-240.*el8_3.x86_64
8.2 4.18.0-193.*el8_2.x86_64
8.1 4.18.0-147.*el8_1.x86_64
8.0 4.18.0-80.*el8.x86_64
4.18.0-80.*el8_0.x86_64
CentOS Linux 7 7.9 3.10.0-1160
7.8 3.10.0-1136
7.7 3.10.0-1062
CentOS Linux 6 6.10 2.6.32-754.3.5
2.6.32-696.30.1
6.9 2.6.32-696.30.1
2.6.32-696.18.7
Ubuntu Server 20.04 5.8
5.4*
18.04 5.3.0-1020
5.0(包括 Azure 优化内核)
4.18*
4.15*
16.04.3 4.15.*
16.04 4.13.*
4.11.*
4.10.*
4.8.*
4.4.*
14.04 3.13.*-generic
4.4.*-generic
SUSE Linux 12 Enterprise Server 12 SP5 4.12.14-122.*-default、4.12.14-16.*-azure
12 SP4 4.12.*(包括 Azure 优化内核)
12 SP3 4.4.*
12 SP2 4.4.*
SUSE Linux 15 企业服务器 15 SP1 4.12.14-197.*-default、4.12.14-8.*-azure
15 4.12.14-150.*-default
Debian 9 4.9

注意

具有基于 Ampere Altra ARM 的处理器的 Azure 虚拟机不支持 Dependency Agent。

后续步骤

如果要停止监视 VM 一段时间,或者要完全删除 VM Insights,请参阅在 VM Insights 中禁用对 VM 的监视