hammerspoon2-docs
    Preparing search index...

    Namespace hostinfo

    Information about this Mac's hardware and how busy it is (CPU and memory usage, load average, swap and memory pressure), and whether it is in light or dark mode.

    Every reading is a single cheap system call, so to monitor something over time, read it from an hs.timer. The exception is CPU usage, which macOS only reports as running totals: a percentage needs two readings some time apart, so cpuUsage() and cpuCoreUsage() return Promises that resolve after the interval you choose.

    hs.timer.every(5, async () => {
    const cpu = await hs.hostinfo.cpuUsage(1)
    const mem = hs.hostinfo.memoryUsage()
    console.log(`CPU ${cpu.active.toFixed(0)}%, app memory ${(mem.appMemory / 2 ** 30).toFixed(1)} GiB`)
    })
    cpuCount
    ramAmount
    cpuCoreUsage
    cpuUsage
    interfaceStyle
    loadAverage
    memoryPressure
    memoryUsage
    off
    on
    once
    swapUsage