thermal: parse what is good.

This commit is contained in:
Alastair Poole 2020-06-18 13:36:23 +01:00
parent d9a750e323
commit 6bd132a6b5
1 changed files with 11 additions and 5 deletions

View File

@ -370,7 +370,7 @@ _cpu_state_get(cpu_core_t **cores, int ncpu)
} }
static cpu_core_t ** static cpu_core_t **
_cpu_cores_state_get(int *ncpu) _cpu_usage_get(int *ncpu)
{ {
cpu_core_t **cores; cpu_core_t **cores;
int i; int i;
@ -696,6 +696,11 @@ _sensors_thermal_get(Sys_Info *info)
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
if (strncmp(names[i]->d_name, "thermal_zone", 12))
{
free(names[i]);
continue;
}
snprintf(path, sizeof(path), "/sys/class/thermal/%s/type", snprintf(path, sizeof(path), "/sys/class/thermal/%s/type",
names[i]->d_name); names[i]->d_name);
@ -1021,6 +1026,9 @@ _power_state_get(power_t *power)
char *buf; char *buf;
#endif #endif
if (!_power_battery_count_get(power))
return;
#if defined(__OpenBSD__) #if defined(__OpenBSD__)
power->ac_mibs[3] = 9; power->ac_mibs[3] = 9;
power->ac_mibs[4] = 0; power->ac_mibs[4] = 0;
@ -1239,7 +1247,7 @@ system_info_all_get(void)
info = calloc(1, sizeof(Sys_Info)); info = calloc(1, sizeof(Sys_Info));
if (!info) return NULL; if (!info) return NULL;
info->cores = _cpu_cores_state_get(&info->cpu_count); info->cores = _cpu_usage_get(&info->cpu_count);
_memory_usage_get(&info->memory); _memory_usage_get(&info->memory);
@ -1247,9 +1255,7 @@ system_info_all_get(void)
if (error) if (error)
_network_transfer_get(info); _network_transfer_get(info);
if (_power_battery_count_get(&info->power)) _power_state_get(&info->power);
_power_state_get(&info->power);
_sensors_thermal_get(info); _sensors_thermal_get(info);
if (!error) if (!error)