nx_site_monitor.nx
buildroot/runtime/nx_site_monitor.nx
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
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
structs
| none |
consts
| 10 | const SM_MAGIC_262144: i64 = 262144 |
| 11 | const SM_MAGIC_262143: i64 = 262143 |
| 12 | const SM_MAGIC_8443: i64 = 8443 |
| 13 | const SM_MAGIC_7443: i64 = 7443 |
| 14 | const SM_MAGIC_8446: i64 = 8446 |
| 15 | const SM_MAGIC_8447: i64 = 8447 |
| 16 | const SM_MAGIC_8097: i64 = 8097 |
| 17 | const SM_MAGIC_18090: i64 = 18090 |
| 19 | const SM_NONE: i64 = 0 |
| 20 | const SM_WENT_DOWN: i64 = 1 // serving (or unknown-bad) -> refused/badresp |
| 21 | const SM_WENT_HUNG: i64 = 2 // -> hung (up, not serving): the actionably-distinct failure |
| 22 | const SM_RECOVERED: i64 = 3 // not-serving -> serving |
| 23 | const SM_STATE: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/knowledge/status/uptime_state.tsv" |
| 24 | const SM_LOG: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/knowledge/status/uptime_alerts.tsv" |
functions
| 29 | func sm_alert(old_v: i64, new_v: i64) -> i64 |
| 38 | func sm_name(a: i64) -> *u8 called by 1: sm_one |
| 44 | func sm_uptime_permil(up: i64, total: i64) -> i64 { if total <= 0 { return 0 } return (up * 1000) / total } |
| 46 | func 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 } |
| 47 | func 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 |
| 49 | func sm_wri(buf: *u8, off: i64, v: i64) -> i64 |
| 54 | func sm_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 60 | func sm_streq_n(buf: *u8, off: i64, end: i64, s: *u8) -> i64 { // does buf[off..tab] == s (NUL-terminated)? called by 1: sm_find |
| 66 | func 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 |
| 74 | func sm_find(buf: *u8, len: i64, daemon: *u8, lv: *i64, up: *i64, tot: *i64) -> i64 |
| 93 | func sm_append(path: *u8, line: *u8, linelen: i64) -> i64 |
| 102 | func sm_one(daemon: *u8, port: i64, prior: *u8, plen: i64, statebuf: *u8, statep: *i64) -> i64 |
| 136 | func main() -> i64 |