-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhardware_monitor_cpp_dump.cpp
More file actions
33 lines (28 loc) · 1.18 KB
/
Copy pathhardware_monitor_cpp_dump.cpp
File metadata and controls
33 lines (28 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
// Copyright (c) 2026 idimus. Free for non-commercial use; commercial use requires a license.
//
// Minimal demo: enumerate devices and print one snapshot of readings.
#include <chrono>
#include <cstdio>
#include <thread>
#include "hardware_monitor_cpp/hardware_monitor_cpp.hpp"
int main() {
using namespace hardware_monitor_cpp;
Monitor monitor;
monitor.addPlatformSources();
monitor.open();
// Prime delta-based metrics (load, power, frequency), then sample over a 1s interval.
monitor.poll();
std::this_thread::sleep_for(std::chrono::seconds(1));
Snapshot snap = monitor.poll();
std::printf("hardware_monitor_cpp - %zu device(s)\n\n", snap.devices().size());
for (const DeviceInfo& d : snap.devices()) {
std::printf("== %s [%s] ==\n", d.name.c_str(), toString(d.id).c_str());
for (const auto& a : d.attributes)
std::printf(" (%s: %s)\n", a.first.c_str(), a.second.c_str());
for (const Reading& r : snap.forDevice(d.id))
std::printf(" %-16s %10.2f %s\n", r.channel.c_str(), r.value, unitSymbol(r.unit));
std::printf("\n");
}
return 0;
}