code wiki / _hdl_build / nx_adnet_opsbeat.nx
nx_adnet_opsbeat.nx source
↩ module page · 62 lines · 3021 B
1// nx_adnet_opsbeat.nx -- RUNNER for the operator view. Makes nx_adnet_ops REACHABLE.
2// A gated organ with no way to invoke it is, by this ecosystem's own law, still the baseline. The
3// registered-organ path is already proven (POST /api/tools/register then POST /api/organ_run), so this
4// is deliberately a plain organ rather than a new mgmt route: routes are instantly callable but every
5// new one widens the control plane, and this needs no authority beyond reading four files.
6//
7// no argv -> read the live confs and print the report (exit 0 always; a findings list is not a failure)
8// fixtures -> nx_adnet_opsbeat fixtures <inv> <rates> <camps> <apps> (testable; reads only)
9//
10// EXIT CODE IS DELIBERATELY 0 EVEN WITH FINDINGS. This is a report, not a gate. If it exited non-zero on
11// "there is work to do" it would go red permanently the first day someone is busy, and a permanently red
12// signal is a signal nobody reads.
13// expect_exit: 0 license_tier: ORIGINAL
14import "nx_syscalls.nx"
15import "_hdl_build/nx_adnet_ops.nx"
16
17const AOB_INV: *u8 = "/volume1/homes/elderwesto/nishihost/sites/nishifamily/synth/adnet_inventory.txt" as *u8
18const AOB_RATES: *u8 = "/volume1/homes/elderwesto/nishihost/knowledge/status/adnet_rates.conf" as *u8
19const AOB_CAMPS: *u8 = "/volume1/homes/elderwesto/nishihost/knowledge/status/adnet_campaigns.conf" as *u8
20const AOB_APPS: *u8 = "/volume1/homes/elderwesto/nishihost/knowledge/status/adnet_applications.log" as *u8
21const AOB_CAP: i64 = 262144
22
23func aob_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
24
25func aob_run(pi: *u8, pr: *u8, pc: *u8, pa: *u8) -> i64 {
26 let b1: *i64 = sys_mmap(16) as *i64
27 var inv: *u8 = sys_read_file(pi, b1)
28 var il: i64 = b1[0]
29 if (inv as i64) == 0 { inv = "" as *u8; il = 0 }
30 let b2: *i64 = sys_mmap(16) as *i64
31 var rates: *u8 = sys_read_file(pr, b2)
32 var rl: i64 = b2[0]
33 if (rates as i64) == 0 { rates = "" as *u8; rl = 0 }
34 let b3: *i64 = sys_mmap(16) as *i64
35 var camps: *u8 = sys_read_file(pc, b3)
36 var cl: i64 = b3[0]
37 if (camps as i64) == 0 { camps = "" as *u8; cl = 0 }
38 let b4: *i64 = sys_mmap(16) as *i64
39 var apps: *u8 = sys_read_file(pa, b4)
40 var al: i64 = b4[0]
41 if (apps as i64) == 0 { apps = "" as *u8; al = 0 }
42
43 let out: *u8 = sys_mmap(AOB_CAP)
44 let n: i64 = aop_report(inv, il, rates, rl, camps, cl, apps, al, out, AOB_CAP)
45 if n == 0 {
46 aob_puts("ADNET-OPS: nothing needs a human right now\n" as *u8)
47 return 0
48 }
49 sys_write(1, out, n)
50 return 0
51}
52
53func main(argc: i64, argv: *i64) -> i64 {
54 if argc > 5 {
55 let v: *u8 = argv[1] as *u8
56 var isfx: i64 = 1
57 let d: *u8 = "fixtures" as *u8
58 var i: i64 = 0
59 while i < 8 { if v[i] != d[i] { isfx = 0; break } i = i + 1 }
60 if isfx == 1 { return aob_run(argv[2] as *u8, argv[3] as *u8, argv[4] as *u8, argv[5] as *u8) }
61 }
62 return aob_run(AOB_INV, AOB_RATES, AOB_CAMPS, AOB_APPS)
63}