Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

sysinfo

CPU, memory, swap, disks, GPU, network and temperatures. nil until configure sets intervals.

mantle.sysinfo:configure({ cpu_interval = 2, ram_interval = 5 })

text {
    content = mantle.sysinfo:map(function(sysinfo)
        return string.format("CPU %d%%  RAM %d%%", sysinfo.cpu_percent, sysinfo.ram_percent)
    end, ""),
}

State

mantle.sysinfo:get() returns SysinfoState, nil before the first push. A field marked ? may be absent.

mantle.sysinfo’s payload; nil until configure sets an interval and a reading changes a field. Pushes only on a change.

FieldTypeDescription
cpu_percentintegerCPU utilization across all cores, 0 to 100, rounded down; 0 until two samples form a delta.
disksDiskDevice[]Physical block devices and their mounted partitions.
gpu?GpuTelemetryGPU telemetry (load, VRAM, temperature) if a supported backend was detected; nil otherwise.
net_rx_bytes_secintegerDownload rate across active non-loopback interfaces in bytes per second; 0 until two samples form a delta.
net_tx_bytes_secintegerUpload rate across active non-loopback interfaces in bytes per second; 0 until two samples form a delta.
ram_percentintegerPhysical memory in use (MemTotal - MemAvailable), 0 to 100, rounded down.
swap_percentintegerSwap in use, 0 to 100, rounded down; also 0 without swap.
temp_coresinteger[]CPU temperatures in whole Celsius: per core (coretemp) or per CCD (k10temp), else one package or acpitz reading; empty without a sensor. An unreadable sensor is skipped.
temp_gpu?integeramdgpu, nouveau, nvidia, i915 or xe hwmon temperature in whole Celsius, or nil without a readable one.

DiskDevice

One physical block device and its mounted partitions.

FieldTypeDescription
namestringKernel block device name, e.g. “nvme0n1” or “sda”.
partitionsDiskPartition[]Mounted partitions under this block device.
percentintegerAggregate percentage in use, 0 to 100.
total_bytesintegerAggregate total bytes across mounted partitions.
used_bytesintegerAggregate bytes in use across mounted partitions.

DiskPartition

One mounted partition under a physical block device.

FieldTypeDescription
mount_pointstringMountpoint path, e.g. “/” or “/home”.
percentintegerPercentage in use, 0 to 100.
total_bytesintegerTotal bytes on this filesystem.
used_bytesintegerBytes in use on this filesystem.

GpuTelemetry

Telemetry metrics for the first detected GPU device.

FieldTypeDescription
mem_total?integerTotal VRAM in bytes, or nil if shared or unavailable.
mem_used?integerDedicated/used VRAM in bytes, or nil if shared or unavailable.
namestringDevice model name reported by driver/tool, e.g. “Raptor Lake-P (Iris Xe Graphics)” or “NVIDIA GeForce RTX 4070”.
temp?integerGPU temperature in whole Celsius, or nil if no sensor reported.
util_percent?integerGPU core utilization percentage, 0 to 100.

Actions

Call each as mantle.sysinfo:<action>(arguments...); ? marks an argument you may omit.

ActionArgumentsDescription
configureintervals: SysinfoConfigureSets poll intervals; every one starts at 0, so nothing is read until this. The first reading lands on the next wall-clock second (CPU: one interval after it).

SysinfoConfigure

sysinfo:configure’s table. Absent keys keep their interval; one wrong-typed key raises at the call.

FieldTypeDescription
cpu_interval?integerSeconds between CPU reads; 0 (the default) stops them.
disk_interval?integerSeconds between disk space reads; 0 (the default) stops them.
gpu_interval?integerSeconds between GPU telemetry reads; 0 (the default) stops them.
net_interval?integerSeconds between network throughput reads; 0 (the default) stops them.
ram_interval?integerSeconds between memory and swap reads; 0 (the default) stops them.
temp_interval?integerSeconds between temperature reads; 0 (the default) stops them.

Backend

FieldRead fromInterval
cpu_percent/proc/stat’s cpu line, the delta between two readscpu_interval
ram_percent, swap_percent/proc/meminforam_interval
temp_coreshwmon k10temp Tccd* or coretemp Core * sensors, else that chip’s first sensor, else acpitz’stemp_interval
temp_gpuThe first sensor of hwmon amdgpu, nouveau, nvidia, i915 or xetemp_interval
diskslsblk --json --bytes block devices and mounted partitions (FSUSED and FSSIZE)disk_interval
gpunvtop -s, nvidia-smi or DRM sysfsgpu_interval
net_rx_bytes_sec, net_tx_bytes_sec/proc/net/dev non-loopback interface counter deltasnet_interval

The chips are picked once, when sysinfo starts; a driver loaded later needs a Supervisor restart. A reading pushes only when it changed a field. Intervals live in the Supervisor, so they outlast reloads until the next configure. Each read runs on the wall-clock second, first at the next one after configure, so it lands with mantle.clock.time’s tick and the two can share one layout pass.

How do I…

Show GPU, disk, and network transfer rates

mantle.sysinfo:configure({ disk_interval = 30, gpu_interval = 2, net_interval = 1 })

text {
    content = mantle.sysinfo:map(function(sysinfo)
        local gpu_str = sysinfo.gpu and sysinfo.gpu.util_percent and
            string.format("GPU %d%%", sysinfo.gpu.util_percent) or "GPU --"
        local disk = sysinfo.disks[1]
        local disk_str = disk and string.format("Disk %d%%", disk.percent) or "Disk --"
        local down_kib = sysinfo.net_rx_bytes_sec // 1024
        local up_kib = sysinfo.net_tx_bytes_sec // 1024
        return string.format("%s  %s  ↓%d KiB/s ↑%d KiB/s", gpu_str, disk_str, down_kib, up_kib)
    end, ""),
}

Gotchas

TrapFix
sysinfo stays nilNothing is read until configure. With only temp_interval set on a machine without sensors, every reading equals the defaults and nothing pushes
ram_percent stays 0 while cpu_percent movesEach field updates on its own interval, and an unset one is 0 (off). Set ram_interval too
gpu stays nilNo supported GPU tool (nvtop, nvidia-smi) or DRM sysfs was found, or gpu_interval is unset
disks stays emptylsblk is missing or returned no mounted partitions, or disk_interval is unset
net_rx_bytes_sec stays 0Rate calculation needs two consecutive samples. Set net_interval to 1 or higher
Network rates look high with bridges or tunnelsThe counters include every non-loopback interface, including virtual ones; the same traffic may cross more than one

See also: clock for clock time; battery for charge and power; network for Wi-Fi and connectivity.

Source: supervisor/src/capabilities/sysinfo/