支援的作業系統
如需支援 OS Inventory Management 的作業系統和版本完整清單,請參閱「作業系統詳細資料」。
必要角色和權限
如要取得列出及說明資產資料所需的權限,請要求管理員為您授予專案的 OS 資產檢視者(roles/osconfig.inventoryViewer
) 身分與存取權管理角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和機構的存取權」。
設定 VM
您必須先把 VM 設定為會使用 OS Inventory Management,才能讓您使用該功能。如要將 VM 設定為使用 OS Inventory Management,請設定 VM 管理員。
在 VM 上設定 VM 管理員後,您就能查看 OS 庫存資料和安全漏洞報告。
查看 OS 資產資料
如要查看 OS 庫存資料,請使用下列其中一種方法:
查看 VM 的 OS 資產資料
您可以使用 Google Cloud 控制台、gcloud CLI 或 OS Config API,查看特定 VM 的 OS 資訊。
主控台
如要使用 Google Cloud 控制台查看 VM 的 OS 安全漏洞和已安裝套件的相關資訊,請按照下列步驟操作:
- 前往 Google Cloud 控制台的「VM instances」(VM 執行個體) 頁面。
- 按一下要查看 OS 資訊的執行個體名稱。「執行個體詳細資料」頁面隨即顯示。
- 按一下「OS 資訊」分頁標籤。
如要查看 OS 庫存資料,請啟用 VM 管理員。 如果 Google Cloud 控制台提示您啟用 VM 管理員, 請選取下列其中一個選項:- 為目前的專案啟用:為所選專案中的所有 VM 啟用 VM 管理員
- 為這個 VM 啟用:僅為所選 VM 啟用 VM 管理員
- 在「OS 資訊」分頁中,查看 OS 安全漏洞和已安裝套件的清單。
- 選用:如果任何已安裝的套件有更新,請選取套件名稱,然後按一下「套用更新」。
系統隨即會顯示「修補程式」頁面。如要進一步瞭解如何使用 VM 管理員的修補程式功能,請參閱「建立修補程式工作」。
gcloud
如要查看特定 VM 的庫存詳細資料,請執行 os-config inventories describe
指令:
gcloud compute os-config inventories describe VM_NAME \ --location=ZONE \ --view=VIEW
更改下列內容:
VM_NAME
:VM 的名稱ZONE
:VM 執行個體所在的可用區VIEW
:所需的輸出資訊類型。 可用的檢視畫面類型如下:basic
:只顯示 OS 資訊full
:顯示 OS 和套件的相關資訊如未指定,則預設值為
basic
。
範例 (基本檢視畫面)
gcloud compute os-config inventories describe vm1-centos \ --location=us-central1-c
輸出範例
architecture: x86_64 hostname: vm1-centos kernelRelease: 3.10.0-1160.92.1.el7.x86_64 kernelVersion: '#1 SMP Tue Jun 20 11:48:01 UTC 2023' longName: CentOS Linux 7 (Core) osconfigAgentVersion: 20230504.00-g1.el7 shortName: centos updateTime: '2023-07-26T17:03:50Z' version: '7'
範例 (完整檢視畫面)
gcloud compute os-config inventories describe vm1-centos \ --location=us-central1-c \ --view=full
Linux 輸出範例
┌─────────────────────────────────────────────────────────────────────────────────────┐ │ Installed Packages (Yum) │ ├─────────────────────────────────────┬──────────────┬────────────────────────────────┤ │ PACKAGE_NAME │ ARCHITECTURE │ VERSION │ ├─────────────────────────────────────┼──────────────┼────────────────────────────────┤ │ GeoIP │ x86_64 │ 1.5.0-13.el7 │ │ NetworkManager │ x86_64 │ 1:1.12.0-8.el7_6 │ │ NetworkManager-libnm │ x86_64 │ 1:1.12.0-8.el7_6 │ │ NetworkManager-team │ x86_64 │ 1:1.12.0-8.el7_6 │ │ NetworkManager-tui │ x86_64 │ 1:1.12.0-8.el7_6 │ │ acl │ x86_64 │ 2.2.51-14.el7 │ │ yum-cron │ all │ 3.4.3-161.el7.centos │ │ yum-metadata-parser │ x86_64 │ 1.1.4-10.el7 │ │ yum-plugin-fastestmirror │ all │ 1.1.31-50.el7 │ │ zlib │ x86_64 │ 1.2.7-18.el7 │ └─────────────────────────────────────┴──────────────┴────────────────────────────────┘ ┌───────────────────────────────────────────────────────────────────────────────┐ │ Package Updates Available (Yum) │ ├───────────────────────────────┬──────────────┬────────────────────────────────┤ │ PACKAGE_NAME │ ARCHITECTURE │ VERSION │ ├───────────────────────────────┼──────────────┼────────────────────────────────┤ │ GeoIP │ x86_64 │ 1.5.0-14.el7 │ │ NetworkManager │ x86_64 │ 1:1.18.8-2.el7_9 │ │ NetworkManager-libnm │ x86_64 │ 1:1.18.8-2.el7_9 │ │ NetworkManager-team │ x86_64 │ 1:1.18.8-2.el7_9 │ │ yum-cron │ all │ 3.4.3-168.el7.centos │ │ yum-plugin-fastestmirror │ all │ 1.1.31-54.el7_8 │ │ zlib │ x86_64 │ 1.2.7-19.el7_9 │ └───────────────────────────────┴──────────────┴────────────────────────────────┘ architecture: x86_64 hostname: vm1-centos kernelRelease: 3.10.0-957.1.3.el7.x86_64 kernelVersion: '#1 SMP Thu Nov 29 14:49:43 UTC 2018' longName: CentOS Linux 7 (Core) osconfigAgentVersion: 20230504.00-g1.el7 shortName: centos updateTime: '2021-05-11T22:21:52.323Z' version: '7'
Windows 輸出範例
┌───────────────────────────────────────────────────────────┐ │ Installed Packages (GooGet) │ ├───────────────────────┬──────────────┬────────────────────┤ │ PACKAGE_NAME │ ARCHITECTURE │ VERSION │ ├───────────────────────┼──────────────┼────────────────────┤ │ google-osconfig-agent │ x86_64 │ 20210415.4.0+win@1 │ └───────────────────────┴──────────────┴────────────────────┘ ┌───────────────────────────────────────────────────┐ │ Installed Packages (Windows Update Agent) │ ├───────┬────────────┬────────────────┬─────────────┤ │ TITLE │ CATEGORIES │ KB_ARTICLE_IDS │ SUPPORT_URL │ ├───────┼────────────┼────────────────┼─────────────┤ │ title │ C1, C2 │ 4589208 │ url.com │ └───────┴────────────┴────────────────┴─────────────┘ ┌───────────────────────────────────────────────────────────────┐ │ Installed Packages (Quick Fix Engineering) │ ├─────────┬─────────────────┬────────────┬──────────────────────┤ │ CAPTION │ DESCRIPTION │ HOT_FIX_ID │ INSTALL_TIME │ ├─────────┼─────────────────┼────────────┼──────────────────────┤ │ caption │ Security Update │ KB4470788 │ 2019-03-12T00:00:00Z │ └─────────┴─────────────────┴────────────┴──────────────────────┘ ┌───────────────────────────────────────────────────────────────────────────┐ │ Installed Packages (Windows Application) │ ├──────────────────┬─────────────────┬───────────────────────┬──────────────┤ │ DISPLAY_NAME │ DISPLAY_VERSION │ PUBLISHER │ INSTALL_DATE │ ├──────────────────┼─────────────────┼───────────────────────┼──────────────┤ │ PowerShell 7-x64 │ 7.0.2.0 │ Microsoft Corporation │ 2021-06-08 │ └──────────────────┴─────────────────┴───────────────────────┴──────────────┘ ┌───────────────────────────────────────────────────────────┐ │ Package Updates Available (GooGet) │ ├───────────────────────┬──────────────┬────────────────────┤ │ PACKAGE_NAME │ ARCHITECTURE │ VERSION │ ├───────────────────────┼──────────────┼────────────────────┤ │ google-osconfig-agent │ x86_64 │ 20210415.4.0+win@1 │ └───────────────────────┴──────────────┴────────────────────┘ ┌───────────────────────────────────────────────────┐ │ Package Updates Available (Windows Update Agent) │ ├───────┬────────────┬────────────────┬─────────────┤ │ TITLE │ CATEGORIES │ KB_ARTICLE_IDS │ SUPPORT_URL │ ├───────┼────────────┼────────────────┼─────────────┤ │ title │ C1, C2 │ 4589208 │ url.com │ └───────┴────────────┴────────────────┴─────────────┘ ┌───────────────────────────────────────────────────────────────┐ │ Package Updates Available (Quick Fix Engineering) │ ├─────────┬─────────────────┬────────────┬──────────────────────┤ │ CAPTION │ DESCRIPTION │ HOT_FIX_ID │ INSTALL_TIME │ ├─────────┼─────────────────┼────────────┼──────────────────────┤ │ caption │ Security Update │ KB4470788 │ 2019-03-12T00:00:00Z │ └─────────┴─────────────────┴────────────┴──────────────────────┘ architecture: x86_64 hostname: vm3-windows kernelRelease: 10.0.17763.1817 kernelVersion: 10.0.17763.1817 (WinBuild.160101.0800) longName: Microsoft Windows Server 2019 Datacenter osconfigAgentVersion: 20210901.00.0+win@1 shortName: windows updateTime: '2021-09-12T22:14:35Z' version: 10.0.17763
REST
如要查看特定 VM 的目錄詳細資料,請對 projects.locations.instances.inventories.get
方法建立 GET
要求。
GET https://osconfig.googleapis.com/v1/projects/PROJECT_ID/locations/ZONE/instances/INSTANCE/inventory
更改下列內容:
PROJECT_ID
:您的專案 IDZONE
:VM 執行個體所在的可用區INSTANCE
:指定 VM 的執行個體 ID 或名稱
查看特定可用區中 VM 的 OS 資產資料
您可以使用 gcloud CLI 或 OS Config API,查看特定區域中 VM 的 OS 資訊。
gcloud
如要查看特定可用區中 VM 的庫存資料清單,請執行 os-config inventories list
指令。
gcloud compute os-config inventories list \ --location=ZONE \ --view=VIEW
更改下列內容:
ZONE
:VM 所在的可用區VIEW
:所需的輸出資訊類型。 可用的檢視畫面類型如下:basic
:只顯示 OS 資訊full
:顯示 OS 和套件的相關資訊如未指定,則預設值為
basic
。
範例 (基本檢視畫面)
gcloud compute os-config inventories list \ --location=us-central1-c
輸出結果會與下列內容相似:
INSTANCE_ID INSTANCE_NAME OS OSCONFIG_AGENT_VERSION UPDATE_TIME 29255009728795105 vm1-centos CentOS Linux 7 (Core) 20230504.00-g1.el7 2023-07-26T16:53:49Z 5138980234596718741 vm2-rhel8 Red Hat Enterprise Linux 8.8 (Ootpa) 20230504.00-g1.el8 2023-07-26T16:55:33Z 7127836223366142250 vm3-windows Microsoft Windows Server 2022 Datacenter 20230403.00.0+win@1 2023-07-26T16:49:16Z
範例 (完整檢視畫面)
gcloud compute os-config inventories list \ --location=us-central1-c \ --view=full
輸出結果會與下列內容相似:
INSTANCE_ID INSTANCE_NAME OS INSTALLED_PACKAGES AVAILABLE_PACKAGES OSCONFIG_AGENT_VERSION UPDATE_TIME 29255009728795105 vm1-centos CentOS Linux 7 (Core) 334 2 20230504.00-g1.el7 2023-07-26T16:53:49Z 5932621394110773366 vm2-rhel8 Red Hat Enterprise Linux 8.8 (Ootpa) 410 138 20230504.00-g1.el8 2023-07-26T16:55:33Z 7127836223366142250 vm3-windows Microsoft Windows Server 2022 Datacenter 36 6 20230403.00.0+win@1 2023-07-26T16:49:16Z
REST
如要查看特定可用區中 VM 的清單,請對 projects.locations.instances.inventories.list
方法建立 GET
要求。
GET https://osconfig.googleapis.com/v1/projects/PROJECT_ID/locations/ZONE/instances/–/inventories
更改下列內容:
PROJECT_ID
:您的專案 IDZONE
:VM 所在的可用區
透過 Cloud Asset Inventory 查看 OS 資產資料
OS 庫存管理服務會儲存庫存和安全漏洞報告資料,並轉送至 Cloud Asset Inventory。Cloud Asset Inventory 是一項中繼資料儲存庫服務,可讓您檢視、監控及分析各項資產 Google Cloud。您可以透過 Cloud Asset Inventory 輪詢資訊,並查看資料變更。
如要從 Cloud Asset Inventory 存取 OS 庫存和安全漏洞報告資料,請完成下列設定:
- 設定 VM 管理員。
- 在 Google Cloud 專案中,啟用 Cloud Asset Inventory API、Google Cloud CLI,並指派權限。
詳情請參閱「查看 VM 管理員資料」。
OS 庫存管理服務 (舊版)
如果您仍在使用舊版 OS 庫存管理服務,請展開下列章節,查看 Google Cloud CLI 的操作說明。
OS 庫存管理服務 (舊版)
列出 VM如要查看已設定 OS Inventory Management 的 VM 清單,請執行 instances
os-inventory list-instances
指令。
舉例來說,如要列出有庫存資料的所有 VM,請執行下列指令:
gcloud compute instances os-inventory list-instances
輸出結果會與下列內容相似:
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS inventory-instance us-east1-b e2-standard-2 192.0.2.1 RUNNING instance-inventory1 us-west1-b e2-standard-2 192.0.2.2 RUNNING instance-inventory2 asia-east2-b e2-standard-2 192.0.2.3 RUNNING
您也可以使用篩選器來縮小搜尋結果範圍。舉例來說,如要列出已設定 OS Inventory Management,且主機名稱符合規則運算式 instance-*
的所有 VM,請執行下列指令:
gcloud compute instances os-inventory list-instances --inventory-filter="Hostname~instance-*"
輸出結果會與下列內容相似:
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS inventory-instance us-east1-b e2-standard-2 192.0.2.1 RUNNING instance-inventory1 us-west1-b e2-standard-2 192.0.2.2 RUNNING instance-inventory2 asia-east2-b e2-standard-2 192.0.2.3 RUNNING
如要查看 VM 的庫存資料,請使用 instances
os-inventory describe
指令。
如要查看系統針對特定 VM 收集的庫存資料,請執行下列指令:
gcloud compute instances os-inventory describe VM_NAME \ --zone=ZONE
更改下列內容:
VM_NAME
:VM 名稱ZONE
:VM 所在的可用區
如要查看指令傳回的輸出內容類型詳細資料,請參閱「OS Inventory Management 提供的資訊」一節。
後續步驟
- 查看作業系統的安全漏洞報告。
- 進一步瞭解 OS 廣告空間管理。