Added temperature watchdog and utilization for CPU on linux using sysfs and procfs

This commit is contained in:
Jens Steube
2021-07-10 14:24:51 +02:00
parent bfe83ec138
commit 9fc6c26f8c
4 changed files with 117 additions and 2 deletions
+20
View File
@@ -15,6 +15,8 @@ static const char SENSOR_K10TEMP[] = "k10temp";
static const char SENSOR_K8TEMP[] = "k8temp";
static const char SENSOR_ACPITZ[] = "acpitz";
static const char PROC_STAT[] = "/proc/stat";
typedef int HM_ADAPTER_SYSFS_CPU;
typedef void *SYSFS_CPU_LIB;
@@ -27,6 +29,21 @@ typedef struct hm_sysfs_cpu_lib
} hm_sysfs_cpu_lib_t;
typedef struct
{
unsigned long user;
unsigned long nice;
unsigned long system;
unsigned long idle;
unsigned long iowait;
unsigned long irq;
unsigned long softirq;
unsigned long steal;
unsigned long guest;
unsigned long guest_nice;
} proc_stat_t;
typedef hm_sysfs_cpu_lib_t SYSFS_CPU_PTR;
bool sysfs_cpu_init (void *hashcat_ctx);
@@ -34,4 +51,7 @@ void sysfs_cpu_close (void *hashcat_ctx);
char *hm_SYSFS_CPU_get_syspath_hwmon ();
int hm_SYSFS_CPU_get_temperature_current (void *hashcat_ctx, int *val);
bool read_proc_stat (void *hashcat_ctx, proc_stat_t *proc_stat);
int hm_SYSFS_CPU_get_utilization_current (void *hashcat_ctx, int *val);
#endif // _EXT_SYSFS_CPU_H