evisum/src/bin/system/machine.h

100 lines
1.6 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
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-06-07 06:39:13 -07:00
unsigned long long total;
unsigned long long used;
unsigned long long cached;
unsigned long long buffered;
unsigned long long shared;
unsigned long long swap_total;
unsigned long long swap_used;
unsigned long long zfs_arc_used;
2018-06-10 06:09:44 -07:00
} meminfo_t;
typedef struct
{
char *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
{
unsigned long incoming;
unsigned long 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;
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-05-13 13:13:01 -07:00
system_cpu_online_count_get();
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);
void
system_memory_usage_get(meminfo_t *memory);
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