the new format
git-svn-id: http://172.17.0.253/svn/soft_pkgs/sys_nicmonitor@146 09c3743a-b0dd-45d3-b506-aa74c7a2a6ef
This commit is contained in:
198
code/trunk/sys_nicmonitor/proc_inv.h
Normal file
198
code/trunk/sys_nicmonitor/proc_inv.h
Normal file
@@ -0,0 +1,198 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) Comets' Grp. of Kedong Corp 2008. All Rights Reserved.
|
||||
//
|
||||
// FileName : procconf.h
|
||||
//
|
||||
// Function : this class realize some basic functions for process managerment,
|
||||
// such as initiate process, report status of process, check status of process,
|
||||
// update status of process, get information of process
|
||||
//
|
||||
// Author :
|
||||
//
|
||||
// Date :
|
||||
//
|
||||
// Modify by :
|
||||
//
|
||||
// Mod Date :
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _PROCCONF_H
|
||||
#define _PROCCONF_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
//#include <iostream.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "const.h"
|
||||
|
||||
//for alarm ................................
|
||||
typedef struct MESS_BH
|
||||
{
|
||||
unsigned char mtype;
|
||||
int length;
|
||||
};
|
||||
typedef struct PROCESS_ALM
|
||||
{
|
||||
char context_name[MAX_STRING_LEN];
|
||||
char app_name[MAX_STRING_LEN];
|
||||
char proc_name[MAX_STRING_LEN];
|
||||
unsigned char status;
|
||||
};
|
||||
//for alarm end .............................
|
||||
|
||||
//for mmi....................................
|
||||
const int MAX_BUFFER_LEN = 500;
|
||||
typedef struct MESS_BLOCK
|
||||
{
|
||||
unsigned char num;
|
||||
char buffer[MAX_BUFFER_LEN];
|
||||
};
|
||||
typedef struct MESS_PROC
|
||||
{
|
||||
char context_name[MAX_STRING_LEN];
|
||||
char app_name[MAX_STRING_LEN];
|
||||
char proc_name[MAX_STRING_LEN];
|
||||
char status;
|
||||
};
|
||||
//for mmi end ................................
|
||||
|
||||
const int DEFAULT_PERIOD = 3;
|
||||
const int COUNT_LIMIT = 2;
|
||||
const int START_DEFAULT_PERIOD = 60;
|
||||
const int START_COUNT_LIMIT = 5;
|
||||
const int APP_COUNT_LIMIT = 1;
|
||||
|
||||
//process critical level
|
||||
//const int WST_CRITICAL = 1; // Shutdown and reboot workstation when failed
|
||||
//const int SYS_CRITICAL = 2; // Shutdown and reboot the system on the wst when failed
|
||||
//const int USER_CRITICAL = 3; // Shutdown and reboot the subsystem when failed
|
||||
//const int GENERAL = 4; // reboot the process
|
||||
const int CRUCIAL = 1; // crucial process
|
||||
const int GENERAL = 0; // general process
|
||||
|
||||
|
||||
extern int srv_init(char *service,int port);
|
||||
extern int Tcp_close(int sockfd);
|
||||
extern int Tcp_read(int fd,char *ptr,int nbytes);
|
||||
extern int Tcp_write(int fd,char *ptr,int nbytes);
|
||||
extern int srv_accept(int fd,struct sockaddr *cli_addr,int *clilen);
|
||||
extern int client_tcp_open(char *host,char *service,int port);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char context_name[MAX_STRING_LEN];
|
||||
char app_name[MAX_STRING_LEN];
|
||||
char proc_name[MAX_STRING_LEN];
|
||||
pid_t proc_pid;
|
||||
}PROC_ADM_INFO;
|
||||
|
||||
//***************************************************************
|
||||
// structure name : PROC_INFO
|
||||
// function : store process informatin
|
||||
// author :
|
||||
// date :
|
||||
// modify by :
|
||||
// modification :
|
||||
// mod date :
|
||||
//***************************************************************
|
||||
typedef struct
|
||||
{
|
||||
int position;
|
||||
char node_name[MAX_STRING_LEN];
|
||||
char context_name[MAX_STRING_LEN];
|
||||
char app_name[MAX_STRING_LEN];
|
||||
char proc_name[MAX_STRING_LEN];
|
||||
|
||||
unsigned char active_flag;
|
||||
unsigned char master_flag;
|
||||
|
||||
time_t startup_time;
|
||||
time_t refresh_time;
|
||||
short refresh_peri;
|
||||
unsigned char monitor_type;
|
||||
|
||||
pid_t proc_pid;
|
||||
unsigned char auto_start;
|
||||
unsigned char act_timer;
|
||||
unsigned char start_timer;
|
||||
unsigned char critical_level;
|
||||
|
||||
char exefile_path[MAX_EXECMD_LEN];
|
||||
|
||||
}PROC_INFO;
|
||||
|
||||
//***************************************************************
|
||||
// structure name : APP_INFO
|
||||
// function : store application informatin
|
||||
// author :
|
||||
// date :
|
||||
// modify by :
|
||||
// modification :
|
||||
// mod date :
|
||||
//***************************************************************
|
||||
typedef struct
|
||||
{
|
||||
int position;
|
||||
char context_name[MAX_STRING_LEN];
|
||||
int context_id;
|
||||
char app_name[MAX_STRING_LEN];
|
||||
int app_id;
|
||||
unsigned char act_timer;
|
||||
unsigned char active_flag;
|
||||
}APP_INFO;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int no_proc;
|
||||
int semdes_cfg;
|
||||
PROC_INFO proc[MAX_LOCAL_PROCESS];
|
||||
APP_INFO app[MAX_LOCAL_APP];
|
||||
}PROCCFG;
|
||||
|
||||
class proc_invocation
|
||||
{
|
||||
public:
|
||||
int m_init;
|
||||
PROCCFG *proccfg_p;
|
||||
|
||||
public:
|
||||
proc_invocation();
|
||||
~proc_invocation();
|
||||
|
||||
int conf_create();
|
||||
//int check_proc_status();
|
||||
//int update_rtdb();
|
||||
//int kill_proc(pid_t pid);
|
||||
//int start_proc(char *cmdline);
|
||||
//int send_alarm(char *context_name, char *app_name, char *proc_name, unsigned char status);
|
||||
//int update_proc_status(char *context_name, char *app_name, char *proc_name, char status);
|
||||
|
||||
//int proc_init(char *context_name, char *app_name, char *proc_name, int critical_level);//exefile_path,auto_start
|
||||
int proc_init(char *context_name, char *app_name, char *proc_name);
|
||||
int proc_report(int pos, char status, int intertime=3);
|
||||
int proc_exit(int proc_pos);
|
||||
|
||||
int get_pos(char *context_name, char *app_name, char *proc_name);
|
||||
int is_proc_exist(char *context_name, char *app_name, char *proc_name);
|
||||
int conf_map();
|
||||
|
||||
int get_procinfo(int position, PROC_ADM_INFO *p_info);
|
||||
int get_active_pid(int &num, int *p_pidlist);
|
||||
int is_proc_run(pid_t pid);
|
||||
int is_proc_run(char *context_name, char *app_name, char *proc_name);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user