Skip to content

hardware module

BlockDevice

Attributes:

Name Type Description
blocks

The filesystem's total 1K-block count, as the raw string df prints.

used

The used block count, as a raw string.

available

The available block count, as a raw string.

used_percent

The use percentage without the % sign, as a raw string.

mount

The mount point path.

BlockDevices

The mounted block devices, as a dict of device -> BlockDevice dict.

Commands:

df

Returns:

dict[str, BlockDevice]

Raises:

CommandNotFoundError, HostConnectionError

Examples:

Examples can be found in examples/modules/hardware/hardware_block_devices.py.

CpuInfo

The CPU details reported by lscpu, as a dict (or None).

Commands:

LANG=C lscpu

Returns:

dict[str, str | list[str]] | None

Raises:

CommandNotFoundError, HostConnectionError

Examples:

Examples can be found in examples/modules/hardware/hardware_cpu_info.py.

Cpus

The number of online CPUs on the machine, as an int (or None).

Commands:

getconf NPROCESSORS_ONLN 2> /dev/null || getconf _NPROCESSORS_ONLN

Returns:

int | None

Raises:

CommandNotFoundError, HostConnectionError

Examples:

Examples can be found in examples/modules/hardware/hardware_cpus.py.

DiskStat

Attributes:

Name Type Description
reads_completed

Reads completed successfully.

reads_merged

Reads merged before queueing.

sectors_read

Sectors read (512-byte units).

ms_reading

Milliseconds spent reading.

writes_completed

Writes completed successfully.

writes_merged

Writes merged before queueing.

sectors_written

Sectors written (512-byte units).

ms_writing

Milliseconds spent writing.

ios_in_progress

IOs currently in flight.

ms_doing_io

Milliseconds spent doing IOs.

weighted_ms_doing_io

Milliseconds spent doing IOs, weighted by the number of IOs in flight.

discards_completed

Discards completed successfully, on a 4.18+ kernel that prints the discard group.

discards_merged

Discards merged before queueing, on a 4.18+ kernel that prints the discard group.

sectors_discarded

Sectors discarded (512-byte units), on a 4.18+ kernel that prints the discard group.

ms_discarding

Milliseconds spent discarding, on a 4.18+ kernel that prints the discard group.

flush_requests

Flush requests completed, on a 5.5+ kernel that prints the flush group.

ms_flushing

Milliseconds spent flushing, on a 5.5+ kernel that prints the flush group.

DiskStats

The per-device IO counters, as a dict of device -> DiskStat dict.

Commands:

cat /proc/diskstats

Returns:

dict[str, DiskStat]

Raises:

CommandNotFoundError, HostConnectionError

Examples:

Examples can be found in examples/modules/hardware/hardware_disk_stats.py.

DmiInfo

The DMI identity fields from sysfs, as a dict of field -> value.

Commands:

grep -H '' /sys/class/dmi/id/* 2> /dev/null || true

Returns:

dict[str, str]

Raises:

HostConnectionError

Examples:

Examples can be found in examples/modules/hardware/hardware_dmi_info.py.

Ipv4Address

Attributes:

Name Type Description
address

The IPv4 address string, as the command printed it.

mask_bits

The prefix length in bits, when the listing carried a mask token.

netmask

The dotted-quad netmask, when the listing carried a mask token (a prefix length is expanded to its netmask).

broadcast

The broadcast address, or None when the listing carried none.

additional_ips

The alias addresses, as further Ipv4Address entries in listing order; absent when the interface carries only one IPv4 address.

Ipv4Addrs

The IPv4 addresses per network interface, as interface -> list.

Commands:

ip -j addr show 2> /dev/null || ip addr show 2> /dev/null || ifconfig -a

Returns:

dict[str, list[str]]

Raises:

CommandNotFoundError, HostConnectionError

Examples:

Examples can be found in examples/modules/hardware/hardware_ipv4_addrs.py.

Ipv6Address

Attributes:

Name Type Description
address

The IPv6 address string, as the command printed it.

mask_bits

The prefix length in bits, when the listing carried a mask token.

additional_ips

The alias addresses, as further Ipv6Address entries in listing order; absent when the interface carries only one IPv6 address.

Ipv6Addrs

The IPv6 addresses per network interface, as interface -> list.

Commands:

ip -j addr show 2> /dev/null || ip addr show 2> /dev/null || ifconfig -a

Returns:

dict[str, list[str]]

Raises:

CommandNotFoundError, HostConnectionError

Examples:

Examples can be found in examples/modules/hardware/hardware_ipv6_addrs.py.

LsBlk

The complete block device tree, as a list of LsBlkNode dicts.

Commands:

lsblk -J -b -o NAME,TYPE,SIZE,MOUNTPOINT

Returns:

list[LsBlkNode]

Raises:

CommandNotFoundError, HostConnectionError

Examples:

Examples can be found in examples/modules/hardware/hardware_lsblk.py.

LsBlkNode

Attributes:

Name Type Description
name

The device name (e.g. sda, sda1).

type

The device type (disk/part/lvm/...).

size

The device size in bytes (lsblk -b).

mountpoint

The mount point path, or None when unmounted (the singular MOUNTPOINT column reports only the last mount when a device is mounted at several paths).

children

The stacked devices nested under this node, as further LsBlkNode entries; absent on a leaf device.

NetworkDevice

Attributes:

Name Type Description
state

The interface state (UP/DOWN/UNKNOWN).

ether

The MAC address, when the listing carried one.

mtu

The interface MTU, when the listing carried one.

ipv4

The primary IPv4 address block, when the interface carries an IPv4 address.

ipv6

The primary IPv6 address block, when the interface carries an IPv6 address.

NetworkDevices

The network devices, as a dict of interface -> NetworkDevice dict.

Commands:

ip -j addr show 2> /dev/null || ip addr show 2> /dev/null || ifconfig -a

Returns:

dict[str, NetworkDevice]

Raises:

CommandNotFoundError, HostConnectionError

Examples:

Examples can be found in examples/modules/hardware/hardware_network_devices.py.

SmbiosInfo

The decoded SMBIOS/DMI tables, as a dict of section -> field dict.

Commands:

dmidecode -q 2> /dev/null || sudo -n dmidecode -q 2> /dev/null || true

Returns:

dict[str, dict[str, str | list[str]]]

Raises:

HostConnectionError

Examples:

Examples can be found in examples/modules/hardware/hardware_smbios_info.py.