Commit 2fb3663
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.2731 parent 985304a commit 2fb3663
5 files changed
Lines changed: 264 additions & 89 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
509 | 509 | | |
510 | 510 | | |
511 | 511 | | |
| 512 | + | |
512 | 513 | | |
513 | 514 | | |
514 | 515 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
0 commit comments