Module: sys.hoststat
Source: ./sys/hoststat.reef
Overview
sys.hoststat — CPU %, RAM, load, uptime, kernel (C: /proc + uname)
Types
Sample
Fields:
| Name | Type |
|---|---|
cpu_pct |
int |
ncpu |
int |
mem_used |
int64 |
mem_total |
int64 |
load_x100 |
int |
uptime_sec |
int |
Objects
Sampler
proc init()
Methods:
exclusive fn take(): Sample
Functions
fn kernel_release(): string
fn os_sysname(): string
fn uptime_sec(): int
fn cpu_pct_at(i: int): option.Option[int]
0.9.2 C16: None for an out-of-range CPU index.
reef_hoststat_cpu_pct_at returns 0 for i < 0 or i >= ncpu (reef_hoststat.c:181), and 0 is also the reading for a genuinely idle core -- so "no such CPU" and "that CPU is idle" were the same answer. The bound is checked here rather than trusted from C, so the None is produced on the Reef side.
fn cpu_pct_at_or(i: int, default: int): int
*_or: lookup, or the caller default. Pairs with the Option getter above, which stays the source of truth. A PRESENT value always wins -- including the ones C16 made distinguishable from absent -- because substituting the default for a real value would reinstate the sentinel collision C16 removed.
Generated by reefc doc