Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
Data view: Pi temperature and under-voltage over time #525
The Health section of the Data view (`/admin/data`) now charts the Pi's temperature and under-voltage over time.
stopped parked by the crew deploy f1cfa05
The Health section of the Data view (/admin/data) now charts the Pi's temperature and under-voltage over time.
This pull is built on #519. facts.ts and /admin/data exist only in #519, so this branch starts from #519's head. That's why the last run was declined. Merge #519 first; until then this diff also shows #519's two commits. My change is the last commit.
- The parser (
src/pi-health.ts). The script that writes/var/log/so101-health.logisn't in the repository, so the parser accepts several forms:
- The time: ISO 8601 (a time without a zone is the Pi's local time), Unix seconds, or syslog's Mon DD HH:MM:SS.
- The temperature: temp= / temp_c= / temperature=, in −40…125 °C.
- Under-voltage: undervolt= / under_voltage=, or else bit 0 of vcgencmd's throttled=, which means "short of power now". Bit 16 only means it happened since boot, so it is kept but not counted as a flag for that minute.
- Lines it can't read are skipped and counted.
- The arm server:
GET /health/pi?n=1-1440. It reads only the last 256 KiB of the log and returns the lines oldest first. A badngets 400, and a missing log gets 404.SO101_HEALTH_LOGpoints it at another file. - The relay. While the real arm is live, it asks each minute for as many lines as minutes have passed since the last one it kept. The fields are checked again on arrival, and each line is stored as the
pi:tempandpi:undervoltsamples at the time the Pi logged it. A relay that was down fills the gap (up to a day), no line is kept twice, and a line more than 5 minutes ahead (a wrong Pi clock) is dropped. The simulation has no Pi, so nothing is sampled there. - The facts store (
src/facts.ts) gainssampleAtandlastSampleAt. - The series (
src/data-series.ts) gainspiTempC(each step's hottest minute) andpiUndervolt(minutes short of power). - The Data view has a new panel, "Health · the Pi", with two charts. It works with "Compare to the period before" and says plainly when the Pi logged nothing.
Tests: src/pi-health.test.ts covers each log format, zone offsets, the throttled bits, bad lines, reading the end of the file, the relay's check of the answer, sampling without duplicates, and the route end to end with the relay keeping each new line. data-series.test.ts gains the Pi's series. These pass, as do the facts, data-api, layout, README, server, relay, lobby, admin and node-loads suites; I didn't run the whole check. bun x tsc --noEmit reports nothing for the changed files. The app boots and / answers in 32 ms. The repository has no scripts/design-lint.ts, so that step didn't run.
Not done: there's no number for the Pi in the overview strip, and the other throttled bits (throttled now, frequency capped) aren't charted.
To try it: on a Pi, run curl http://<pi>:8101/health/pi?n=5. Then, with ARM_SERVER set, open /admin/data as the owner and look at "Health · the Pi".
🤖 Generated with Claude Code
Closes #520
Parked by the crew: the preview's deploy failed and the decider saw no point in another try
The Health section of the Data view (
/admin/data) now charts the Pi's temperature and under-voltage over time.This pull is built on #519.
facts.tsand/admin/dataexist only in #519, so this branch starts from #519's head. That's why the last run was declined. Merge #519 first; until then this diff also shows #519's two commits. My change is the last commit.src/pi-health.ts). The script that writes/var/log/so101-health.logisn't in the repository, so the parser accepts several forms:- The time: ISO 8601 (a time without a zone is the Pi's local time), Unix seconds, or syslog's
Mon DD HH:MM:SS. - The temperature:temp=/temp_c=/temperature=, in −40…125 °C. - Under-voltage:undervolt=/under_voltage=, or else bit 0 of vcgencmd'sthrottled=, which means "short of power now". Bit 16 only means it happened since boot, so it is kept but not counted as a flag for that minute. - Lines it can't read are skipped and counted.GET /health/pi?n=1-1440. It reads only the last 256 KiB of the log and returns the lines oldest first. A badngets 400, and a missing log gets 404.SO101_HEALTH_LOGpoints it at another file.pi:tempandpi:undervoltsamples at the time the Pi logged it. A relay that was down fills the gap (up to a day), no line is kept twice, and a line more than 5 minutes ahead (a wrong Pi clock) is dropped. The simulation has no Pi, so nothing is sampled there.src/facts.ts) gainssampleAtandlastSampleAt.src/data-series.ts) gainspiTempC(each step's hottest minute) andpiUndervolt(minutes short of power).Tests:
src/pi-health.test.tscovers each log format, zone offsets, the throttled bits, bad lines, reading the end of the file, the relay's check of the answer, sampling without duplicates, and the route end to end with the relay keeping each new line.data-series.test.tsgains the Pi's series. These pass, as do the facts, data-api, layout, README, server, relay, lobby, admin and node-loads suites; I didn't run the whole check.bun x tsc --noEmitreports nothing for the changed files. The app boots and/answers in 32 ms. The repository has noscripts/design-lint.ts, so that step didn't run.Not done: there's no number for the Pi in the overview strip, and the other
throttledbits (throttled now, frequency capped) aren't charted.To try it: on a Pi, run
curl http://<pi>:8101/health/pi?n=5. Then, withARM_SERVERset, open/admin/dataas the owner and look at "Health · the Pi".🤖 Generated with Claude Code
Closes #520
Closes #520