evisum/src/bin/system.h

83 lines
1.3 KiB
C
Raw Normal View History

2018-06-04 03:11:21 -07:00
#ifndef __SYSTEM_H__
#define __SYSTEM_H__
2018-06-10 06:09:44 -07:00
#include <stdint.h>
#include <stdbool.h>
typedef struct
{
float percent;
unsigned long total;
unsigned long idle;
} cpu_core_t;
typedef struct
{
unsigned long total;
unsigned long used;
unsigned long cached;
unsigned long buffered;
unsigned long shared;
unsigned long swap_total;
unsigned long swap_used;
} meminfo_t;
2019-09-01 06:54:27 -07:00
#define MAX_BATTERIES 10
2020-02-15 18:03:32 -08:00
2019-09-01 06:54:27 -07:00
typedef struct
{
double charge_full;
double charge_current;
2019-09-01 06:54:27 -07:00
uint8_t percent;
} 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;
// Necessary evils.
char *battery_names[MAX_BATTERIES];
int *bat_mibs[MAX_BATTERIES];
int ac_mibs[5];
2018-06-10 06:09:44 -07:00
} power_t;
2020-02-15 18:03:32 -08:00
#define INVALID_TEMP -999
2018-06-10 06:09:44 -07:00
typedef struct results_t results_t;
struct results_t
{
int cpu_count;
cpu_core_t **cores;
meminfo_t memory;
power_t power;
unsigned long incoming;
unsigned long outgoing;
int temperature;
};
2020-04-14 10:24:27 -07:00
results_t *
system_stats_get(void);
2018-06-10 06:09:44 -07:00
2018-06-04 03:11:21 -07:00
int
2018-10-02 07:38:06 -07:00
system_cpu_memory_get(double *percent_cpu, long *memory_total, long *memory_used);
2018-06-04 03:11:21 -07:00
2018-06-10 06:09:44 -07:00
bool
2018-10-02 07:38:06 -07:00
system_network_transfer_get(unsigned long *incoming, unsigned long *outgoing);
2018-06-10 06:09:44 -07:00
int
2018-10-02 07:38:06 -07:00
system_temperature_cpu_get(void);
2018-06-10 06:09:44 -07:00
void
2018-10-02 07:38:06 -07:00
system_power_state_get(power_t *power);
2018-06-10 06:09:44 -07:00
int
system_cpu_online_count_get();
2018-06-04 03:11:21 -07:00
#endif