diff --git a/src/detection/cpu/cpu_obsd.c b/src/detection/cpu/cpu_obsd.c index 04d550198..298f064d6 100644 --- a/src/detection/cpu/cpu_obsd.c +++ b/src/detection/cpu/cpu_obsd.c @@ -1,6 +1,9 @@ #include "cpu.h" #include "common/sysctl.h" +#include +#include + const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) { if (ffSysctlGetString(CTL_HW, HW_MODEL, &cpu->name)) @@ -13,7 +16,14 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) ffCPUDetectSpeedByCpuid(cpu); cpu->frequencyBase = (uint32_t) ffSysctlGetInt(CTL_HW, HW_CPUSPEED, 0); - cpu->temperature = FF_CPU_TEMP_UNSET; // HW_SENSORS? + cpu->temperature = FF_CPU_TEMP_UNSET; + if (options->temp) + { + struct sensor sensors; + size_t size = sizeof(sensors); + if (sysctl((int[]) {CTL_HW, HW_SENSORS, 0, SENSOR_TEMP, 0}, 5, &sensors, &size, NULL, 0) == 0) + cpu->temperature = (double) (sensors.value - 273150000) / 1E6; + } return NULL; }