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 and swap use, CPU and GPU temperatures. nil until configure sets intervals.

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

text {
    content = mantle.sysinfo:map(function(sysinfo)
        if sysinfo == nil then
            return ""
        end
        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.
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_gpuintegeramdgpu, nouveau or nvidia hwmon temperature in whole Celsius, or -1 without a readable one.

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 drops the call.

FieldTypeDescription
cpu_interval?integerSeconds between CPU 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 or nvidiatemp_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.system.time’s tick and the two can share one layout pass.

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

Source: supervisor/src/capabilities/sysinfo/