如果在Linux上Microsoft Defender for Endpoint出现问题,并且需要支持,系统可能会要求你提供客户端分析器工具的输出。 它是一种诊断工具,可帮助管理员和支持团队排查Microsoft Defender for Endpoint问题。 它收集有关安装、配置、服务运行状况、日志、连接状态等的详细信息。此工具主要用于检查系统运行状况、验证配置并帮助排查潜在问题。
您可以通过以下任一方式收集客户端分析器的诊断数据:
命令行:在设备上本地运行客户端分析仪。 参见 run-the-binary-version-of-the-client-analyzer 或 run-the-python-based-client-analyzer。
实时响应:在实时响应会话中远程运行客户端分析器。 请参阅 use-live-response-to-collect-diagnostics-log
调查包:从Microsoft Defender门户的设备页面收集调查包。 在 Linux 上,该包包含客户端分析器诊断。 参见 collect-investigation-package-from-devices
提示
观看此视频以获取客户端分析器的概述: Defender for Endpoint 客户端分析器概述
运行客户端分析器的二进制版本
客户端分析器的二进制版本可通过两种方式提供:
- 随 Linux 版 Microsoft Defender 一起提供
- 作为独立工具提供
运行 Microsoft Defender for Linux 附带的客户端分析器二进制文件:
注意
从 Microsoft Defender for Endpoint 版本101.25082.0000开始,客户端分析器随代理一起提供。 可以在以下位置找到它: /opt/microsoft/mdatp/tools/client_analyzer/binary
运行此工具会在 .zip 目录中生成一个 /tmp 文件形式的诊断包。
若要运行客户端分析器,请执行以下步骤:
转到目录
/opt/microsoft/mdatp/tools/client_analyzer/binary:cd /opt/microsoft/mdatp/tools/client_analyzer/binary使用根权限运行该工具以生成诊断包:
sudo ./MDESupportTool -d
下载并运行客户端分析器独立二进制工具
若要使用独立的 ClientAnalyzer 二进制文件,请完成以下步骤。
将 XMDE 客户端分析器二进制文件 工具下载到需要调查的 Linux 计算机上。 如果使用的是终端,请通过输入以下命令下载该工具:
wget --quiet -O XMDEClientAnalyzerBinary.zip "https://go.microsoft.com/fwlink/?linkid=2336125"验证下载:
echo '5F906591D33D675F14D73D5B658A796CEC7480B023B18D45C5D687713A4D4FBB XMDEClientAnalyzerBinary.zip' | sha256sum -c在计算机上提取
XMDEClientAnalyzerBinary.zip的内容。unzip -q XMDEClientAnalyzerBinary.zip -d XMDEClientAnalyzerBinary更改目录:
cd XMDEClientAnalyzerBinary将生成两个新的 zip 文件:
- SupportToolLinuxamd64Binary.zip:适用于 x86 Linux 设备
- SupportToolLinuxarm64Binary.zip:适用于 ARM Linux设备
根据Linux OS 体系结构解压缩特定 zip。 例如,此处使用
SupportToolLinuxamd64Binary.zip文件。unzip -q SupportToolLinuxamd64Binary.zip使用根权限运行该工具以生成诊断包:
sudo ./MDESupportTool -d
运行基于 Python 的客户端分析器
Python 版本的客户端分析器以两种方式提供:
- 随 Linux 版 Microsoft Defender 一起提供
- 作为独立工具提供
注意
- 分析器依赖几个额外的 PIP 包(
decorator、sh、distro、lxml和psutil),这些包需要在操作系统中以 root 身份安装,以生成结果输出。 如果未安装,分析器会尝试从 Python 包的官方存储库中提取它。 - 此外,该工具当前需要在设备上安装 Python 版本 3 或更高版本。
- 从MDE Linux 的客户端分析器 1.7.0 版本开始,现已支持在 Python 虚拟环境 (venv) 中运行基于 Python 的客户端分析器。 使用虚拟环境是可选的,不需要。
- 如果设备位于代理后面,则可以将代理服务器作为环境变量传递给
mde_support_tool.sh脚本。 例如:https_proxy=https://myproxy.contoso.com:8080 ./mde_support_tool.sh"。
警告
运行基于 Python 的客户端分析器需要安装 PIP 包,这可能会导致环境中出现一些问题。 为了避免出现问题,建议将包安装到用户 PIP 环境中。
运行适用于 Linux 的 Microsoft Defender 随附的客户端分析器 Python 版本
注意
从 Defender for Endpoint 版本 101.25082.0000开始,客户端分析器随代理一起提供。 可以在以下位置找到它: /opt/microsoft/mdatp/tools/client_analyzer/python
若要运行此客户端分析器,请执行以下步骤:
转到目录
/opt/microsoft/mdatp/tools/client_analyzer/python:cd /opt/microsoft/mdatp/tools/client_analyzer/python使用根权限运行以安装所需的依赖项。
sudo ./mde_support_tool.sh若要收集诊断包并生成结果存档文件,请使用根权限再次运行。
sudo ./mde_support_tool.sh -d
下载并运行客户端分析器独立 Python 版本
在需要调查的 Linux 计算机上下载 XMDE 客户端分析器工具。 如果使用的是终端,请通过输入以下命令下载该工具:
wget --quiet -O XMDEClientAnalyzerPython.zip "https://go.microsoft.com/fwlink/?linkid=2336046"验证下载:
echo '0B7C350A1C19E049416B1C8FB7ED857569DDCC32FB90453A3FCCD083487C0B4E XMDEClientAnalyzerPython.zip' | sha256sum -c在计算机上提取
XMDEClientAnalyzer.zip的内容:unzip -q XMDEClientAnalyzerPython.zip -d XMDEClientAnalyzerPython更改目录:
cd XMDEClientAnalyzerPython为工具授予可执行权限:
chmod a+x mde_support_tool.sh以非根用户身份运行以安装所需的依赖项:
./mde_support_tool.sh若要收集诊断包并生成结果存档文件,请使用根权限再次运行:
sudo ./mde_support_tool.sh -d
提示
观看此视频,详细了解载入问题: Defender for Endpoint 客户端分析器载入问题
命令行选项
客户端分析器提供以下命令行选项:
usage: MDESupportTool [-h] [--output OUTPUT] [--outdir OUTDIR] [--no-zip]
[--force] [--diagnostic] [--skip-mdatp]
[--bypass-disclaimer] [--interactive] [--delay DELAY]
[--mdatp-log {trace,info,warning,error,debug,verbose}]
[--max-log-size MAX_LOG_SIZE]
{certinfocollection,performance,installation,exclude,ratelimit,skipfaultyrules,trace,observespikes,connectivitytest}
...
MDE Diagnostics Tool
positional arguments:
{certinfocollection,performance,installation,exclude,ratelimit,skipfaultyrules,trace,observespikes,connectivitytest}
certinfocollection Collect cert information: Subject name and Hashes
performance Collect extensive machine performance tracing for
analysis of a performance scenario that can be
reproduced on demand
installation Collect different installation/onboarding reports
exclude Exclude specific processes from audit-d monitoring.
ratelimit Set the rate limit for auditd events. Rate limit will
update the limits for auditd events for all the
applications using auditd, which could impact
applications other than MDE.
skipfaultyrules Continue loading rules in spite of an error. This
summarizes the results of loading the rules. The exit
code will not be success if any rule fails to load.
trace Use OS tracing facilities to record Defender
performance traces.
observespikes Collect the process logs in case of spike or mdatp
crash
connectivitytest Perform connectivity test for MDE
optional arguments:
-h, --help show this help message and exit
--output OUTPUT, -o OUTPUT
Output path to export report
--outdir OUTDIR Directory where diagnostics file will be generated.
--no-zip, -nz If set a directory will be created instead of an
archive file.
--force, -f Will overwrite if output directory exists.
--diagnostic, -d Collect extensive machine diagnostic information.
--skip-mdatp Skip any mdatp command. Use this when the mdatp
command is unresponsive.
--bypass-disclaimer Do not display disclaimer banner.
--interactive, -i Interactive diagnostic,
--delay DELAY, -dd DELAY
Delay diagnostic by how many minutes (0~2880), use
this to wait for more debug logs before it collects.
--mdatp-log {trace,info,warning,error,debug,verbose}
Set MDATP log level. If you use interactive or delay
mode, the log level will set to debug automatically,
and reset after 48h.
--max-log-size MAX_LOG_SIZE
Maximum log file size in MB before rotating(Will
restart mdatp).
诊断模式
诊断模式用于收集大量计算机信息,例如内存、磁盘和 MDATP 日志。 这组文件提供了调试与 Defender For Endpoint 相关的任何问题所需的主要信息集。
支持的选项如下所示:
optional arguments:
-h, --help show this help message and exit
--output OUTPUT, -o OUTPUT
Output path to export report
--outdir OUTDIR Directory where diagnostics file will be generated.
--no-zip, -nz If set a directory will be created instead of an
archive file.
--force, -f Will overwrite if output directory exists.
--diagnostic, -d Collect extensive machine diagnostic information.
--skip-mdatp Skip any mdatp command. Use this when the mdatp
command is unresponsive.
--bypass-disclaimer Do not display disclaimer banner.
--interactive, -i Interactive diagnostic,
--delay DELAY, -dd DELAY
Delay diagnostic by how many minutes (0~2880), use
this to wait for more debug logs before it collects.
--mdatp-log {trace,info,warning,error,debug,verbose}
Set MDATP log level. If you use interactive or delay
mode, the log level will set to debug automatically,
and reset after 48h.
--max-log-size MAX_LOG_SIZE
Maximum log file size in MB before rotating(Will
restart mdatp).
用法示例: sudo ./MDESupportTool -d
注意
日志级别自动重置功能仅在代理版本 101.24052.0002 或更高版本中可用。
下表汇总了使用此模式时生成的文件:
| 文件 | 备注 |
|---|---|
mde_diagnostic.zip |
Defender for Endpoint 的日志和配置 |
health.txt |
Defender for Endpoint 的健康状态 (仅在安装 Defender for Endpoint) 时才显示 |
health_details_features.txt |
其他 Defender for Endpoint 功能的运行状况 (仅在安装 Defender for Endpoint) 时才显示 |
permissions.txt |
Defender for Endpoint 拥有/使用的文件夹的权限问题 (仅在安装 Defender for Endpoint) 时才显示 |
crashes |
Defender for Endpoint 生成的故障转储 |
process_information.txt |
运行工具时在计算机中运行的进程 |
proc_directory_info.txt |
Defender for Endpoint 进程的虚拟内存映射 (仅在安装 Defender for Endpoint) 时才显示 |
auditd_info.txt |
Auditd 运行状况、规则、日志 |
auditd_log_analysis.txt |
由 auditd 处理的事件摘要 |
auditd_logs.zip |
审核的日志文件 |
ebpf_kernel_config.txt |
当前已加载的 Linux 内核配置 |
ebpf_enabled_func.txt |
当前启用跟踪的所有内核函数的列表 |
ebpf_syscalls.zip |
有关系统调用跟踪的信息 |
ebpf_raw_syscalls.zip |
跟踪与原始系统调用相关的事件 |
ebpf_maps_info.txt |
eBPF 地图的 ID 和大小信息 |
syslog.zip |
/var/log/syslog 下的文件 |
messages.zip |
/var/log/messages 下的文件 |
conflicting_processes_information.txt |
Defender for Endpoint 冲突进程 |
exclusions.txt |
防病毒排除项列表 |
definitions.txt |
防病毒定义信息 |
mde_directories.txt |
Defender for Endpoint 目录中的文件列表 |
disk_usage.txt |
磁盘使用情况详细信息 |
mde_user.txt |
Defender for Endpoint 用户信息 |
mde_definitions_mount.txt |
Defender for Endpoint 定义装入点 |
service_status.txt |
Defender for Endpoint 服务状态 |
service_file.txt |
Defender for Endpoint 服务文件 |
hardware_info.txt |
硬件信息 |
mount.txt |
装入点信息 |
uname.txt |
内核信息 |
memory.txt |
系统内存信息 |
meminfo.txt |
有关系统内存使用情况的详细信息 |
cpuinfo.txt |
CPU信息 |
lsns_info.txt |
Linux命名空间信息 |
lsof.txt |
Defender for Endpoint 打开文件描述符信息 (参见本表后的注释) |
sestatus.txt |
Defender for Endpoint 打开文件描述符信息 |
lsmod.txt |
Linux内核中模块的状态 |
dmesg.txt |
来自内核环形缓冲区的消息 |
kernel_lockdown.txt |
内核锁定信息 |
rtp_statistics.txt |
Defender for Endpoint 实时防护 (RTP) 统计信息 (仅在安装 Defender for Endpoint) 时才显示 |
libc_info.txt |
libc 库信息 |
uptime_info.txt |
自上次重启以来的时间 |
last_info.txt |
上次登录用户的列表 |
locale_info.txt |
显示当前区域设置 |
tmp_files_owned_by_mdatp.txt |
组拥有的 /tmp 文件:mdatp (仅在安装 Defender for Endpoint) 时才显示 |
mdatp_config.txt |
所有 Defender for Endpoint 配置 (仅在安装 Defender for Endpoint) 时才显示 |
mpenginedb.dbmpenginedb.db-walmpenginedb.db-shm |
防病毒定义文件 (仅在安装 Defender for Endpoint) 时才显示 |
iptables_rules.txt |
Linux iptables 规则 |
network_info.txt |
网络信息 |
sysctl_info.txt |
内核设置信息 |
hostname_diagnostics.txt |
主机名诊断信息 |
mde_event_statistics.txt |
Defender for Endpoint 事件统计信息 (仅在安装 Defender for Endpoint) 时才显示 |
mde_ebpf_statistics.txt |
Defender for Endpoint eBPF 统计信息 (仅在安装 Defender for Endpoint) 时才显示 |
kernel_logs.zip |
内核日志 |
mdc_log.zip |
Microsoft Defender for Cloud 日志 |
netext_config.txt |
|
threat_list.txt |
Defender for Endpoint 检测到的威胁列表 (仅在安装 Defender for Endpoint) 时才显示 |
top_output.txt |
运行工具时在计算机中运行的进程 |
top_summary.txt |
运行进程的内存和 CPU 使用率分析 |
客户端分析器的可选参数
客户端分析器为额外的数据收集提供了以下可选参数:
收集性能信息
收集 Defender for Endpoint 进程的详细计算机性能跟踪数据,以分析可按需重现的性能场景。
-h, --help show this help message and exit
--frequency FREQUENCY
profile at this frequency
--length LENGTH length of time to collect (in seconds)
用法示例: sudo ./MDESupportTool performance --frequency 500
此模式生成以下文件:
| 文件 | 备注 |
|---|---|
perf_benchmark.tar.gz |
Defender for Endpoint 处理性能数据 |
注意
还会生成与诊断模式对应的文件。
tar 归档文件包含 <pid of a MDE process>.data 格式的文件。
可以使用 命令读取数据文件:
perf report -i <pid>.data
运行连接测试
此模式测试 Defender for Endpoint 所需的云资源是否可访问。
-h, --help show this help message and exit
-o ONBOARDING_SCRIPT, --onboarding-script ONBOARDING_SCRIPT
Path to onboarding script
-g GEO, --geo GEO Geo string to test <US|UK|EU|AU|CH|IN>
用法示例:
sudo ./MDESupportTool connectivitytest -o ~/MicrosoftDefenderATPOnboardingLinuxServer.py`
屏幕上打印的输出显示 URL 是否可访问。
收集不同的安装/载入报告
此模式收集与安装相关的信息,例如发行版和系统要求。
-h, --help show this help message and exit
-d, --distro Check for distro support
-m, --min-requirement Check for the system info against offical minimum requirements
-e, --external-dep Check for externel package dependency
-c, --connectivity Check for connectivity for services used by MDE
-a, --all Run all checks
-o ONBOARDING_SCRIPT, --onboarding-script ONBOARDING_SCRIPT
Path to onboarding script
-g GEO, --geo GEO Geo string to test <US|UK|EU|AU|CH|IN>
用法示例:
sudo ./MDESupportTool installation --all
生成单个报表 installation_report.json 。 文件中的键如下所示:
| 键 | 备注 |
|---|---|
| agent_version | 安装的 Defender for Endpoint 版本。 |
| onboarding_status | 载入和环信息 |
| support_status | 当前系统配置支持MDE。 |
| distro | 安装代理的发行版是否受支持。 |
| connectivitytest | 连通性测试状态。 |
| 最低要求 | 满足 CPU 和内存的最低要求。 |
| 外部依赖 | 外部依赖项是否已满足。 |
| mde_health | MDE 代理的健康状态 |
| folder_perm | 是否具备所需的文件夹权限。 |
排除模式
此模式会为 audit-d 监控添加排除项。
-h, --help show this help message and exit
-e <executable>, --exe <executable>
exclude by executable name, i.e: bash
-p <process id>, --pid <process id>
exclude by process id, i.e: 911
-d <directory>, --dir <directory>
exclude by target path, i.e: /var/foo/bar
-x <executable> <directory>, --exe_dir <executable> <directory>
exclude by executable path and target path, i.e: /bin/bash /var/foo/bar
-q <q_size>, --queue <q_size>
set dispatcher q_depth size
-r, --remove remove exclusion file
-s, --stat get statistics about common executables
-l, --list list auditd rules
-o, --override Override the existing auditd exclusion rules file for mdatp
-c <syscall number>, --syscall <syscall number>
exclude all process of the given syscall
用法示例:
sudo ./MDESupportTool exclude -d /var/foo/bar`
使用 Defender for Endpoint 中的实时响应收集支持日志
可以在实时响应会话期间运行客户端分析器,方法是使用 Microsoft Defender for Endpoint on Linux 已包含的版本,或者将客户端分析器作为二进制或 Python 包下载并在设备上解压。
- 安装时需要
unzip软件包。 - 若要执行,需要
acl包。
重要
Windows 使用回车符和换行符这两个不可见字符来表示文件中一行的结束以及新一行的开始。 Linux 系统仅使用文件行末尾的换行符不可见字符。 在使用以下脚本时,如果在 Windows 上执行此操作,此差异可能会导致脚本运行错误和失败。 一个潜在的解决方案是利用 适用于 Linux 的 Windows 子系统 (WSL) 和dos2unix包重新格式化脚本,使其与 Unix 和 Linux 格式标准保持一致。