vcpe/srcs/libs/include/hardware.h

104 lines
2.7 KiB
C

//
// Created by xajhu on 2021/7/6 0006.
//
#ifndef DAEMON_AGENT_PROJECT_AGENT_INCLUDE_HARDWARE_H
#define DAEMON_AGENT_PROJECT_AGENT_INCLUDE_HARDWARE_H
#ifdef __cplusplus
extern "C" {
#endif
#define MEM_VALUE_SIZE (64)
#define MAX_WATCH_DISK_DEVICE (256)
#define REFRESH_MAX_PERIOD (24 * 3600)
#define MAX_SENSOR_ITEMS (1000)
typedef struct {
char cpuName[MEM_VALUE_SIZE * 4];
int cpuSpeed;
} CPU_DESC, *PCPU_DESC;
typedef struct {
unsigned int nCores;
unsigned int nLogicCores;
unsigned int nCpus;
double cpuUsed;
unsigned int timestamp;
CPU_DESC cpuCoreDesc;
} CPU_INFO, *PCPU_INFO;
typedef struct {
const char *deviceName;
const char *diskSize;
const char *diskUsed;
const char *usedPercent;
} DISK_PART_USED, *PDISK_PART_USED;
typedef struct {
int nItems;
unsigned int timestamp;
DISK_PART_USED diskPartInfo[MAX_WATCH_DISK_DEVICE];
} DISK_INFO, *PDISK_INFO;
typedef struct {
const char *sensorName;
const char *value;
const char *unit;
const char *status;
} SENSOR_ITEM, *PSENSOR_ITEM;
typedef struct {
int nItems;
unsigned int timestamp;
SENSOR_ITEM sensorInfo[MAX_SENSOR_ITEMS];
} SENSOR_INFO, *PSENSOR_INFO;
typedef struct {
char cachedMemSize[MEM_VALUE_SIZE];
char bufferMemSize[MEM_VALUE_SIZE];
char availMemSize[MEM_VALUE_SIZE];
char freeMemSize[MEM_VALUE_SIZE];
char totalMemSize[MEM_VALUE_SIZE];
unsigned int timestamp;
} MEMORY_INFO, *PMEMORY_INFO;
typedef struct {
CPU_INFO cpuInfo;
MEMORY_INFO memInfo;
DISK_INFO diskInfo;
SENSOR_INFO sensorInfo;
} HARDWARE_INFO, *PHARDWARE_INFO;
int init_hardware();
const char *get_hardware_json();
//*****************************************************
// CPU 相关功能
//*****************************************************
int cpu_watch_init();
int get_cpu_info(PCPU_INFO pInfo);
//*****************************************************
// 内存 相关功能
//*****************************************************
unsigned int get_sys_free_memory();
unsigned int get_sys_total_memory();
int get_memory_info(PMEMORY_INFO pInfo);
int memory_watch_init();
//*****************************************************
// 磁盘分区 相关功能
//*****************************************************
int get_disk_info(PDISK_INFO pInfo);
int disk_watch_info();
//*****************************************************
// 传感器 相关功能
//*****************************************************
int sensor_watch_init();
int get_sensor_info(PSENSOR_INFO pInfo);
#ifdef __cplusplus
}
#endif
#endif//DAEMON_AGENT_PROJECT_AGENT_INCLUDE_HARDWARE_H