Skip to content

Hyper-V virtual disks over WinRM (win_hyperv_storage) ​

Reads the virtual hard disks of a Hyper-V host over WinRM or native WMI: how big the files are, how big the disks may grow, how full the fullest one is of its maximum, whether a disk's file is missing, and how much room is left on the volume with the least. A set of dynamically expanding disks promised more than the volume holds is the usual way a Hyper-V host runs out of space without anyone touching a machine, which is why the volume's free space is read here too.

Transport. Under a Windows probe the device can be set to read this sensor over native WMI instead of WinRM; the queries and the result are the same. The target is then set up as in the WMI setup guide instead.

What it looks like ​

The page of a win_hyperv_storage sensor in the light theme

The sensor's page after a few polls, watching a Windows Server Hyper-V host with one small guest. In the dark theme: the sensor's page. The form for adding it: light, dark.

Channels ​

KeyNameUnitDefault limits
vmms_stateManagement service (vmms)Stopped is Down
disksVirtual disksnone
disks_missingDisk files missingerror above 0
file_size_bytesSize of the disk filesBnone
max_size_bytesSize the disks may grow toBnone
fill_pctFullest disk, of its maximum%none
volume_free_pctFree space on the fullest volume%warning below 15, error below 5
volume_free_bytesFree space on that volumeBnone

Sizes are totals over the disks read; fill_pct and the volume figures are the worst of them, and the message names the machine whose disk is on the volume with least room. By default every machine on the host is read; vm limits it to one.

Only hard disks, only the disk a machine uses now. CD and DVD images and floppy images are not counted. A disk that has snapshots (differencing disks) is read as the file the machine writes to now; its parents are not added.

The maximum is known only while the machine runs. The size a disk may grow to comes from the machine's logical disk (Msvm_LogicalDisk), which Hyper-V creates when the machine starts and removes when it stops. For a machine that is off, the file size and the volume are read and the maximum and fill_pct are unknown, not guessed. When the sensor reads all the machines of a host, max_size_bytes adds only those that run.

Fragmentation is not reported. The fragmentation of a disk file that Hyper-V Manager shows is returned only by a method of the management service (GetVirtualHardDiskState), which an enumeration cannot call; the class that carries it (Msvm_VirtualHardDiskState) lists no instances. It was looked for on Windows Server 2022 and is left out rather than shown as a channel that is always empty.

Where the file is. Each disk file is read by name from CIM_DataFile, one query for each disk (at most 200 disks per poll), and the volume is the one with the longest mount point the path starts with (Win32_Volume), so a volume mounted in a folder is found before the drive that holds the folder. A file on a share (\\server\share\...) or any path that does not begin with a drive letter cannot be read by CIM_DataFile: such a disk is counted in disks but gets no file size, no volume reading and is not reported as missing. A disk whose local file is not found is counted in disks_missing, which is an error by default: a machine whose disk is gone will not start.

Parameters ​

ParameterDefaultMeaning
vmevery machineOnly the disks of this machine, by name or identifier. Case does not matter.
port5985, or 5986 with httpsTCP port of the WinRM listener.
httpsfalseUse the HTTPS listener instead of HTTP with message encryption.
accept_self_signedfalseAccept an HTTPS certificate that cannot be verified. The credential has the same switch; either one is enough.

Suggested interval: 300 seconds. Credential: Windows, on the Hyper-V host. Discovery proposes one sensor for the host, covering every machine.

Where the data comes from ​

ChannelSource
the disksMsvm_StorageAllocationSettingData in root\virtualization\v2, the Microsoft:Hyper-V:Virtual Hard Disk rows that belong to a machine (the Microsoft:Definition\... rows are Hyper-V's templates and are left out); HostResource is the file.
max_size_bytes, fill_pctMsvm_LogicalDisk (NumberOfBlocks times BlockSize) of the same machine and controller slot.
file_size_bytesCIM_DataFile.FileSize in root\cimv2, by name. The name comes from the host's own answer and is escaped.
volume_free_pct, volume_free_bytesWin32_Volume (FreeSpace, Capacity) of fixed volumes.

On the target and failures ​

As for the host sensor; the account must also be able to read file information of the folders that hold the disks. Specific to this sensor:

MessageMeaning
the host has no virtual machine named X (it lists ...) (kind config)vm is not one of the host's machines.
no file for C:\... in the message, disks_missing above 0The machine's configuration points to a disk file that is not there.

Verification ​

Checked against WS-Man responses recorded from a real Windows Server 2022 Hyper-V host with one small guest and one dynamically expanding 2 GB disk (a 4 MiB file), with the guest running and turned off, and against that host live over NTLM with message encryption in both states, including a disk read for one machine and for all.

The host is a virtual machine under KVM on a Linux workstation, so the Hyper-V role runs nested. That took one change: with the CPU passed through and vmx on, Windows hung before the hypervisor started (a static boot logo, then the recovery environment after a hard reset). It started once the CPU's control-flow enforcement features (cet-ss and cet-ibt) were hidden from the guest and QEMU's Hyper-V enlightenments were passed through (hyperv mode='passthrough'), with QEMU 11 and a recent Linux kernel.

The share path, the missing file and the small-volume limits are written by hand: the lab host has one volume and one local disk. Not seen: a Cluster Shared Volume, an SMB share, a differencing disk, a fixed-size disk, a volume mounted in a folder, hundreds of disks, and a non-administrator account.

Live tests are described on the host page.

AGPL-3.0-only