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

Parked opened this
Closed without merging

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

opened this

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.log isn'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 bad n gets 400, and a missing log gets 404. SO101_HEALTH_LOG points 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:temp and pi:undervolt samples 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) gains sampleAt and lastSampleAt.
  • The series (src/data-series.ts) gains piTempC (each step's hottest minute) and piUndervolt (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

Closes #520

commented

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.log isn'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 bad n gets 400, and a missing log gets 404. SO101_HEALTH_LOG points 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:temp and pi:undervolt samples 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) gains sampleAt and lastSampleAt.
  • The series (src/data-series.ts) gains piTempC (each step's hottest minute) and piUndervolt (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

commented

Parked by the crew: the preview's deploy failed and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs