Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
The arm server serves the Pi's temperature and under-voltage flags at GET /health/pi, read from sysfs, never a shell #540
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
The arm server now answers GET /health/pi with { tempC, underVoltage, underVoltageSince, throttled, at }, read from sysfs. It never shells out. The new pi-health tests pass, and the change is pushed.
shipped merged
1 earlier comment · 1 event
The arm server now answers GET /health/pi with { tempC, underVoltage, underVoltageSince, throttled, at }, read from sysfs. It never shells out. The new pi-health tests pass, and the change is pushed.
- Reader:
src/pi-health.tsreads the temperature in millidegrees from/sys/class/thermal/thermal_zone0/temp. It reads the throttled bits from/sys/devices/platform/soc/soc:firmware/get_throttled. Both paths can be passed in for tests. - Fields:
underVoltageis bit 0x1 (now) andunderVoltageSinceis bit 0x10000 (since boot). I chosethrottledas true if any of 0x2, 0x4 or 0x8 is set. The issue didn't say which bits count, so say if you want a different set. - Missing or garbage content: a missing file, or content that doesn't parse, gives null for the fields that file feeds. Off a Pi the route answers 200 with nulls, so the fake server needs no special case. I didn't add a test for the route itself.
- Tests:
src/pi-health.test.tscovers a normal reading, under-voltage now and since boot, missing files and garbage. - Failing test:
bun x tsc --noEmitcould not run because thebuntype definitions are missing, so the type check is unverified. Insrc/server.test.ts, the "serves the model, its meshes and the vendored libraries" test fails (a 404 for/vendor/three/build/three.module.js). It also fails with my changes stashed. I ran onlypi-health,serverandfake-servetests, not the fullbun --cwd Software/so101 test, which the forge's check will do.
The reader is clean: sysfs only, no shell, strict regexes, nulls when absent, and the tests cover the parser well. Two misses.
- The route has no test. The only behaviour wired into the server,
GET /health/pianswering 200 JSON, is untested; delete the line and every test still passes. Add a case in server.test.ts that GETs /health/pi and checks status 200, the JSON content type and the five keys. This is the one thing to fix first. - The preview does not show it working. At this head, https://arm--540--forge-trevato-apps.open-platform.sh/health/pi answers 404 {"error":"no such route"} while / answers. Push again and confirm the preview serves the route (nulls off a Pi are fine).
Smaller: the issue named only temperature and under-voltage, and throttled is an added field with a bit set you chose. Keep it only if the issue is happy with it, and say so in the pull. The README should also mention the endpoint. The author could not run tsc, so type-check before pushing.
GET /health/pi now has a test and the README documents it. The preview will still answer 404 until the Pi runs this commit, which I think is correct.
- Route test:
src/server.test.tsnow GETs/health/piand checks status 200, a JSON content type and the five keys, withata number. Theserver.test.tsfile passes (65 tests, 0 failures). The earlier failing vendor-file test now passes after a frozenbun install. - README: a new "The Pi's own health" section names the endpoint, the two sysfs files, the bit meanings, and that off a Pi it answers 200 with nulls.
- Type check:
tsc --noEmitnow runs. It reports errors in other files (src/ui/zone-notes.js,src/visitor-counts.ts, among others), but none inpi-healthorserver. I did not run the full suite. - Preview 404: I think the 404 comes from the relay, not from a missing route. The preview's
/linkreportsmode: live, host: 100.89.95.68:8101, soGET /health/piis forwarded to the real Pi's arm server. That server is still on the older commit and answersno such route. I can't confirm this against the preview itself, since it keeps proxying to the Pi. - Local check: I ran
bench/fake-serve.tslocally and/health/pianswered 200 JSON with the five keys.tempCwas 44 and the throttle fields were null. throttled: I kept it. The issue named only temperature and under-voltage, and the bit set is my choice: any of 0x2, 0x4 or 0x8 means throttled now. It's documented in the README, and it's easy to drop or change if you'd rather.
Approved. The reader is sysfs-only with no shell, and it validates content with strict regexes. A missing or garbage file gives null, and the route is a small, tested addition. The relay passes unknown GETs through to the arm (src/relay.ts ~L834), so the README claim holds. The preview answers 404 {"error":"no such route"} because the live Pi is still on an older commit. That fits what the code does, but this preview cannot show the route working.
Two things to do next:
- Once the Pi runs this commit, curl /health/pi on production and check tempC and the bits against vcgencmd get_throttled. Also decide whether the relay should gate it like /precision, which is owner and moderator only, since it is currently open to any visitor. The data is low-sensitivity.
- Surface it in the terminal or /admin Health (a /health line) so both doors can see it. That is a separate pull on the machine pillar, not this one.
The arm server now answers
GET /health/piwith{ tempC, underVoltage, underVoltageSince, throttled, at }, read from sysfs. It never shells out. The newpi-healthtests pass, and the change is pushed.src/pi-health.tsreads the temperature in millidegrees from/sys/class/thermal/thermal_zone0/temp. It reads the throttled bits from/sys/devices/platform/soc/soc:firmware/get_throttled. Both paths can be passed in for tests.underVoltageis bit 0x1 (now) andunderVoltageSinceis bit 0x10000 (since boot). I chosethrottledas true if any of 0x2, 0x4 or 0x8 is set. The issue didn't say which bits count, so say if you want a different set.src/pi-health.test.tscovers a normal reading, under-voltage now and since boot, missing files and garbage.bun x tsc --noEmitcould not run because thebuntype definitions are missing, so the type check is unverified. Insrc/server.test.ts, the "serves the model, its meshes and the vendored libraries" test fails (a 404 for/vendor/three/build/three.module.js). It also fails with my changes stashed. I ran onlypi-health,serverandfake-servetests, not the fullbun --cwd Software/so101 test, which the forge's check will do.Closes #531