/* =============================================================================================== * * Filename: monitor.h * * Description: Declare monitoring module functions and dependencies. * * Version: 0.1 * Created: 2020年07月15日 10时21分 * Revision: none * Compiler: gcc * Link: -lpthread * * Author: songtianlun, songtianlun@comleader.com.cn * Organization: IEUCD * * ===============================================================================================*/ #include #include #include #include #include #include #include #include #include #include #include "ini/INIReader.h" #define MAXBUFSIZE 1024 struct KEY_PROCESS { int sum_monitor; int num_normal; int num_abnormal; int pid_abnormal[10]; char Char; short Short; long Long; float Float; double Double; char String[100]; }; struct CPU_INFO { char name[10]; unsigned int user; unsigned int nice; unsigned int system; unsigned int idle; unsigned int iowait; unsigned int irq; unsigned int softirq; unsigned int stealstolen; unsigned int guest; unsigned int guest_nice; }; struct MEM_INFO { unsigned int total; unsigned int free; unsigned int buffers; unsigned int cached; unsigned int swap_cached; unsigned int swap_total; unsigned int swap_free; unsigned int available; }; struct USERS_INFO { char name[50]; char passwd[10]; char cid[10]; char cgroup_id[10]; }; struct GROUPS_INFO { char name[50]; char passwd[10]; char gid[10]; }; typedef struct KEY_PROCESS Key_process; typedef struct CPU_INFO Cpu_info; typedef struct MEM_INFO Mem_info; typedef struct USERS_INFO User_info; typedef struct GROUPS_INFO Group_info; void *monitor_key_process(void *args); void *monitor_key_sys_value(void *args); void *monitor_key_files(void *args); void *monitor_key_log(void *args); int init_config(char *conf_path); void get_cpu_occupy (Cpu_info *o); float cal_cpu_occupy(Cpu_info *, Cpu_info *); void get_mem_occupy (Mem_info *o); float cal_mem_occupy(Mem_info *); int get_tcp_socket_sum (); int get_progress_sum (); int get_users (User_info users[]); int get_groups (Group_info groups[]); int get_crontab (char crontab[][200]); void print_now_time(); int split(char dst[][80], char* str, const char* spl);