/************************************************************************* > File Name : CJudgeSysInfo.h > Author : FengChao > EMail : smile.fengchao@gmail.com > Created Time : Fri 17 Jul 2020 09:47:20 AM CST ************************************************************************/ #ifndef CJUDGE_SYS_INFO_H #define CJUDGE_SYS_INFO_H #include "CTypedef.h" #include "CJudgeUtils.h" #include #include "CZeroMQ.h" #define MAX_MSG_BUFFER 1024 // 通信消息缓存区 #define getbit(x,y) ((x) >> (y)&1) #define setbit(x,y) x|=(1< SysState_MV; typedef std::vector SysLog_MV; typedef struct { SysState_MV sys_state_mv; time_t start_ms; }SysState_Group; typedef struct { SysLog_MV sys_log_mv; time_t start_ms; }SysLog_Group; */ class CJudgeSysInfo : public CSingleton { public: CJudgeSysInfo(); virtual ~CJudgeSysInfo(); public: void Init(); void RcvNosStateMessage(); void Judge(); int GetNosRunning(int nos_id); private: void JudgeSysState(std::vector& sys_state_v, uint& nos_time_out_bit); void JudgeProcessState(); void JudgeFileState(); void JudgeFileNum(); void JudgeSysLog(std::vector& SysShellLog_MV, std::vector& SysLoginLog_MV); int JudgeCpuOccupy(uint cpu_occupy, uint nos_id); int JudgeMemOccupy(uint mem_occupy, uint nos_id); int JudgeTcpSocket(uint tcp_establish_num, uint nos_id); int JudgeProcessNum(uint running_process, uint nos_id); void JudgeLoginLog(std::vector& SysLoginLog_CMV); void JudgeShellLog(std::vector& SysShellLog_CMV); int JudgeUserInfo(char passwd_md5[64], uint nos_id); int JudgeGroupInfo(char group_md5[64], uint nos_id); int JudgeCronNum(uint cron_num, uint nos_id); void JudgePathFileNum(); void JudgeHomeFileNum(); void JudgeAppMd5(); void JudgeAutoStartMd5(); void JudgeManagerProgress(); void JudgeProtocolProgress(); void JudgeLocalConfigManager(); void JudgeFirewell(); int SendDataToShd(const void *pvData, unsigned int uiDataLen); int RecvDataFromShd(void *pvBuff, unsigned int uiBuffLen); // 消息解析函数 SysState_T SplitMsgToSysState(char *buffer, int len_Buffer); ProcessState_T SplitMsgToProcessState(char *buffer, int len_Buffer); FileState_T SplitMsgToFileState(char *buffer, int len_Buffer); FileNum_T SplitMsgToFileNum(char *buffer, int len_Buffer); SysLog_T SplitMsgToSysLog(char *buffer, int len_Buffer); uint GetNosId(char ip[32]); private: // 全局标志位 uint nos_running_bit; // 配置 int nos_report_port; int schedule_port; int msg_time_out; int nos_num; uint running_num; std::string schedule_ip; SysState_T m_SysState; // 系统运行状态消息 ProcessState_T m_ProcessState; // 关键进程状态消息 FileState_T m_FileState; // 关键文件状态消息 FileNum_T m_FileNum; // 关键文件数量消息 SysLog_T m_SysLog; // 关键日志增量消息 // Judge_sys_info std::string sys_shell_log_name; std::string sys_login_log_name; std::string process_manager_name; std::string process_protocol_name; std::string process_local_cfgm_name; std::string process_firewall_name; std::string user_md5; std::string group_md5; std::string config_manager_md5; std::string auto_start_md5; uint cpu_occupy_max; uint mem_occupy_max; uint tcp_socket_max; uint process_max; uint cron_max; uint path_file_max; uint home_file_max; uint process_running_code; // ZeroMQ Connect CZMQReqRep *m_pShdClient; CZMQReqRep *m_pNosServer; }; #endif