evisum/src/bin/system/machine.h

129 lines
2.0 KiB
C
Raw Normal View History

2020-05-13 04:17:39 -07:00
#ifndef __MACHINE_H__
#define __MACHINE_H__
2018-06-04 03:11:21 -07:00
/* All functions and data types implementing these APIs have no additional
* system dependencies deliberately.
*
* See machine.c and the files includes in machine/ sub directory.
*/
2018-06-10 06:09:44 -07:00
#include <stdint.h>
#include <stdbool.h>
typedef struct
{
unsigned long total;
unsigned long idle;
2020-06-17 03:27:36 -07:00
float percent;
2018-06-10 06:09:44 -07:00
} cpu_core_t;
typedef struct
{
uint64_t total;
uint64_t used;
uint64_t cached;
uint64_t buffered;
uint64_t shared;
uint64_t swap_total;
uint64_t swap_used;
uint64_t zfs_arc_used;
2018-06-10 06:09:44 -07:00
} meminfo_t;
typedef struct
{
char *name;
char *child_name;
2020-06-17 03:27:36 -07:00
double value;
bool invalid;
} sensor_t;
2019-09-01 06:54:27 -07:00
typedef struct
{
2020-06-18 04:17:11 -07:00
char *name;
double charge_full;
double charge_current;
2019-09-01 06:54:27 -07:00
uint8_t percent;
bool present;
2020-06-18 04:17:11 -07:00
#if defined(__OpenBSD__)
int *mibs;
#endif
2019-09-01 06:54:27 -07:00
} bat_t;
2018-06-10 06:09:44 -07:00
typedef struct
{
bool have_ac;
int battery_count;
2018-06-10 06:09:44 -07:00
2019-09-01 06:54:27 -07:00
bat_t **batteries;
int ac_mibs[5];
2018-06-10 06:09:44 -07:00
} power_t;
typedef struct
{
uint64_t incoming;
uint64_t outgoing;
} network_t;
typedef struct Sys_Info Sys_Info;
struct Sys_Info
2018-06-10 06:09:44 -07:00
{
int cpu_count;
cpu_core_t **cores;
2018-06-10 06:09:44 -07:00
meminfo_t memory;
power_t power;
2020-06-17 03:27:36 -07:00
int sensor_count;
sensor_t **sensors;
network_t network_usage;
2018-06-10 06:09:44 -07:00
};
Sys_Info *
2020-06-17 15:08:44 -07:00
system_info_all_get(void);
2018-06-10 06:09:44 -07:00
2020-06-16 12:12:55 -07:00
void
2020-06-17 15:08:44 -07:00
system_info_all_free(Sys_Info *);
2020-06-16 12:12:55 -07:00
int
2020-07-11 09:23:34 -07:00
system_cpu_online_count_get(void);
int
system_cpu_count_get(void);
cpu_core_t **
system_cpu_usage_get(int *ncpu);
2020-06-24 15:10:50 -07:00
cpu_core_t **
system_cpu_usage_delayed_get(int *ncpu, int usecs);
2020-09-06 05:23:08 -07:00
int
system_cpu_frequency_get(void);
2020-09-07 04:50:32 -07:00
int
system_cpu_n_frequency_get(int n);
2020-10-08 04:54:33 -07:00
int
system_cpu_n_temperature_get(int n);
2020-10-10 04:03:46 -07:00
int
system_cpu_temperature_min_max_get(int *min, int *max);
2020-09-07 04:50:32 -07:00
int
system_cpu_frequency_min_max_get(int *min, int *max);
void
system_memory_usage_get(meminfo_t *memory);
sensor_t **
system_sensors_thermal_get(int *count);
void
system_power_state_get(power_t *power);
void
system_network_transfer_get(network_t *usage);
2018-06-04 03:11:21 -07:00
#endif