使用 az networkcloud baremetalmachine run-data-extract 命令排查裸机计算机问题

在某些情况下,用户可能需要调查和解决本地裸机计算机的问题。 Azure 运营商关系通过 az networkcloud baremetalmachine run-data-extract 提供一组指定的数据提取命令。 用户可以通过这些命令从裸机计算机获取诊断数据。

该命令生成包含数据提取结果的输出文件。 默认情况下,数据将发送到群集管理器存储帐户。 还有一种预览方法,用户可以使用有权访问存储帐户的存储帐户和标识来配置群集资源来接收输出。

先决条件

  • 本文假定已安装 Azure 命令行接口和 networkcloud 命令行接口扩展。 有关详细信息,请参阅如何安装 CLI 扩展
  • 目标裸机已启动并准备就绪。
  • 这些命令的语法基于 az networkcloud CLI 的 0.3.0+ 版本。
  • 获取为群集资源创建的群集受管理资源组名称 (cluster_MRG)。

将命令输出发送到用户指定的存储帐户

若要配置接收发送的命令输出的存储帐户和容器,请参阅 Azure 运营商关系群集对托管标识和用户提供的资源的支持

若要访问命令的输出,用户需要拥有对存储 Blob 的适当访问权限,包括具有必要的 Azure 角色分配并确保正确配置任何网络限制。

对于角色分配,用户必须在 Blob 容器或其存储帐户上具有以下角色分配:

  • 数据访问角色,例如“存储 Blob 数据读取者”或“存储 Blob 数据参与者”
  • 至少分配 Azure 资源管理器“读取者”角色

有关向存储帐户分配角色的信息,请参阅分配 Azure 角色以访问 blob 数据

对于网络限制,如果存储帐户允许通过防火墙访问公共终结点,则必须使用网络规则配置防火墙,以允许该用户的 IP 地址通过。 如果仅允许专用终结点访问,则用户必须属于有权访问专用终结点的网络。

有关允许使用网络规则专用终结点通过存储帐户防火墙进行访问的信息,请参阅相应的文档。

验证对指定存储帐户的访问权限

在运行命令之前,可能需要验证你是否有权访问指定的存储帐户:

  1. 从 Azure 门户导航到存储帐户。
  2. 在存储帐户详细信息中,从左侧的导航菜单中选择“存储浏览器”
  3. 在存储浏览器详细信息中,选择“Blob 容器”
  4. 查找要向其发送命令输出的容器,然后选择它。
  5. 如果在访问存储帐户或容器时遇到错误,则你正在使用的用户可能需要为存储帐户或容器分配角色。 或者,可能需要更新存储帐户的防火墙设置以包含你的 IP 地址。

执行 run-data-extract 命令

运行数据提取命令执行一个或多个预定义脚本,以便从裸机计算机中提取数据。

警告

Microsoft 不提供或支持任何需要提供纯文本用户名和密码的 Operator Nexus API 调用。 请注意,将会记录发送的任何值,并将其视为应当轮换和撤销的公开机密。 Microsoft 记录的安全使用机密的方法是将它们存储在 Azure Key Vault 中。 如果存在特定问题或疑虑,请通过 Azure 门户提交请求。

以下是受支持命令的当前列表

警告

v20250701preview API 版本及更高版本开始,非受限 run-data-extract 命令将不再支持此命令。 若要执行 mde-agent-information,请参阅 运行名为 run-data-extracts-restricted 的命令

警告

v20250701preview API 版本及更高版本开始,非受限 run-data-extract 命令将不再支持此命令。 若要执行 cluster-cve-report,请参阅 运行名为 run-data-extracts-restricted 的命令

命令语法为:

az networkcloud baremetalmachine run-data-extract --name "<machine-name>"  \
  --resource-group "<cluster_MRG>" \
  --subscription "<subscription>" \
  --commands '[{"arguments":["<arg1>","<arg2>"],"command":"<command1>"}]'  \
  --limit-time-seconds "<timeout>"

--commands 选项中使用 json 格式指定多个命令。 每个 command 指定命令和参数。 对于具有多个参数的命令,请以列表的形式提供给 arguments 参数。 有关构造 结构的说明,请参阅 --commands

这些命令可以长时间运行,因此建议将 --limit-time-seconds 设置为至少 600 秒(10 分钟)。 Debug 选项或运行多个提取可能需要 10 分钟以上。

在响应中,该操作以异步方式执行,并返回 HTTP 状态代码 202。 有关如何跟踪命令补全和查看输出文件的详细信息,请参阅如何在关联的存储帐户中查看命令的完整输出部分。

硬件支持数据收集

以下示例执行 hardware-support-data-collection 命令,并从 Dell 服务器获取 SysInfoTTYLog 日志。 该脚本在指定的裸机计算机上执行 racadm supportassist collect 命令。 生成的 tar.gz 文件包含 hardware-support-data-<timestamp>.zip 中压缩的提取命令文件输出。

az networkcloud baremetalmachine run-data-extract --name "bareMetalMachineName" \
  --resource-group "cluster_MRG" \
  --subscription "subscription" \
  --commands '[{"arguments":["SysInfo", "TTYLog"],"command":"hardware-support-data-collection"}]' \
  --limit-time-seconds 600

hardware-support-data-collection 输出

====Action Command Output====
Executing hardware-support-data-collection command
Getting following hardware support logs: SysInfo,TTYLog
Job JID_814372800396 is running, waiting for it to complete ...
Job JID_814372800396 Completed.
---------------------------- JOB -------------------------
[Job ID=JID_814372800396]
Job Name=SupportAssist Collection
Status=Completed
Scheduled Start Time=[Not Applicable]
Expiration Time=[Not Applicable]
Actual Start Time=[Thu, 13 Apr 2023 20:54:40]
Actual Completion Time=[Thu, 13 Apr 2023 20:59:51]
Message=[SRV088: The SupportAssist Collection Operation is completed successfully.]
Percent Complete=[100]
----------------------------------------------------------
Deleting Job JID_814372800396
Collection successfully exported to /hostfs/tmp/runcommand/hardware-support-data-2023-04-13T21:00:01.zip

================================
Script execution result can be found in storage account:
https://cm2p9bctvhxnst.blob.core.windows.net/bmm-run-command-output/dd84df50-7b02-4d10-a2be-46782cbf4eef-action-bmmdataextcmd.tar.gz?se=2023-04-14T01%3A00%3A15Zandsig=ZJcsNoBzvOkUNL0IQ3XGtbJSaZxYqmtd%2BM6rmxDFqXE%3Dandsp=randspr=httpsandsr=bandst=2023-04-13T21%3A00%3A15Zandsv=2019-12-12

收集的硬件支持文件的示例列表

Archive:  TSR20240227164024_FM56PK3.pl.zip
   creating: tsr/hardware/
   creating: tsr/hardware/spd/
   creating: tsr/hardware/sysinfo/
   creating: tsr/hardware/sysinfo/inventory/
  inflating: tsr/hardware/sysinfo/inventory/sysinfo_CIM_BIOSAttribute.xml
  inflating: tsr/hardware/sysinfo/inventory/sysinfo_CIM_Sensor.xml
  inflating: tsr/hardware/sysinfo/inventory/sysinfo_DCIM_View.xml
  inflating: tsr/hardware/sysinfo/inventory/sysinfo_DCIM_SoftwareIdentity.xml
  inflating: tsr/hardware/sysinfo/inventory/sysinfo_CIM_Capabilities.xml
  inflating: tsr/hardware/sysinfo/inventory/sysinfo_CIM_StatisticalData.xml
   creating: tsr/hardware/sysinfo/lcfiles/
  inflating: tsr/hardware/sysinfo/lcfiles/lclog_0.xml.gz
  inflating: tsr/hardware/sysinfo/lcfiles/curr_lclog.xml
   creating: tsr/hardware/psu/
   creating: tsr/hardware/idracstateinfo/
  inflating: tsr/hardware/idracstateinfo/avc.log
 extracting: tsr/hardware/idracstateinfo/avc.log.persistent.1
[..snip..]

收集 MDE 代理信息

使用 mde-agent-information 命令收集数据,并将其格式化为 JSON 到 /hostfs/tmp/runcommand/mde-agent-information.json。 JSON 文件位于存储帐户中的数据提取 zip 文件中。 该脚本在指定的裸机计算机上执行一系列 mdatp 命令。

以下示例在没有参数的情况下执行 mde-agent-information 命令。

az networkcloud baremetalmachine run-data-extract --name "bareMetalMachineName" \
  --resource-group "cluster_MRG" \
  --subscription "subscription" \
  --commands '[{"command":"mde-agent-information"}]' \
  --limit-time-seconds 600

mde-agent-information 输出

====Action Command Output====
Executing mde-agent-information command
MDE agent is running, proceeding with data extract
Getting MDE agent information for bareMetalMachine
Writing to /hostfs/tmp/runcommand

================================
Script execution result can be found in storage account:
 https://cmzhnh6bdsfsdwpbst.blob.core.windows.net/bmm-run-command-output/f5962f18-2228-450b-8cf7-cb8344fdss63b0-action-bmmdataextcmd.tar.gz?se=2023-07-26T19%3A07%3A22Z&sig=X9K3VoNWRFP78OKqFjvYoxubp65BbNTq%2BGnlHclI9Og%3D&sp=r&spr=https&sr=b&st=2023-07-26T15%3A07%3A22Z&sv=2019-12-12

收集示例 JSON 对象

{
  "diagnosticInformation": {
      "realTimeProtectionStats": $real_time_protection_stats,
      "eventProviderStats": $event_provider_stats
      },
  "mdeDefinitions": $mde_definitions,
  "generalHealth": $general_health,
  "mdeConfiguration": $mde_config,
  "scanList": $scan_list,
  "threatInformation": {
      "list": $threat_info_list,
      "quarantineList": $threat_info_quarantine_list
    }
}

收集 MDE 支持诊断

mde-support-diagnostics 命令收集的数据使用 MDE 客户端分析器工具捆绑来自 mdatp 命令和相关日志文件的信息。 存储帐户 tgz 文件将包含名为 zipmde-support-diagnostics-<hostname>.zip 文件。 zip 应与任何支持请求一起发送,以确保支持团队可以根据需要使用日志进行故障排除和根本原因分析。

以下示例在没有参数的情况下执行 mde-support-diagnostics 命令。

az networkcloud baremetalmachine run-data-extract --name "bareMetalMachineName" \
  --resource-group "cluster_MRG" \
  --subscription "subscription" \
  --commands '[{"command":"mde-support-diagnostics"}]' \
  --limit-time-seconds 600

mde-support-diagnostics 输出

====Action Command Output====
Executing mde-support-diagnostics command
[2024-01-23 16:07:37.588][INFO] XMDEClientAnalyzer Version: 1.3.2
[2024-01-23 16:07:38.367][INFO] Top Command output: [/tmp/top_output_2024_01_23_16_07_37mel0nue0.txt]
[2024-01-23 16:07:38.367][INFO] Top Command Summary: [/tmp/top_summary_2024_01_23_16_07_370zh7dkqn.txt]
[2024-01-23 16:07:38.367][INFO] Top Command Outliers: [/tmp/top_outlier_2024_01_23_16_07_37aypcfidh.txt]
[2024-01-23 16:07:38.368][INFO] [MDE Diagnostic]
[2024-01-23 16:07:38.368][INFO]   Collecting MDE Diagnostic
[2024-01-23 16:07:38.613][WARNING] mde is not running
[2024-01-23 16:07:41.343][INFO] [SLEEP] [3sec] waiting for agent to create diagnostic package
[2024-01-23 16:07:44.347][INFO] diagnostic package path: /var/opt/microsoft/mdatp/wdavdiag/5b1edef9-3b2a-45c1-a45d-9e7e4b6b869e.zip
[2024-01-23 16:07:44.347][INFO] Successfully created MDE diagnostic zip
[2024-01-23 16:07:44.348][INFO]   Adding mde_diagnostic.zip to report directory
[2024-01-23 16:07:44.348][INFO]   Collecting MDE Health
[...snip...]
================================
Script execution result can be found in storage account:
 https://cmmj627vvrzkst.blob.core.windows.net/bmm-run-command-output/7c5557b9-b6b6-a4a4-97ea-752c38918ded-action-bmmdataextcmd.tar.gz?se=2024-01-23T20%3A11%3A32Z&sig=9h20XlZO87J7fCr0S1234xcyu%2Fl%2BVuaDh1BE0J6Yfl8%3D&sp=r&spr=https&sr=b&st=2024-01-23T16%3A11%3A32Z&sv=2019-12-12

下载执行结果文件后,可以解压缩支持文件进行分析。

MDE 客户端分析器收集的信息示例列表

Archive:  mde-support-diagnostics-rack1compute02.zip
  inflating: mde_diagnostic.zip
  inflating: process_information.txt
  inflating: auditd_info.txt
  inflating: auditd_log_analysis.txt
  inflating: auditd_logs.zip
  inflating: ebpf_kernel_config.txt
  inflating: ebpf_enabled_func.txt
  inflating: ebpf_syscalls.zip
  inflating: ebpf_raw_syscalls.zip
  inflating: messagess.zip
  inflating: conflicting_processes_information.txt
[...snip...]

硬件汇总状态

使用 hardware-rollup-status 命令收集数据,并将其格式化为 JSON 到 /hostfs/tmp/runcommand/rollupStatus.json。 JSON 文件位于存储帐户中的数据提取 zip 文件中。 收集的数据会显示计算机子系统的健康状况。

以下示例在没有参数的情况下执行 hardware-rollup-status 命令。

az networkcloud baremetalmachine run-data-extract --name "bareMetalMachineName" \
  --resource-group "clusete_MRG" \
  --subscription "subscription" \
  --commands '[{"command":"hardware-rollup-status"}]' \
  --limit-time-seconds 600

hardware-rollup-status 输出

====Action Command Output====
Executing hardware-rollup-status command
Getting rollup status logs for b37dev03a1c002
Writing to /hostfs/tmp/runcommand

================================
Script execution result can be found in storage account:
https://cmkfjft8twwpst.blob.core.windows.net/bmm-run-command-output/20b217b5-ea38-4394-9db1-21a0d392eff0-action-bmmdataextcmd.tar.gz?se=2023-09-19T18%3A47%3A17Z&sig=ZJcsNoBzvOkUNL0IQ3XGtbJSaZxYqmtd%3D&sp=r&spr=https&sr=b&st=2023-09-19T14%3A47%3A17Z&sv=2019-12-12

收集的 JSON 示例

{
	"@odata.context" : "/redfish/v1/$metadata#DellRollupStatusCollection.DellRollupStatusCollection",
	"@odata.id" : "/redfish/v1/Systems/System.Embedded.1/Oem/Dell/DellRollupStatus",
	"@odata.type" : "#DellRollupStatusCollection.DellRollupStatusCollection",
	"Description" : "A collection of DellRollupStatus resource",
	"Members" :
	[
		{
			"@odata.context" : "/redfish/v1/$metadata#DellRollupStatus.DellRollupStatus",
			"@odata.id" : "/redfish/v1/Systems/System.Embedded.1/Oem/Dell/DellRollupStatus/iDRAC.Embedded.1_0x23_SubSystem.1_0x23_Current",
			"@odata.type" : "#DellRollupStatus.v1_0_0.DellRollupStatus",
			"CollectionName" : "CurrentRollupStatus",
			"Description" : "Represents the subcomponent roll-up statuses.",
			"Id" : "iDRAC.Embedded.1_0x23_SubSystem.1_0x23_Current",
			"InstanceID" : "iDRAC.Embedded.1#SubSystem.1#Current",
			"Name" : "DellRollupStatus",
			"RollupStatus" : "Ok",
			"SubSystem" : "Current"
		},
		{
			"@odata.context" : "/redfish/v1/$metadata#DellRollupStatus.DellRollupStatus",
			"@odata.id" : "/redfish/v1/Systems/System.Embedded.1/Oem/Dell/DellRollupStatus/iDRAC.Embedded.1_0x23_SubSystem.1_0x23_Voltage",
			"@odata.type" : "#DellRollupStatus.v1_0_0.DellRollupStatus",
			"CollectionName" : "VoltageRollupStatus",
			"Description" : "Represents the subcomponent roll-up statuses.",
			"Id" : "iDRAC.Embedded.1_0x23_SubSystem.1_0x23_Voltage",
			"InstanceID" : "iDRAC.Embedded.1#SubSystem.1#Voltage",
			"Name" : "DellRollupStatus",
			"RollupStatus" : "Ok",
			"SubSystem" : "Voltage"
		},
[..snip..]

生成群集 CVE 报表

漏洞数据是使用 cluster-cve-report 命令收集的,并格式化为 {year}-{month}-{day}-nexus-cluster-vulnerability-report.json 的 JSON 格式。 JSON 文件位于存储帐户中的数据提取 zip 文件中。 收集的数据包括群集中每个容器映像的漏洞数据。

以下示例在没有参数的情况下执行 cluster-cve-report 命令。

注释

目标计算机必须是控制平面节点,否则不会执行该操作。

az networkcloud baremetalmachine run-data-extract --name "bareMetalMachineName" \
  --resource-group "cluster_MRG" \
  --subscription "subscription" \
  --commands '[{"command":"cluster-cve-report"}]' \
  --limit-time-seconds 600

cluster-cve-report 输出

====Action Command Output====
Nexus cluster vulnerability report saved.


================================
Script execution result can be found in storage account:
https://cmkfjft8twwpst.blob.core.windows.net/bmm-run-command-output/20b217b5-ea38-4394-9db1-21a0d392eff0-action-bmmdataextcmd.tar.gz?se=2023-09-19T18%3A47%3A17Z&sig=ZJcsNoBzvOkUNL0IQ3XGtbJSaZxYqmtd%3D&sp=r&spr=https&sr=b&st=2023-09-19T14%3A47%3A17Z&sv=2019-12-12

CVE 报表架构

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Vulnerability Report",
  "type": "object",
  "properties": {
    "metadata": {
      "type": "object",
      "properties": {
        "dateRetrieved": {
          "type": "string",
          "format": "date-time",
          "description": "The date and time when the data was retrieved."
        },
        "platform": {
          "type": "string",
          "description": "The name of the platform."
        },
        "resource": {
          "type": "string",
          "description": "The name of the resource."
        },
        "clusterId": {
          "type": "string",
          "description": "The resource ID of the cluster."
        },
        "runtimeVersion": {
          "type": "string",
          "description": "The version of the runtime."
        },
        "managementVersion": {
          "type": "string",
          "description": "The version of the management software."
        },
        "vulnerabilitySummary": {
          "type": "object",
          "properties": {
            "uniqueVulnerabilities": {
              "type": "object",
              "properties": {
                "critical": { "type": "integer" },
                "high": { "type": "integer" },
                "medium": { "type": "integer" },
                "low": { "type": "integer" },
                "unknown": { "type": "integer" }
              },
              "required": ["critical", "high", "medium", "low", "unknown"]
            },
            "totalVulnerabilities": {
              "type": "object",
              "properties": {
                "critical": { "type": "integer" },
                "high": { "type": "integer" },
                "medium": { "type": "integer" },
                "low": { "type": "integer" },
                "unknown": { "type": "integer" }
              },
              "required": ["critical", "high", "medium", "low", "unknown"]
            }
          },
          "required": ["uniqueVulnerabilities", "totalVulnerabilities"]
        }
      },
      "required": [
        "dateRetrieved",
        "platform",
        "resource",
        "clusterId",
        "runtimeVersion",
        "managementVersion",
        "vulnerabilitySummary"
      ]
    },
    "containers": {
      "type": "object",
      "additionalProperties": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "namespace": {
              "type": "array",
              "description": "The namespaces where the container image is in-use.",
              "items": { "type": "string" }
            },
            "digest": {
              "type": "string",
              "description": "The digest of the container image."
            },
            "observedCount": {
              "type": "integer",
              "description": "The number of times the container image has been observed."
            },
            "os": {
              "type": "object",
              "properties": {
                "family": {
                  "type": "string",
                  "description": "The family of the operating system."
                }
              },
              "required": ["family"]
            },
            "vulnerabilities": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "title": { "type": "string" },
                  "vulnerabilityID": { "type": "string" },
                  "fixedVersion": { "type": "string" },
                  "installedVersion": { "type": "string" },
                  "referenceLink": { "type": "string", "format": "uri" },
                  "publishedDate": { "type": "string", "format": "date-time" },
                  "dataSource": { "type": "string" },
                  "score": { "type": "number" },
                  "severity": { "type": "string" },
                  "severitySource": { "type": "string" },
                  "resource": { "type": "string" },
                  "target": { "type": "string" },
                  "packageType": { "type": "string" },
                  "exploitAvailable": { "type": "boolean" }
                },
                "required": [
                  "title",
                  "vulnerabilityID",
                  "fixedVersion",
                  "installedVersion",
                  "referenceLink",
                  "publishedDate",
                  "dataSource",
                  "score",
                  "severity",
                  "severitySource",
                  "resource",
                  "target",
                  "packageType",
                  "exploitAvailable"
                ]
              }
            }
          },
          "required": ["namespace", "digest", "os", "observedCount", "vulnerabilities"]
        }
      }
    }
  },
  "required": ["metadata", "containers"]
}

CVE 数据详细信息

CVE 数据每 24 小时刷新一次,或者在引用映像的 Kubernetes 资源发生更改时刷新每个容器映像。

收集 Helm 版本

Helm 版本数据是使用 collect-helm-releases 命令收集的,并作为 json 格式化为 {year}-{month}-{day}-helm-releases.json。 JSON 文件位于存储帐户中的数据提取 zip 文件中。 收集的数据包括群集中的所有 helm 版本信息,其中包括运行命令 helm list 时返回的标准数据。

以下示例在没有参数的情况下执行 collect-helm-releases 命令。

注释

目标计算机必须是控制平面节点,否则不会执行该操作。

az networkcloud baremetalmachine run-data-extract --name "bareMetalMachineName" \
  --resource-group "cluster_MRG" \
  --subscription "subscription" \
  --commands '[{"command":"collect-helm-releases"}]' \
  --limit-time-seconds 600

collect-helm-releases 输出

====Action Command Output====
Helm releases report saved.


================================
Script execution result can be found in storage account:
https://cmcr5xp3mbn7st.blob.core.windows.net/bmm-run-command-output/a29dcbdb-5524-4172-8b55-88e0e5ec93ff-action-bmmdataextcmd.tar.gz?se=2024-10-30T02%3A09%3A54Z&sig=v6cjiIDBP9viEijs%2B%2BwJDrHIAbLEmuiVmCEEDHEi%2FEc%3D&sp=r&spr=https&sr=b&st=2024-10-29T22%3A09%3A54Z&sv=2023-11-03

Helm 版本架构

{
  "$schema": "http://json-schema.org/schema#",
  "type": "object",
  "properties": {
    "metadata": {
      "type": "object",
      "properties": {
        "dateRetrieved": {
          "type": "string"
        },
        "platform": {
          "type": "string"
        },
        "resource": {
          "type": "string"
        },
        "clusterId": {
          "type": "string"
        },
        "runtimeVersion": {
          "type": "string"
        },
        "managementVersion": {
          "type": "string"
        }
      },
      "required": [
        "clusterId",
        "dateRetrieved",
        "managementVersion",
        "platform",
        "resource",
        "runtimeVersion"
      ]
    },
    "helmReleases": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "namespace": {
            "type": "string"
          },
          "revision": {
            "type": "string"
          },
          "updated": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "chart": {
            "type": "string"
          },
          "app_version": {
            "type": "string"
          }
        },
        "required": [
          "app_version",
          "chart",
          "name",
          "namespace",
          "revision",
          "status",
          "updated"
        ]
      }
    }
  },
  "required": [
    "helmReleases",
    "metadata"
  ]
}

收集 Systemctl 状态输出

服务状态使用 platform-services-status 命令收集。 输出采用纯文本格式,它会返回主机上服务的状态概览以及每个找到的服务的 systemctl status

以下示例在没有参数的情况下执行 platform-services-status 命令。

az networkcloud baremetalmachine run-data-extract --name "bareMetalMachineName" \
  --resource-group "clusete_MRG" \
  --subscription "subscription" \
  --commands '[{"command":"platform-services-status"}]' \
  --limit-time-seconds 600
  --output-directory "/path/to/local/directory"

platform-services-status 输出

====Action Command Output====
UNIT                                                                                          LOAD      ACTIVE   SUB     DESCRIPTION
aods-infra-vf-config.service                                                                  not-found inactive dead    aods-infra-vf-config.service
aods-pnic-config-infra.service                                                                not-found inactive dead    aods-pnic-config-infra.service
aods-pnic-config-workload.service                                                             not-found inactive dead    aods-pnic-config-workload.service
arc-unenroll-file-semaphore.service                                                           loaded    active   exited  Arc-unenrollment upon shutdown service
atop-rotate.service                                                                           loaded    inactive dead    Restart atop daemon to rotate logs
atop.service                                                                                  loaded    active   running Atop advanced performance monitor
atopacct.service                                                                              loaded    active   running Atop process accounting daemon
audit.service                                                                                 loaded    inactive dead    Audit service
auditd.service                                                                                loaded    active   running Security Auditing Service
azurelinux-sysinfo.service                                                                    loaded    inactive dead    Azure Linux Sysinfo Service
blk-availability.service                                                                      loaded    inactive dead    Availability of block devices
[..snip..]


-------
● arc-unenroll-file-semaphore.service - Arc-unenrollment upon shutdown service
     Loaded: loaded (/etc/systemd/system/arc-unenroll-file-semaphore.service; enabled; vendor preset: enabled)
     Active: active (exited) since Tue 2024-11-12 06:33:40 UTC; 11h ago
   Main PID: 11663 (code=exited, status=0/SUCCESS)
        CPU: 5ms

Nov 12 06:33:39 rack1compute01 systemd[1]: Starting Arc-unenrollment upon shutdown service...
Nov 12 06:33:40 rack1compute01 systemd[1]: Finished Arc-unenrollment upon shutdown service.


-------
○ atop-rotate.service - Restart atop daemon to rotate logs
     Loaded: loaded (/usr/lib/systemd/system/atop-rotate.service; static)
     Active: inactive (dead)
TriggeredBy: ● atop-rotate.timer
[..snip..]

收集系统诊断数据

系统诊断日志是使用 collect-system-diagnostics 命令收集的。 它会检索所有必要的日志,从而在裸金属机器中提供更深入的可见性。 它收集以下类型的诊断数据。

以下示例在没有参数的情况下执行 collect-system-diagnostics 命令。

  • 系统和内核诊断
    • 内核信息:日志、可读消息、版本和体系结构,用于深入内核诊断。
    • 操作系统日志:详细的日志记录系统活动以及系统服务的容器日志。
  • 硬件和资源使用情况
    • CPU 和 IO 已限速的进程:识别限速问题,提供性能瓶颈相关见解。
    • 网络接口统计信息:网络接口的详细统计数据,用于诊断错误和丢包。
  • 软件和服务
    • 已安装的包:所有已安装包的列表,对于了解系统的软件环境至关重要。
    • 活动系统服务:有关活动服务、进程快照以及详细的系统和进程统计信息的信息。
    • 容器运行时和 Kubernetes 组件日志:Kubernetes 组件的日志,以及群集诊断的其他重要服务。
  • 网络和连接
    • 网络连接跟踪信息:用于防火墙诊断的 Conntrack 统计信息和连接列表。
    • 网络配置和接口详细信息:接口配置、IP 路由、地址和邻居信息。
    • 任何其他接口配置和日志:与节点内所有接口的配置相关的日志。
    • 网络连接测试:测试外部网络连接和 Kubernetes API 服务器通信。
    • DNS 解析配置:用于诊断域名解析问题的 DNS 解析程序配置。
    • 网络配置和日志:全面的网络数据,包括连接跟踪和接口配置。
    • 容器网络接口 (CNI) 配置:用于容器网络诊断的 CNI 配置。
  • 安全性和符合性
    • SELinux 状态:报告 SELinux 模式以了解访问控制和安全上下文。
    • IPtables 规则:配置 IPtables 规则集,以便深入了解防火墙设置。
  • 存储和文件系统
    • 装入点和卷信息:有关装入点、卷、磁盘使用情况和文件系统详细信息。
  • Azure Arc azcmagent 日志
    • 将 Azure 连接的计算机代理和扩展的日志文件收集到 ZIP 存档中。
  • 配置和管理
    • 系统配置:用于全面查看内核运行时配置的 Sysctl 参数。
    • Kubernetes 配置和运行状况:Kubernetes 设置详细信息,包括配置和服务列表。
    • 容器运行时信息:配置、版本信息和运行容器的详细信息。
    • 容器运行时接口(CRI)信息:用于容器运行时接口的操作数据,有助于容器编排诊断。
az networkcloud baremetalmachine run-data-extract --name "bareMetalMachineName" \
  --resource-group "cluster_MRG" \
  --subscription "subscription" \
  --commands '[{"command":"collect-system-diagnostics"}]' \
  --limit-time-seconds 900

collect-system-diagnostics 输出

====Action Command Output====
Trying to check for root... 
Trying to check for required utilities... 
Trying to create required directories... 
Trying to check for disk space... 
Trying to start collecting logs... Trying to collect common operating system logs... 
Trying to collect mount points and volume information... 
Trying to collect SELinux status... 
Trying to collect Containerd daemon information... 
Trying to collect Containerd running information... 
Trying to collect Container Runtime Interface (CRI) information... Trying to collect CRI information... 
Trying to collect kubelet information... 
Trying to collect Multus logs if they exist... 
Trying to collect azcmagent logs... time="2025-09-09T15:21:55Z" level=info msg="Adding directory /var/opt/azcmagent/log to zip"
time="2025-09-09T15:21:55Z" level=info msg="Adding directory /var/lib/GuestConfig/arc_policy_logs to zip"
time="2025-09-09T15:21:57Z" level=info msg="Adding directory /var/lib/GuestConfig/ext_mgr_logs to zip"
time="2025-09-09T15:21:57Z" level=info msg="Adding directory /var/lib/GuestConfig/extension_logs to zip"
time="2025-09-09T15:21:57Z" level=info msg="Adding directory /var/lib/GuestConfig/extension_reports to zip"
time="2025-09-09T15:21:57Z" level=info msg="Adding directory /var/lib/GuestConfig/gc_agent_logs to zip"
time="2025-09-09T15:21:57Z" level=info msg="Diagnostic logs have been saved to /tmp/azcmagent-logs-3765466.zip."


Collecting System logs
Trying to collect kernel logs... 
Trying to collect installed packages... 
Trying to collect active system services... 
Trying to collect sysctls information... 
Trying to collect CPU Throttled Process Information... 
Trying to collect IO Throttled Process Information... 
Trying to collect conntrack information... conntrack v1.4.8 (conntrack-tools): 1917 flow entries have been shown.

Trying to collect ipvsadm information... 
Trying to collect kernel command line... 
Trying to collect configuration files... Collecting Networking logs
Trying to collect networking information... conntrack v1.4.8 (conntrack-tools): 1916 flow entries have been shown.

Trying to collect CNI configuration information... 
Trying to collect iptables information... 

Trying to archive gathered information... 
Finishing up...

	Done... your bundled logs are located in /hostfs/tmp/runcommand/system_diagnostics_bareMetalMachineName_2025-09-09_1519-UTC.tar.gz



================================
Script execution result can be downloaded from storage account using the command: 
 az storage blob download --blob-url https://simdev4003469vm1sa.blob.core.windows.net/command-output-blob/runcommand-output-7d601db8-75b7-4af2-94dd-f4f49ee0b0b7.tar.gz --file runcommand-output-7d601db8-75b7-4af2-94dd-f4f49ee0b0b7.tar.gz --auth-mode login  > /dev/null 2>&1

如何在关联的存储帐户中查看命令的完整输出

若要访问命令的输出,用户需要拥有对存储 Blob 的适当访问权限,包括具有必要的 Azure 角色分配并确保正确配置任何网络限制。

对于角色分配,用户必须在 Blob 容器或其存储帐户上具有以下角色分配:

  • 数据访问角色,例如“存储 Blob 数据读取者”或“存储 Blob 数据参与者”
  • 至少分配 Azure 资源管理器“读取者”角色

有关向存储帐户分配角色的信息,请参阅分配 Azure 角色以访问 blob 数据

对于网络限制,如果存储帐户允许通过防火墙访问公共终结点,则必须使用网络规则配置防火墙,以允许该用户的 IP 地址通过。 如果仅允许专用终结点访问,则用户必须属于有权访问专用终结点的网络。

有关允许使用网络规则专用终结点通过存储帐户防火墙进行访问的信息,请参阅相应的文档。

配置必要的权限和访问权限后,可以使用输出摘要中的链接或命令下载压缩的输出文件 (tar.gz)。

还可以在 Azure 门户中下载:

  1. 从 Azure 门户导航到存储帐户。
  2. 在存储帐户详细信息中,从左侧的导航菜单中选择“存储浏览器”
  3. 在存储浏览器详细信息中,选择“blob 容器”
  4. 选择 Blob 容器。
  5. 从命令中选择输出文件。 可通过输出摘要确定文件名。 此外,“上次修改时间”时间戳将与执行命令的时间一致。
  6. 你可以从“概述”弹出窗口中管理并下载输出文件

下载的 tar.gz 文件包含完整输出和压缩的提取命令文件输出。

此命令提供链接(如果使用群集管理器存储)或其他命令(如果使用用户提供的存储)来下载完整输出。 tar.gz文件还包含压缩的提取命令文件输出。 通过在可选参数 --output-directory中指定目录路径,将输出文件从存储 Blob 下载到本地目录。

警告

使用 --output-directory 参数将覆盖与所创建新文件同名的本地目录中的任何文件。

注释

由于网络或防火墙限制,存储帐户可能会被锁定,导致 403 This request is not authorized to perform this operation.。 有关验证访问权限的过程,请参阅 用户托管存储 部分。

执行 run-data-extracts-restricted 命令

先决条件

  • 最低支持的 API 版本为v20250701previewv20250901或更高版本
  • 已配置存储 Blob 容器
  • 目标裸机已启动并准备就绪。
  • 所需的 az networkcloud CLI 扩展版本为 4.0.0b1+。
  • 获取为群集资源创建的群集受管理资源组名称 (cluster_MRG)。

run-data-extracts-restricted 命令功能复制了不受限制的运行数据提取命令,并通过 RBAC(基于角色的访问控制)实现精细的访问控制。 它允许客户使用提升的权限在 BareMetalMachines 上运行敏感数据提取作。

这是 run-data-extracts-restricted 实现为一个新的、独立的 API 操作。 将在v20250701previewv20250901 GA API 中引入该操作,旨在反映原始命令的行为,但限制对特定子命令的访问。 以下列表包含允许的run-data-extracts-restricted子命令:

可以使用az networkcloud baremetalmachine run-data-extracts-restricted执行命令,它接受与run-data-extract类似的参数。

示例

az networkcloud baremetalmachine run-data-extracts-restricted --name "<machine-name>"  \
  --resource-group "<cluster_MRG>" \
  --subscription "<subscriptionID>" \
  --commands '[{"arguments":["--min-severity=8"],"command":"cluster-cve-report"}]'  \
  --limit-time-seconds "600"
  --output-directory ~/path/to/my/output/directory

存储和输出

运行命令执行的输出默认存储在由该命令定义的 Blob 容器中 commandOutputSettings。 每个命令输出类型(例如 BareMetalMachineRunDataExtractsRestricted)均支持commandOutputSettings值的重写。 有关如何为 runcommand 指定 commandOutputSettings 替代,请参阅 Azure 操作员 Nexus 群集对托管标识和用户提供的资源的支持