2020-05-13 04:17:39 -07:00
|
|
|
#ifndef __MACHINE_H__
|
|
|
|
#define __MACHINE_H__
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2020-07-11 05:09:38 -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
|
|
|
|
{
|
2020-07-11 05:09:38 -07:00
|
|
|
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;
|
|
|
|
|
2020-06-16 06:29:06 -07:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char *name;
|
2020-10-05 04:18:26 -07:00
|
|
|
char *child_name;
|
2020-06-17 03:27:36 -07:00
|
|
|
double value;
|
|
|
|
bool invalid;
|
2020-06-16 06:29:06 -07:00
|
|
|
} sensor_t;
|
|
|
|
|
2019-09-01 06:54:27 -07:00
|
|
|
typedef struct
|
|
|
|
{
|
2020-06-18 04:17:11 -07:00
|
|
|
char *name;
|
2019-09-07 03:36:46 -07:00
|
|
|
double charge_full;
|
|
|
|
double charge_current;
|
2019-09-01 06:54:27 -07:00
|
|
|
uint8_t percent;
|
2020-04-28 05:39:05 -07:00
|
|
|
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
|
|
|
|
{
|
2019-09-07 03:36:46 -07:00
|
|
|
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;
|
2019-09-07 03:36:46 -07:00
|
|
|
int ac_mibs[5];
|
2018-06-10 06:09:44 -07:00
|
|
|
} power_t;
|
|
|
|
|
2020-06-18 07:36:39 -07:00
|
|
|
typedef struct
|
|
|
|
{
|
2020-07-10 07:04:06 -07:00
|
|
|
uint64_t incoming;
|
|
|
|
uint64_t outgoing;
|
2020-06-18 07:36:39 -07:00
|
|
|
} network_t;
|
|
|
|
|
2020-05-14 06:43:44 -07:00
|
|
|
typedef struct Sys_Info Sys_Info;
|
|
|
|
struct Sys_Info
|
2018-06-10 06:09:44 -07:00
|
|
|
{
|
|
|
|
int cpu_count;
|
|
|
|
cpu_core_t **cores;
|
2020-07-11 05:09:38 -07:00
|
|
|
|
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;
|
2020-07-11 05:09:38 -07:00
|
|
|
sensor_t **sensors;
|
2020-06-16 06:29:06 -07:00
|
|
|
|
2020-06-18 07:36:39 -07:00
|
|
|
network_t network_usage;
|
2018-06-10 06:09:44 -07:00
|
|
|
};
|
|
|
|
|
2020-05-14 06:43: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
|
|
|
|
2019-11-16 07:58:16 -08:00
|
|
|
int
|
2020-07-11 09:23:34 -07:00
|
|
|
system_cpu_online_count_get(void);
|
|
|
|
|
|
|
|
int
|
|
|
|
system_cpu_count_get(void);
|
2019-11-16 07:58:16 -08:00
|
|
|
|
2020-06-18 07:36:39 -07:00
|
|
|
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);
|
|
|
|
|
2020-06-18 07:36:39 -07:00
|
|
|
void
|
|
|
|
system_memory_usage_get(meminfo_t *memory);
|
|
|
|
|
2020-06-28 12:02:07 -07:00
|
|
|
sensor_t **
|
|
|
|
system_sensors_thermal_get(int *count);
|
|
|
|
|
2020-06-18 07:36:39 -07:00
|
|
|
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
|