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.
| Field | Type | Description |
|---|---|---|
cpu_percent | integer | CPU utilization across all cores, 0 to 100, rounded down; 0 until two samples form a delta. |
ram_percent | integer | Physical memory in use (MemTotal - MemAvailable), 0 to 100, rounded down. |
swap_percent | integer | Swap in use, 0 to 100, rounded down; also 0 without swap. |
temp_cores | integer[] | 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 | integer | amdgpu, 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.
| Action | Arguments | Description |
|---|---|---|
configure | intervals: SysinfoConfigure | Sets 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.
| Field | Type | Description |
|---|---|---|
cpu_interval? | integer | Seconds between CPU reads; 0 (the default) stops them. |
ram_interval? | integer | Seconds between memory and swap reads; 0 (the default) stops them. |
temp_interval? | integer | Seconds between temperature reads; 0 (the default) stops them. |
Backend
| Field | Read from | Interval |
|---|---|---|
cpu_percent | /proc/stat’s cpu line, the delta between two reads | cpu_interval |
ram_percent, swap_percent | /proc/meminfo | ram_interval |
temp_cores | hwmon k10temp Tccd* or coretemp Core * sensors, else that chip’s first sensor, else acpitz’s | temp_interval |
temp_gpu | The first sensor of hwmon amdgpu, nouveau or nvidia | temp_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
| Trap | Fix |
|---|---|
sysinfo stays nil | Nothing 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 moves | Each field updates on its own interval, and an unset one is 0 (off). Set ram_interval too |