|
|
|
@ -381,9 +381,9 @@ bool CPUStats::UpdateCpuPower() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool find_temp_input(const std::string path, std::string& input, const std::string& name)
|
|
|
|
|
static bool find_input(const std::string& path, const char* input_prefix, std::string& input, const std::string& name)
|
|
|
|
|
{
|
|
|
|
|
auto files = ls(path.c_str(), "temp", LS_FILES);
|
|
|
|
|
auto files = ls(path.c_str(), input_prefix, LS_FILES);
|
|
|
|
|
for (auto& file : files) {
|
|
|
|
|
if (!ends_with(file, "_label"))
|
|
|
|
|
continue;
|
|
|
|
@ -402,9 +402,9 @@ static bool find_temp_input(const std::string path, std::string& input, const st
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool find_fallback_temp_input(const std::string path, std::string& input)
|
|
|
|
|
static bool find_fallback_input(const std::string& path, const char* input_prefix, std::string& input)
|
|
|
|
|
{
|
|
|
|
|
auto files = ls(path.c_str(), "temp", LS_FILES);
|
|
|
|
|
auto files = ls(path.c_str(), input_prefix, LS_FILES);
|
|
|
|
|
if (!files.size())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
@ -413,7 +413,7 @@ static bool find_fallback_temp_input(const std::string path, std::string& input)
|
|
|
|
|
if (!ends_with(file, "_input"))
|
|
|
|
|
continue;
|
|
|
|
|
input = path + "/" + file;
|
|
|
|
|
SPDLOG_DEBUG("fallback cpu temp input: {}", input);
|
|
|
|
|
SPDLOG_DEBUG("fallback cpu {} input: {}", input_prefix, input);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
@ -433,23 +433,24 @@ bool CPUStats::GetCpuFile() {
|
|
|
|
|
SPDLOG_DEBUG("hwmon: sensor name: {}", name);
|
|
|
|
|
|
|
|
|
|
if (name == "coretemp") {
|
|
|
|
|
find_temp_input(path, input, "Package id 0");
|
|
|
|
|
find_input(path, "temp", input, "Package id 0");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if ((name == "zenpower" || name == "k10temp")) {
|
|
|
|
|
find_temp_input(path, input, "Tdie");
|
|
|
|
|
if (!find_input(path, "temp", input, "Tdie"))
|
|
|
|
|
find_input(path, "temp", input, "Tctl");
|
|
|
|
|
break;
|
|
|
|
|
} else if (name == "atk0110") {
|
|
|
|
|
find_temp_input(path, input, "CPU Temperature");
|
|
|
|
|
find_input(path, "temp", input, "CPU Temperature");
|
|
|
|
|
break;
|
|
|
|
|
} else if (name == "it8603") {
|
|
|
|
|
find_temp_input(path, input, "temp1");
|
|
|
|
|
find_input(path, "temp", input, "temp1");
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
path.clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (path.empty() || (!file_exists(input) && !find_fallback_temp_input(path, input))) {
|
|
|
|
|
if (path.empty() || (!file_exists(input) && !find_fallback_input(path, "temp", input))) {
|
|
|
|
|
SPDLOG_ERROR("Could not find cpu temp sensor location");
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
@ -459,27 +460,6 @@ bool CPUStats::GetCpuFile() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool find_input(const std::string& path, const char* input_prefix, std::string& input, const std::string& name)
|
|
|
|
|
{
|
|
|
|
|
auto files = ls(path.c_str(), input_prefix, LS_FILES);
|
|
|
|
|
for (auto& file : files) {
|
|
|
|
|
if (!ends_with(file, "_label"))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
auto label = read_line(path + "/" + file);
|
|
|
|
|
if (label != name)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
auto uscore = file.find_first_of("_");
|
|
|
|
|
if (uscore != std::string::npos) {
|
|
|
|
|
file.erase(uscore, std::string::npos);
|
|
|
|
|
input = path + "/" + file + "_input";
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static CPUPowerData_k10temp* init_cpu_power_data_k10temp(const std::string path) {
|
|
|
|
|
auto powerData = std::make_unique<CPUPowerData_k10temp>();
|
|
|
|
|
|
|
|
|
|