ela
Contents

ManualPackages

System readings

In the terminalela --spec system-readings

The machine's readings as maps and lists, under the sys prefix, read from /proc and /sys. Bytes are numbers of bytes, rates bytes a second, temperatures degrees Celsius, percentages 0 to 100. A figure the machine does not report is a key left out, never a 0: test it with has.

Built-inDoes
sys.cpus()How many CPUs this process may run on, as nproc counts them: what taskset or a container leaves it; read at once, with no wait
sys.cpu()Returns a map: percent busy, cores (a list, each core's percent), count, model
sys.memory()Returns a map of bytes: total, available, used, percent, swap_total, swap_used
sys.load()Returns the load averages as a map: one, five, fifteen
sys.disks()Returns a map: read and write in bytes a second over every disk, and mounts, a list of maps: path, device, type, total, free, used, percent
sys.net()Returns a map: rx and tx in bytes a second over the physical interfaces, and interfaces, a list of maps: name, rx_total, tx_total, physical
sys.temps()Returns the temperature sensors as a list of maps: chip, label, celsius
sys.gpus()Returns the graphics cards as a list of maps: name, vendor, driver, busy, memory_used, memory_total, and for an NVIDIA card celsius and watts, for others mhz
cpu = sys.cpu()mem = sys.memory()used = text.bytes($mem["used"])echo "cpu $cpu['percent']%, memory $used"disks = sys.disks()for d in $disks["mounts"]    if $d["percent"] > 90        echo "$d['path'] is nearly full"    end ifend for
  • Rates and percentages are a difference between two readings. Each call that gives one reads again and measures over the time since the reading before, at least a quarter of a second; the first call waits that long. A loop that calls sys.cpu() once a second gets each second's figure.
  • Network rates are the physical interfaces', those with a device of their own: a bridge, a veth pair, Docker's link or a WireGuard tunnel passes on bytes a physical one counts, and adding it would count them twice. Where none is physical, as inside a container, every interface but the loopback counts.
  • Disks are the local filesystems, one entry a disk: a bind mount or a subvolume of one already listed is left out, and so are network and memory filesystems. free is what a user can still write, without the reserve kept for root.
  • Cards: an NVIDIA card is read through its driver's library, loaded at the first sys.gpus() call and never before; other cards through the kernel's DRM files. A machine with no card gives an empty list.