nx_vsz_watchdog_core.nx
buildroot/runtime/nx_vsz_watchdog_core.nx
about
nx_vsz_watchdog_core.nx -- importable CORE of the VSZ watchdog (the permanent fix for outage MODE 2:
mmap-per-request daemons never munmap -> VSZ balloons (mgmt hit ~160GB) -> fork() fails -> child-exec
SILENTLY EMPTY while /api/health stays 200; see reference-mgmt-api-outage-tmp-log-rootcause-2026-07-12).
The watchdog DECIDES DEATH ONLY: it kills a conf-listed daemon whose VSZ crossed its threshold; RESPAWN
stays 100% the nx_hostctl guard's job (single responsibility, no dueling supervisors). FAIL-SAFE BY
CONSTRUCTION: no conf file -> INERT; unreadable /proc -> skip; cooldown suppresses kill-storms; pid<=300
and self are never killed. Pure decision funcs here (gate-locked); the /proc walk + kill live in the CLI.
license_tier: ORIGINAL
dependencies 1 imports · 10 importers
imports: nx_syscalls.nx
imported by: nx_fsops_lib.nxnx_heal_lib.nxnx_hget_leak_probe.nxnx_leak_check_lib.nxnx_resgov.nxnx_seg_cache_gate.nxnx_sweep_daemon_lib.nxnx_toolreg_reconcile_lib.nxnx_vsz_watchdog.nxnx_vsz_watchdog_gate.nx
structs
| none |
consts
| 11 | const VW_PROC_PATH_CAP: i64 = 256 // /proc/<pid>/status path buffer |
| 12 | const VW_STATUS_BUF: i64 = 8192 // /proc status read buffer |
| 13 | const VW_PTR_CELL: i64 = 16 // 2-i64 scratch cell (vw_num_at end-pointer out-param) |
functions
| 15 | func vw_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 18 | func vw_contains(hay: *u8, hn: i64, needle: *u8, nn: i64) -> i64 |
| 32 | func vw_num_at(s: *u8, n: i64, off: i64, endp: *i64) -> i64 |
| 48 | func vw_parse_row(buf: *u8, ls: i64, le: i64, outp: *i64) -> i64 |
| 74 | func vw_status_kb(buf: *u8, n: i64, pat: *u8) -> i64 |
| 97 | func vw_should_kill(vsz_kb: i64, max_gb: i64, last_kill_s: i64, now_s: i64, cooldown_s: i64) -> i64 |
| 106 | func vw_read(path: *u8, buf: *u8, cap: i64) -> i64 called by 20: fg_readback_eqmainfsx_conf_denyfsx_readfsx_read_linesfsx_edit+14 calls 3: sys_openat_rdsys_readsys_close |
| 117 | func vw_now_s() -> i64 { let ts: *i64 = sys_mmap(16) as *i64; sys_clock_gettime_mono(ts); return ts[0] } |
| 120 | func vw_selfpid() -> i64 |
| 131 | func vw_vmsize_parse(buf: *u8, n: i64) -> i64 { return vw_status_kb(buf, n, "VmSize:" as *u8) } |
| 135 | func vw_status_kb_of(dirname: *u8, label: *u8) -> i64 |
| 156 | func vw_vmsize_kb_of(dirname: *u8) -> i64 { return vw_status_kb_of(dirname, "VmSize:" as *u8) } |
| 158 | func vw_rss_kb_of(dirname: *u8) -> i64 { return vw_status_kb_of(dirname, "VmRSS:" as *u8) } |