From 891a31fe455dbbd7da662c31e333c7861f0296e3 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Tue, 1 Dec 2026 12:53:46 +0100 Subject: [PATCH] docs: the host basics in the README and CHANGELOG; harvest records their scripts --- CHANGELOG.md | 28 ++++++++++++++++++++++++++++ README.md | 31 ++++++++++++++++++++++++++++++- tools/harvest.py | 16 +++++++++++++++- 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23eb7c0..3ef9f1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,34 @@ All notable changes to this driver. The format follows ## [Unreleased] ### Added +- The host's SMBIOS identity, what ties it to its BMC (NetOrk/netork#2888): + `get_system_identity` reads the system UUID and product serial + (`Win32_ComputerSystemProduct`), the board serial (`Win32_BaseBoard`) and the system + firmware's vendor, version and release date (`Win32_BIOS`) in one script of its own. + Vendor placeholders such as "To be filled by O.E.M." or an all-F UUID read as empty, + by napalm-device-types' rules (`clean_system_identity`). +- Running processes (NetOrk/netork#2889): `get_processes` lists them the way `ps` does -- + parent, owner, CPU and memory share, virtual and resident size, start and command line + -- from `Win32_Process` and `Get-Process -IncludeUserName` in one script. A process + that exited between the two reads, or whose PID was reused in between, is left out. +- Local accounts (NetOrk/netork#2889): `get_os_users` lists the host's own accounts with + their local groups and profile folder. `uid` is the account's relative identifier + (500 for the built-in Administrator), `sid` its whole security identifier. A domain + controller, which has no local accounts, and a host without the LocalAccounts cmdlets + raise `NotImplementedError`. +- Installed software (NetOrk/netork#2890): `get_packages` lists the programs installed + for the whole machine from the Uninstall keys, the 64-bit and the 32-bit ones, each + with its publisher and architecture; `source` is `msi` or `exe`. Hidden system + components and updates listed under their product are left out. Programs installed + for one user only, and Store apps, are not read yet; nothing is installed or removed. +- Restart required and automatic updates (NetOrk/netork#2891): `get_host_status` says + the host needs a restart when Windows Update or component servicing waits for one; + pending file renames, a pending update executable and a new computer name are named + in the reason but do not count on their own. Automatic updates follow the Windows + Update policy (`NoAutoUpdate`, `AUOptions`); without one a Windows client installs on + its own and a server follows its local setting. When they last succeeded is the + latest successful installation Windows Update recorded; the system drive's size and + free space come with it. Nothing searches for updates during the reading. - Restarting and shutting the host down (NetOrk/netork#2841): `reboot_host()` and `shutdown_host()` from napalm-device-types' `HostRebootMixin` and `HostShutdownMixin` run `Restart-Computer` and `Stop-Computer` over the PSRP connection, neither with diff --git a/README.md b/README.md index cae0cc4..8f825f6 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,11 @@ handshake once. | `get_scheduled_jobs` | `Get-ScheduledTask` + `Get-ScheduledTaskInfo`, one script; `\Microsoft\*` is `platform`, other tasks `admin`, the root task an application wrote `application`; time zone mapped to IANA for the common zones | | `manage_scheduled_job` | `Enable-`/`Disable-ScheduledTask`, `Start-ScheduledTask` (returns once started; the result shows in the next reading) | | `put_scheduled_job` / `delete_scheduled_job` | `Register-ScheduledTask -Xml -Force` in the root folder, `Unregister-ScheduledTask`; an application's tasks only | +| `get_system_identity` | `Win32_ComputerSystemProduct` (UUID, serial), `Win32_BaseBoard`, `Win32_BIOS`; placeholders empty (napalm-device-types' `clean_system_identity`). See *Host basics* | +| `get_processes` | `Win32_Process` joined with `Get-Process -IncludeUserName` by PID and start, shaped like `ps` | +| `get_os_users` | `Get-LocalUser`, `Get-LocalGroup` + `Get-LocalGroupMember` (ADSI fallback), `Win32_UserProfile`; the RID as `uid`, the SID as `sid` | +| `get_packages` | The machine-wide Uninstall keys, native and `WOW6432Node`; no per-user installs, no Store apps, nothing installed | +| `get_host_status` | `Microsoft.Update.SystemInfo`, the registry's restart markers, the Windows Update policy and history, the system drive | | `get_time_sync` / `configure_time_sync` | w32time's registry values (group policy first), `w32tm /query /status`, the registry's `TimeZoneInformation`; writes `NtpServer`/`Type` + `w32tm /config /update`, `Set-TimeZone`. See *Time sync* | `running_kernel` carries the full build including the update revision @@ -97,7 +102,31 @@ napalm-device-types' `TimeSyncMixin`; both the servers and the zone are written. zone with summer time switched off reads as `None`; writing the zone switches it back on. -Not yet: packages, Windows Update, health metrics, Hyper-V. +### Host basics + +* **Identity.** Windows decodes the SMBIOS system UUID the way dmidecode does; the + release date is CIM's midnight UTC, read as that day. +* **Processes.** `cpu` is the CPU time over the time since the start, per logical + processor; `memory` the working set over the visible memory; `started` the local time + as `ps -o lstart` prints it. Windows has no controlling terminal and no `ps` state: + `tty` and `state` are empty. The owner needs an elevated session; without one it is + empty. PID 0 (System Idle Process) is no process. +* **Local accounts.** `gid` is 513, the primary group of every local account; `home` is + the profile folder, empty until the account first logs on; `shell` is empty. +* **Packages.** A 32-bit and a 64-bit install of one program are two packages, told + apart by `architecture`. Keys without a `DisplayName`, `SystemComponent=1` and + entries with a `ParentKeyName` are left out. +* **Restart required** is Windows Update's `RebootRequired` (or its registry marker) or + component servicing's `RebootPending`. `PendingFileRenameOperations`, + `UpdateExeVolatile` and a pending computer rename only make up the reason. +* **Automatic updates.** Policy first: `NoAutoUpdate=1` off, `AUOptions` 4 on, 2, 3 + and 7 off, 5 the local setting. Without a policy a client is on and a server follows + its local `AUOptions`; a server with neither reads as unknown. The last success is the + latest successful installation Windows Update recorded (its history, the AutoUpdate + result, the older registry result); the interval is 31 days, the cadence of the + monthly cumulative update. + +Not yet: Windows Update, health metrics, Hyper-V. See netork#300 for the plan. ## Preparing a host diff --git a/tools/harvest.py b/tools/harvest.py index 38de2f4..8bfbe9e 100644 --- a/tools/harvest.py +++ b/tools/harvest.py @@ -14,7 +14,16 @@ import argparse import getpass import pathlib -from napalm_windows import WindowsDriver, scheduled_tasks, time_sync +from napalm_windows import ( + WindowsDriver, + host_status, + os_users, + packages, + processes, + scheduled_tasks, + system_identity, + time_sync, +) from napalm_windows import windows as mod SCRIPTS = { @@ -27,6 +36,11 @@ SCRIPTS = { "listening": mod._PS_LISTENING, "scheduled_tasks": scheduled_tasks._PS_SCHEDULED_TASKS, "time_sync": time_sync._PS_TIME_SYNC, + "system_identity": system_identity._PS_SYSTEM_IDENTITY, + "processes": processes._PS_PROCESSES, + "os_users": os_users._PS_OS_USERS, + "packages": packages._PS_PACKAGES, + "host_status": host_status._PS_HOST_STATUS, } OUT = pathlib.Path(__file__).parent / "harvest-out"