several sanity checks added

This commit is contained in:
2026-03-19 00:35:00 +01:00
parent 0ba5d49758
commit 27720d4f54
2 changed files with 9 additions and 3 deletions

View File

@@ -49,7 +49,10 @@ void update(cpuSensors* c) {
utils::fastReadNum<1000>("/sys/devices/system/cpu/cpu" + std::to_string(i) + "/cpufreq/cpuinfo_avg_freq", buf, t);
c->avg_freq += t;
}
c->avg_freq /= c->num_cores;
c->avg_freq /= (c->num_cores > 1) ? c->num_cores : 1;
if (c->hwmon.empty())
return;
// commented out unused values so its faster
if (c->module == zenpower) {

View File

@@ -102,12 +102,15 @@ void updateFromMetrics(gpuSensors* g) {
/* reads values from system and updates the target gpu::sensors struct */
void update(gpuSensors* g) {
fillMissingMetrics(g);
const bool hwmon_valid = !g->hwmon.empty();
if (hwmon_valid)
fillMissingMetrics(g);
if (g->hasGpuMetrics)
updateFromMetrics(g);
else
updateFromFs(g);
if (hwmon_valid)
updateFromFs(g);
if (g->fan_speed > 9999) g->fan_speed = 9999; // sanity check fan speed
}