⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 monapi.h

📁 此源代码只用于学习,不得用于其他商业活动 .
💻 H
字号:
/*

* Copyright (c) 2002, 南京联创系统集成股份有限公司综合结算产品部

* All rights reserved.

*

* 文件名称:monapi.h

* 摘    要:声明了集中监控程序所用到的数据结构和类

*

* 当前版本:

* 作    者:冯亮(fengl@lianchuang.com)

* 完成日期:2002年09月04日

*/

#ifndef _MONAPI_H_

#define	_MONAPI_H_



#include <sys/stat.h>

#include <sys/shm.h>

#include <unistd.h>

#include <memory.h>

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <strings.h>

#include <ctype.h>

#include <time.h>

#include <sys/time.h>

#include "c++dcl.h"



#define	INIT		"INIT"

#define	RUN			"RUN"

#define	IDLE		"IDLE"

#define	CONTINUE	"CONTINUE"

#define	EXIT		"EXIT"

#define	ERROR		"ERROR"



#define LINE_LENGTH 8192



/*shared memory key */

#define	SHM_KEY		(key_t)0xabc

#define	SHM_FLAG	IPC_CREAT|0666



#define	MON_MAXPROC	500



#define	MAX_CHANNEL_NUMS	1000



#define	NORMALCDR	0

#define	ERRORCDR	NORMALCDR+1



#define	ARGNUMS	2



typedef struct

{

	char hostcpu[10+1];		/*主机的cpu使用率*/

	char hostmem[10+1];		/*主机已经使用的内存(KB)*/

}S_HostInformation;



typedef struct

{

	char commandline[20+1];				/*别名*/

	char startdate[10+1];				/*进程启动日期*/

	char starttime[8+1];				/*进程启动时间*/

	char procid[10+1];					/*进程ID*/

	char object[255+1];					/*进程处理对象*/

	char status[10+1];					/*进程状态*/

	char step[10+1];					/*进程处理步骤*/

	char count[10+1];					/*进程处理计数器*/

	char totalsize[10+1];				/*总共须处理的字节数*/

	char finishedsize[10+1];			/*已经完成的字节数*/

	char processcpu[10+1];				/*进程的cpu使用率*/

	char processmem[10+1];				/*进程占用的内存(KB)*/

	unsigned long total;				/*从启动到现在处理的话单数*/

	unsigned long error;				/*从启动到现在的错单数*/

	char cdrprocspeed[20+1];			/*处理话单的速率(条/秒)*/

	int CurrentIndex;					/*这个进程的共享内存号索引*/

	int ChannelCode;					/*这个进程的通道号*/

	S_HostInformation hostinformation;	/*被监控主机的信息*/

}S_ShareMemoryInformation;



class C_ShareMemory

{

	public:

		C_ShareMemory(void) {};

		~C_ShareMemory(void) {};

		bool ShareMemoryInit(void);

		void ClearAllMemory(void);

		bool DestroyShareMemory(void);

		void WriteShareMemory(int idx,S_ShareMemoryInformation *ShareMemoryInformation);

		void ReadShareMemory(int idx,S_ShareMemoryInformation *ShareMemoryInformation);

		S_ShareMemoryInformation *GetpShareMemory(void);

	private:

		S_ShareMemoryInformation *pShareMemory;

		int shmidproc;

};



class C_Monitor

{

	public:

		C_Monitor(void)

		{

			CurrentIndex = 0;

		}

		~C_Monitor(void);

		bool ProcIsExist(int argc, char *argv[]);

		void ReportStatus(const char *Status, const char *Object, const char *pchStep = 0);

		bool MonitorInit(int argc, char *argv[]);

		void AddCount(int CDRType);

		void AddRate(unsigned long Bytes);

	private:

		bool MonitorClear(void);

		void Trim(char *String);

		void GetShortProcName(char *pchProcName);

	private:

		int CurrentIndex;

		C_ShareMemory ShareMemory;

		char ZeroDisplay[20+1];

};



#endif	//_MONAPI_H_



//------------------------------------The End--------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -