code wiki / (root) / nx_site_monitor.nx

nx_site_monitor.nx

buildroot/runtime/nx_site_monitor.nx

8341 B148 linesdepth 6pulls 6 transitivereach 1 importersview sourcekind tooltopic site
docsdependenciesstructsconstsfunctions

about

nx_site_monitor.nx -- UPTIME + ALERTING (closes hosting_research gap #2 "uptime-alerting", 3/0 CONFIRMED: best-in-class hosts alert on downtime + track uptime%; Nishi probes but never RECORDS or alerts on a transition, so an outage is silent). Composes nx_health_probe: on each poll it classifies the up/down TRANSITION per daemon (sm_alert) -- went-DOWN, went-HUNG (distinct + actionably different: HUNG needs a kill, DOWN needs a start), or RECOVERED -- and tracks cumulative uptime. State persists in a TSV snapshot so transitions are detected across runs; alerts append to a durable log the status page can surface. module: nishi-core.observability.site_monitor capability: DAEMON_ROBUSTNESS / observability

dependencies 1 imports · 1 importers

nx_health_probe.nx nx_site_monitor.nx nx_site_monitor_gate.nx

imports: nx_health_probe.nx

imported by: nx_site_monitor_gate.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sm_p sm_read sys_read sm_one sm_find sm_streq_n sm_field_i hp_probe sys_socket sys_set_socket_timeout sys_mmap sys_setsockopt sys_munmap sys_mmap ↻ hp_sockaddr nx_connect_bounded nx_fcntl sys_connect sys_mmap ↻ sys_poll sys_write sys_read ↻ sys_munmap ↻ sys_close sm_alert sm_wri sm_p ↻ sm_n hp_name sm_uptime_permil sm_name sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real sm_append sm_read ↻ sys_openat_wr sys_openat_wr ↻

structs

none

consts

10const SM_MAGIC_262144: i64 = 262144
11const SM_MAGIC_262143: i64 = 262143
12const SM_MAGIC_8443: i64 = 8443
13const SM_MAGIC_7443: i64 = 7443
14const SM_MAGIC_8446: i64 = 8446
15const SM_MAGIC_8447: i64 = 8447
16const SM_MAGIC_8097: i64 = 8097
17const SM_MAGIC_18090: i64 = 18090
19const SM_NONE: i64 = 0
20const SM_WENT_DOWN: i64 = 1 // serving (or unknown-bad) -> refused/badresp
21const SM_WENT_HUNG: i64 = 2 // -> hung (up, not serving): the actionably-distinct failure
22const SM_RECOVERED: i64 = 3 // not-serving -> serving
23const SM_STATE: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/knowledge/status/uptime_state.tsv"
24const SM_LOG: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/knowledge/status/uptime_alerts.tsv"

functions

29func sm_alert(old_v: i64, new_v: i64) -> i64
called by 2: sm_onemain
38func sm_name(a: i64) -> *u8
called by 1: sm_one
44func sm_uptime_permil(up: i64, total: i64) -> i64 { if total <= 0 { return 0 } return (up * 1000) / total }
called by 2: sm_onemain
46func sm_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 2: sm_onemain
47func sm_n(v: i64) -> i64 { let t: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m; sys_write(1,"-" as *u8,1)} var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} let b: *u8=sys_mmap(28); var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 }
called by 1: sm_one
49func sm_wri(buf: *u8, off: i64, v: i64) -> i64
called by 2: sm_onemain
54func sm_read(path: *u8, buf: *u8, cap: i64) -> i64
called by 2: sm_appendmain calls 1: sys_read
60func sm_streq_n(buf: *u8, off: i64, end: i64, s: *u8) -> i64 { // does buf[off..tab] == s (NUL-terminated)?
called by 1: sm_find
66func sm_field_i(buf: *u8, off: i64, end: i64, f: i64) -> i64 { // integer value of the f-th tab field
called by 1: sm_find
74func sm_find(buf: *u8, len: i64, daemon: *u8, lv: *i64, up: *i64, tot: *i64) -> i64
called by 2: sm_onemain calls 2: sm_streq_nsm_field_i
93func sm_append(path: *u8, line: *u8, linelen: i64) -> i64
called by 1: sm_one calls 2: sm_readsys_openat_wr
102func sm_one(daemon: *u8, port: i64, prior: *u8, plen: i64, statebuf: *u8, statep: *i64) -> i64
136func main() -> i64