[Bug] IPMI: "Unknown LastPowerEvent code 0x10" — Last Power Event bitfield is parsed as an enum, which fails the whole monitor
Is there an existing issue for this?
- [x] I have searched the existing issues
Current Behavior
Creating an IPMI monitor always fails at "Test connection" with: java.lang.IllegalArgumentException: Unknown LastPowerEvent code 0x10
The exception is thrown while decoding the Get Chassis Status response, so the monitor can never be created — even though the IPMI session itself (RMCP+/authentication) succeeds.
Impact is wider than one field: the Chassis metric group in define/app-ipmi.yml is declared with priority: 0 (availability metric), so when this group throws, the whole collection is marked failed and the Sensor group is never collected either. Users cannot monitor temperature/voltage/fans on such a machine at all.
The value 0x10 is not random: it is bit 4 of the Last Power Event byte, defined by IPMI v2.0 spec §28.2 as "Power control fault". Any BMC that has a non-zero last-power-event bit (0x01, 0x02, 0x04, 0x08, 0x10, or combinations) triggers this.
Expected Behavior
The IPMI monitor should be created and collect metrics normally, regardless of which last-power-event bits the BMC reports.
Last Power Event is a bitfield (IPMI v2.0 §28.2, response data byte 2):
| bit | meaning |
|---|---|
| 0 | AC failed |
| 1 | Power overload |
| 2 | Power interlock active |
| 3 | Power fault |
| 4 | Power control fault |
| 5-7 | reserved |
It should be decoded bit by bit (or as a set of booleans, consistent with how the other two bytes of the same response are handled) and must never throw on reserved/unknown bits.
Secondary expectation: an unrecognised code in one enum should not abort the entire collection. Today IpmiCode.fromByte() throws IllegalArgumentException, which takes down the availability metric group and therefore the whole monitor.
Steps To Reproduce
- Deploy HertzBeat 1.9.1 (
apache-hertzbeat-1.9.1-bin.tar.gz). - Add a monitor of type IPMI: host = BMC address, port = 623, username/password of an IPMI user, any privilege level.
- Click Test connection.
Result: 测试连接失败 java.lang.IllegalArgumentException: Unknown LastPowerEvent code 0x10
(English UI: Test connection failed: ...)
Reproduced on a Huawei server iBMC whose Get Chassis Status response returns 0x10 in the Last Power Event byte.
The failure is deterministic and does not depend on credentials: it happens after a successful IPMI 2.0 session has already been established.
Minimal reproduction without hardware (unit test level): feed GetChassisStatusResponse.fromResponseData() a buffer whose byte 2 is 0x10, e.g. {0x01, 0x10, 0x00, 0x00}. It throws immediately.
Environment
- HertzBeat version: 1.9.1 (binary release `apache-hertzbeat-1.9.1-bin.tar.gz`
- Affected module: `hertzbeat-collector-basic` (class `org.apache.hertzbeat.collector.collect.ipmi2.protocol.ipmi.command.chassis.GetChassisStatusResponse`)
- OS: Ubuntu 22.04 x86_64 (also reproducible on any OS — pure Java parsing issue)
- Runtime: bundled JDK 25
- Storage: GreptimeDB (metrics) / H2 (metadata)
- Device: Huawei server iBMC, IPMI 2.0 over UDP/623, auth + integrity (MD5/SHA1), no encryption
- UI language: zh-CN (error text also shown in English as `Unknown LastPowerEvent code 0x10`)
Debug logs
No response
Anything else?
Anything else?
### Root cause
`GetChassisStatusResponse.fromResponseData()` (master, same in 1.9.1) decodes the *Last Power Event* byte as an enum **index**:
```java
enum LastPowerEvent implements IpmiCode.Code {
none(0, "None"),
unknown(1, "Unknown"),
lastPowerOff(2, "Last Power Off"),
lastPowerOn(3, "Last Power On");
}
...
t = buffer.get();
lastPowerEvent = IpmiCode.fromByte(LastPowerEvent.class, getBits(t, 0, 0x1F)).getDescription();
I have implemented a fix for this issue and opened a PR.
The Last Power Event field is now decoded as a bitfield according to IPMI v2.0 Section 28.2 instead of being treated as an enum.
The implementation:
- Decodes all five event flags independently.
- Handles valid values such as
0x10without throwing an exception. - Ignores reserved bits (5–7).
- Preserves the existing
lastPowerEventfield with readable event descriptions.
I've also added six regression tests covering individual flags, combined flags, reserved bits, and the reported reproduction case.
All six targeted tests pass, and collector module compilation succeeds.
PR: https://github.com/apache/hertzbeat/pull/4558
Thanks for reporting this issue!