hm-cx is a small Rust web server that exposes live host telemetry in the same tree shape used by OpenHardwareMonitor / LibreHardwareMonitor.
It can:
- serve an OHM-compatible
/data.json - sample live sensor values from the local machine using
config.yml - compare live output against
ohm.json - show a live dashboard and mapping console in the browser
- let you override mappings at runtime via
overload.json
The repository also includes a bundled reference export at:
assets/openhardwaremonitor_localhost_8085_data.json
This project is vibecoded with GPT-5.4/Codex free tier, I wanted to test rust language as it's aweful for developer due to syntaxic check and stuff but really good for AI auto-check due to the enforcing of rules.
Useless dashboard from webserver

In Home Assistant via Open Hardware Monitor integration

| Method | Route | Purpose |
|---|---|---|
| GET | / |
Simple route index page listing all available endpoints |
| GET | /live |
Live HTML dashboard for sensors, health, and schema status |
| GET | /data.json |
OHM-compatible rendered sensor tree |
| GET | /rawData.json |
Flat raw sensor map keyed by SensorId |
| GET | /snapshot.json |
Current raw in-memory sampler snapshot |
| GET | /ohm.json |
Filesystem OHM reference JSON if present |
| GET | /mapping |
Live mapping console with override editor |
| GET | /mapping.json |
Machine-readable mapping feed |
| GET | /compare |
Compare raw live data with raw ohm.json sensor entries |
| GET | /compare/schema |
Compare only shape/metadata/units between ohm.json and /data.json |
| GET | /compare/view |
HTML side-by-side path comparison view |
| GET | /health |
Health endpoint with mapping warnings |
| POST | /generate-config |
Generate config.yml automatically |
| POST | /mapping/overrides |
Save or update one mapping override in overload.json |
| POST | /mapping/overrides/delete |
Remove one mapping override |
hm-cx
├── assets/
│ └── openhardwaremonitor_localhost_8085_data.json
├── src/
│ ├── config.rs
│ ├── handlers/mod.rs
│ ├── lib.rs
│ ├── main.rs
│ ├── mapping.rs
│ ├── routes.rs
│ ├── server.rs
│ └── utils/mod.rs
├── tests/
├── Cargo.toml
└── README.md
Important files:
src/main.rs— process entry pointsrc/server.rs— Actix server bootstrapsrc/routes.rs— route registrationsrc/handlers/mod.rs— HTTP handlers and HTML viewssrc/mapping.rs— mapping resolution, live sampling, override application
cargo buildcargo runPORT=8085 cargo runThen open:
http://127.0.0.1:8080/by default- or the port you selected
The server can generate a first-pass config.yml automatically:
cargo run -- generate-configcurl -X POST http://127.0.0.1:8080/generate-configThis writes config.yml in the working directory.
On Linux systems with systemd, the executable can install itself as a user service that starts automatically when you log in.
Recommended flow:
cargo build --release
./target/release/hm_cx installWhat install does:
- writes
~/.config/systemd/user/hm-cx.service - points
ExecStartat the current executable path - stores the current working directory as
WorkingDirectory - sets
PORT=8085in the unit so Home Assistant can use the usual OpenHardwareMonitor port by default - runs
systemctl --user daemon-reload - runs
systemctl --user enable --now hm-cx.service - runs
systemctl --user restart hm-cx.serviceso reinstalling picks up unit changes such as port updates
Important:
- run
installfrom the directory that contains theconfig.yml,ohm.json, andoverload.jsonfiles you want the service to use - the installed service listens on port
8085by default to match OpenHardwareMonitor expectations - if you want a different port, override
PORTin the user unit after installation - if you install from
cargo run -- install, the service will point at Cargo's debug build output instead of a stable release binary
./target/release/hm_cx uninstallWhat uninstall does:
- runs
systemctl --user disable --now hm-cx.service - removes
~/.config/systemd/user/hm-cx.service - runs
systemctl --user daemon-reload
You can inspect the installed unit with:
systemctl --user status hm-cx.service
systemctl --user cat hm-cx.serviceSome power sensors, especially CPU package power exposed via powercap_rapl, are read from files such as:
/sys/class/powercap/.../energy_uj
On many Linux systems those files are not readable by an unprivileged process. In that case hm-cx needs these capabilities on the server binary:
cap_dac_read_searchcap_perfmon
For example, if Package is mapped to powercap_rapl (such as /amdcpu/0/power/0 in an OHM-compatible tree), apply the capabilities to the exact binary you run:
cargo build --release
./scripts/set-hm-cx-capability.sh target/release/hm_cx
getcap ./target/release/hm_cxExpected getcap output is similar to:
./target/release/hm_cx cap_dac_read_search,cap_perfmon=ep
Notes:
- capabilities are attached to the binary file, not to
config.ymlor the systemd unit - rebuilding or replacing the binary usually clears them, so re-run the script after upgrades or fresh builds
- if you use
install, apply capabilities to the same path used byExecStartand then restart the service
If config.yml exists when the server starts, hm-cx launches a background sampler.
In live mode:
/data.jsonbecomes authoritative- the sampler updates the in-memory snapshot continuously
- the HTML views (
/live,/mapping) refresh against live endpoints
If no config.yml exists:
/data.jsonfalls back to the bundled reference asset/rawData.jsonfalls back to raw data extracted from the bundled asset
200 OKwhen at least one sensor value was produced500 Internal Server Errorwhen the snapshot is empty ornull
Example error payload:
{
"error": "no sensor data available",
"reason": "mappings produced no values",
"snapshot_size": 0,
"timestamp_unix": 1670000000,
"suggestion": "inspect /snapshot.json and verify config.yml mappings"
}config.yml contains the default mapping from an OHM sensor id to a local data source.
Example:
mappings:
- ohm: /test/temperature/0
text: Test Temp
type: Temperature
source:
kind: sysfs
path: /sys/class/hwmon/hwmon0/temp1_input
chip: null
key: nullSupported source kinds used by the mapper:
sysfssensors_jsonpowercap_raplproc_cpuinfoudisks2_nvme
NVMe temperatures are matched to hwmon devices by the drive model and sensor channel. SMART health and lifetime totals (Available Spare, Percentage Used, Data Read, and Data Written) are read through UDisks2's org.freedesktop.UDisks2.NVMe.Controller D-Bus interface. This avoids privileged direct access to /dev/nvme* and prevents SMART levels from being incorrectly mapped to PWM controls.
overload.json is the manual override layer applied on top of config.yml.
Example:
{
"overrides": [
{
"ohm": "/test/temperature/0",
"source": {
"kind": "sysfs",
"path": "/sys/class/hwmon/hwmon9/temp9_input",
"chip": null,
"key": null
}
}
]
}Behavior:
- overrides are reloaded continuously during sampling
- overrides take precedence over generated/default mappings
- overridden sensor nodes in
/data.jsonget an extra field:
{
"Value": "42.00 °C",
"RawValue": "42000",
"Text": "CPU",
"Type": "Temperature",
"overload": true
}The extra overload field is intentionally ignored by /compare/schema so schema compatibility checks still focus on OHM shape and metadata.
Open:
/mapping
The mapping console shows:
- OHM sensor id
- current tree path inside rendered
/data.json - live value and raw value
- default source from
config.yml - effective source after override application
- whether the mapping is overloaded
It polls /mapping.json every 5 seconds.
From the browser you can:
- save an override to
overload.json - remove an existing override
Returns a live summary like:
{
"configured": true,
"live_snapshot": true,
"override_file": "overload.json",
"override_count": 1,
"mappings": [
{
"ohm": "/test/temperature/0",
"text": "CPU",
"type": "Temperature",
"tree_path": "Children/[0]",
"label_path": "Sensor / CPU",
"live_value": "42.00 °C",
"live_raw_value": "42000",
"default_source": { "kind": "sysfs", "path": "/sys/class/hwmon/hwmon0/temp1_input", "chip": null, "key": null },
"effective_source": { "kind": "sysfs", "path": "/sys/class/hwmon/hwmon9/temp9_input", "chip": null, "key": null },
"override_source": { "kind": "sysfs", "path": "/sys/class/hwmon/hwmon9/temp9_input", "chip": null, "key": null },
"overloaded": true
}
]
}curl -X POST http://127.0.0.1:8080/mapping/overrides \
-H 'Content-Type: application/json' \
-d '{
"ohm": "/test/temperature/0",
"source": {
"kind": "sysfs",
"path": "/sys/class/hwmon/hwmon9/temp9_input",
"chip": null,
"key": null
}
}'curl -X POST http://127.0.0.1:8080/mapping/overrides/delete \
-H 'Content-Type: application/json' \
-d '{"ohm":"/test/temperature/0"}'Compares:
- raw entries extracted from filesystem
ohm.json - current live raw data
Useful for seeing key-level differences between reference and live raw sensor maps.
Checks compatibility of live /data.json against ohm.json.
It validates:
- path presence
- metadata fields like
SensorId,Text,Type - displayed unit compatibility for fields such as
Value,Min,Max
It intentionally ignores:
- live numeric drift
- OHM
-values that mean “unavailable at capture time” - the extra
overloadmarker added by manual overrides
HTML view for side-by-side hierarchical key comparison between:
ohm.json- current
/data.json
Returns:
okwhen live snapshot exists and no warnings are detecteddegradedwhen mappings exist but some backing sources are missing/inaccessibleunhealthywhen no live data is available in live mode
It also reports warnings for common issues such as:
- missing sysfs paths
- unreadable
powercap_raplfiles
Returns the raw in-memory snapshot exactly as held by the sampler.
Returns a flat map keyed by SensorId.
This is useful when debugging mapping values independently of the OHM tree.
Returns the local ohm.json file if present.
Typical symptoms:
/healthreports a warning aboutpowercap_rapl- a
Packagepower sensor never gets a live value - logs mention permission denied when reading
/sys/class/powercap/.../energy_uj
Useful checks:
# See how power sensors are mapped
rg -n "powercap_rapl|/power/" config.yml overload.json
# Check the health endpoint for permission warnings
curl -s http://127.0.0.1:8080/health | jq .
# Inspect live power mappings and values
curl -s http://127.0.0.1:8080/mapping.json | jq '.mappings[] | select(.type == "Power") | {ohm, text, effective_source, live_value, live_raw_value}'
# See which RAPL files exist on this host
find /sys/class/powercap -maxdepth 3 \( -name energy_uj -o -name name \) -print
# Check whether the hm-cx binary already has the required capabilities
getcap ./target/release/hm_cx
# Apply them if needed
./scripts/set-hm-cx-capability.sh target/release/hm_cxIf you run hm-cx as a user service, also verify and restart it after changing capabilities:
systemctl --user status hm-cx.service
systemctl --user cat hm-cx.service
systemctl --user restart hm-cx.serviceIf the binary was rebuilt after capabilities were applied, re-run setcap or scripts/set-hm-cx-capability.sh on the new binary.
The server uses tracing.
Examples:
cargo run
RUST_LOG=debug cargo run
PORT=8085 RUST_LOG=info cargo runExample warning you may see:
mapping produced no value
This usually means a configured mapping did not produce a live reading during sampling.
Run locally before submitting changes:
cargo fmt --all
cargo build
cargo test
cargo clippy --all-targets --all-features -- -D warningsUseful targeted test examples:
cargo test data_json_route_returns_the_bundled_asset -- --exact
cargo test data_json -- --nocaptureOn Linux, the linux_usage source supplies total CPU load from successive
/proc/stat samples, RAM use from MemTotal - MemAvailable, and AMD GPU load
and VRAM occupancy from DRM sysfs. GPU discovery requires exactly one AMD card
with gpu_busy_percent; card numbers may change across boots. Memory amounts
use decimal GB/MB to match the OHM units. /vram in the reference tree means
virtual memory, so GPU VRAM uses /gpu-amd/0 instead. Existing configuration
files need the corresponding mappings added; regeneration is not required.
- Generate or create
config.yml - Start the server
- Open
/mappingto inspect effective mappings - Add overrides where needed
- Verify
/data.json - Check
/compare/schemafor compatibility - Use
/livefor a compact live dashboard
MIT