Sysinfo Module
The sysinfo module exposes psutil-style system and process monitoring to Lua/Fennel.
Usage
fennel
(local sysinfo (require :sysinfo))Top-Level API
(sysinfo/platform)-> map::os,:arch,:lua,:features
(sysinfo/system)->Systemobject(sysinfo/sleep seconds)-> convenience sleep helper
System API
(sys:refresh)-> boolean(sys:cpu-usage)->{:percent :warmup :interval :per-core}(sys:cpu-times)-> cumulative counters map(sys:mem-virtual)->{:total :used :available :free :percent}(sys:process-current)->Process(sys:process pid)->Processornil(sys:process-list opts)-> sequence ofProcess
Process API
Process objects expose:
p.pid-> pid number(p:exists)-> boolean(p:name)-> string or nil(p:refresh)-> boolean(p:cpu)->{:percent :warmup :interval}(p:cpu-times)->{:user :system}(p:mem)->{:rss :vms :percent}
CPU Sampling Semantics
CPU usage is delta-based and stateful:
- First
(sys:cpu-usage)and first(p:cpu)return warmup:{:percent nil :warmup true ...}
refreshalso records a sample baseline; two refreshes across time are sufficient to warm subsequent CPU reads.- Subsequent calls after elapsed time compute percent from the delta between samples.
- No internal blocking/sleep is required; callers sample naturally in their own update loop.
Platform Behavior
The API surface is stable across Linux, Windows, and macOS. Fields unsupported on a given platform resolve to nil, and feature availability is advertised via (sysinfo/platform).features.
