Skip to content

Commit 2fb3663

Browse files
authored
omdb: one ereport pretty-printer to rule them all (#10486)
As seen in [today's Demo Friday][1], I have put together a little pretty-printer for formatting ereport JSON in a human-focused way. The format it outputs is a little less full of delimiters than the JSON object, as it's indentation delimited, and should look pretty familiar to anyone who's used `fmdump -eV` or similar. More importantly, though, giving us a custom formatter gives us opportunities to prettify and enrich specific fields and structures which commonly occur in ereports by convention. Currently, the most interesting example of this is PMBus status registers from ereports that SPs emit about PMBus devices. For example, let's consider an ereport that I harvested from the dogfood rack's PSC. In the current (JSON) format, it looks like this: ```console root@oxz_switch1:~# omdb db ereport show e9674d6e-cd4b-0cf3-ee6d-0c062720b868 0x5 note: database URL not specified. Will search DNS. note: (override with --db-url or OMDB_DB_URL) note: using DNS from system config (typically /etc/resolv.conf) note: (if this is not right, use --dns-server to specify an alternate DNS server) note: using database URL postgresql://root@[fd00:1122:3344:109::3]:32221,[fd00:1122:3344:105::3]:32221,[fd00:1122:3344:10b::3]:32221,[fd00:1122:3344:107::3]:32221,[fd00:1122:3344:108::3]:32221/omicron?sslmode=disable note: database schema version matches expected (257.0.0) == EREPORT METADATA ============================================================ ENA: 0x5 class: hw.pwr.pwr_good.bad collected at: 2025-11-14 20:38:20.177799 UTC collected by: 8af5baf2-7611-43fc-817c-283cb25e149f reported by: Power 0 (service processor) restart ID: e9674d6e-cd4b-0cf3-ee6d-0c062720b868 part number: 913-0000003 serial number: BRM45220004 marked seen in sitrep: None == EREPORT ===================================================================== { "baseboard_part_number": "913-0000003", "baseboard_rev": 8, "baseboard_serial_number": "BRM45220004", "ereport_message_version": 0, "fruid": { "fw_rev": "0701", "mfr": "Murata-PS", "mpn": "MWOCP68-3600-D-RM", "serial": "LL2216RB003Z" }, "hubris_archive_id": "qSm4IUtvQe0", "hubris_task_gen": 0, "hubris_task_name": "sequencer", "hubris_uptime_ms": 1197408566, "k": "hw.pwr.pwr_good.bad", "pmbus_status": { "cml": 0, "input": 48, "iout": 0, "mfr": 0, "temp": 0, "vout": 0, "word": 10312 }, "rail": "V54_PSU4", "refdes": "PSU4", "slot": 4, "v": 0 } root@oxz_switch1:~# ``` With the new formatter, it looks like this: ```console root@oxz_switch1:~# /tmp/omdb-erebor db ereport show e9674d6e-cd4b-0cf3-ee6d-0c062720b868 0x5 note: database URL not specified. Will search DNS. note: (override with --db-url or OMDB_DB_URL) note: using DNS from system config (typically /etc/resolv.conf) note: (if this is not right, use --dns-server to specify an alternate DNS server) note: using database URL postgresql://root@[fd00:1122:3344:109::3]:32221,[fd00:1122:3344:105::3]:32221,[fd00:1122:3344:10b::3]:32221,[fd00:1122:3344:107::3]:32221,[fd00:1122:3344:108::3]:32221/omicron?sslmode=disable WARN: found schema version 257.0.0, expected 261.0.0 It's possible the database is running a version that's different from what this tool understands. This may result in errors or incorrect output. == EREPORT METADATA ============================================================ ENA: 0x5 class: hw.pwr.pwr_good.bad collected at: 2025-11-14 20:38:20.177799 UTC collected by: 8af5baf2-7611-43fc-817c-283cb25e149f reported by: Power 0 (service processor) restart ID: e9674d6e-cd4b-0cf3-ee6d-0c062720b868 part number: 913-0000003 serial number: BRM45220004 marked seen in sitrep: None == EREPORT ===================================================================== baseboard_part_number = 913-0000003 baseboard_rev = 0x8 baseboard_serial_number = BRM45220004 ereport_message_version = 0x0 fruid = (object) fw_rev = 0701 mfr = Murata-PS mpn = MWOCP68-3600-D-RM serial = LL2216RB003Z (end fruid) hubris_archive_id = qSm4IUtvQe0 hubris_task_gen = 0x0 hubris_task_name = sequencer hubris_uptime_ms = 1197408566 (1197408.566s) class = hw.pwr.pwr_good.bad pmbus_status = (PMBus status) STATUS_WORD = 0x2848 (InputFault | PowerGoodStatus | Off | InputUndervoltageFault) STATUS_VOUT = 0x00 STATUS_IOUT = 0x00 STATUS_INPUT = 0x30 (InputUndervoltageWarning | InputUndervoltageFault) STATUS_TEMPERATURE = 0x00 STATUS_CML = 0x00 STATUS_MFR_SPECIFIC = 0x00 (end PMBus status) rail = V54_PSU4 refdes = PSU4 slot = 0x4 version = 0 root@oxz_switch1:~# ``` Note that Bryan's `pmbus` crate is used to decode the PMBus status registers, which should allow folks to get a sense for what happened here without having to manually interpret the status register bitflags. I've put this new formatter in a crate, named [`erebor`](github.com/oxidecomputer/erebor) --- this is either a portmanteau of "ereport" and "CBOR", or a reference to the Lonely Mountain of Middle-Earth, named "Erebor" in Sindarin; where Smaug destroyed the Dwarves' kingdom in an event that one assumes must have produced a great deal of ereports. This is intended to allow reusing it in `omdb`, in the `faux-mgs ereports` command, and perhaps elsewhere, eventually. This branch adds it to `omdb`. Since I am sure there are situations where one would want to get the output as JSON, I've also added new `--json` and `--raw` flags for doing that. [1]: https://drive.google.com/file/d/16Snam3jJBQ5vyGoeji0zYaeMKrR3q1me/view?usp=sharing&t=827.273
1 parent 985304a commit 2fb3663

5 files changed

Lines changed: 264 additions & 89 deletions

File tree

Cargo.lock

Lines changed: 113 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ dropshot-api-manager = "0.7.2"
509509
dropshot-api-manager-types = "0.7.2"
510510
dyn-clone = "1.0.20"
511511
either = "1.15.0"
512+
erebor = { git = "https://github.com/oxidecomputer/erebor", rev = "48512bf970474ff0fd0868c833fd504c8d169064" }
512513
ereport-types = { path = "ereport/types" }
513514
expectorate = "1.2.0"
514515
fatfs = "0.3.6"

dev-tools/omdb/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ daft.workspace = true
3030
diesel.workspace = true
3131
dropshot.workspace = true
3232
dyn-clone.workspace = true
33+
erebor = { workspace = true, features = ["pmbus"] }
3334
ereport-types.workspace = true
3435
futures.workspace = true
3536
gateway-client.workspace = true

0 commit comments

Comments
 (0)