?? monapi.h
字號(hào):
/*
* Copyright (c) 2002, 南京聯(lián)創(chuàng)系統(tǒng)集成股份有限公司綜合結(jié)算產(chǎn)品部
* All rights reserved.
*
* 文件名稱(chēng):monapi.h
* 摘 要:聲明了集中監(jiān)控程序所用到的數(shù)據(jù)結(jié)構(gòu)和類(lèi)
*
* 當(dāng)前版本:
* 作 者:馮亮(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]; /*主機(jī)的cpu使用率*/
char hostmem[10+1]; /*主機(jī)已經(jīng)使用的內(nèi)存(KB)*/
}S_HostInformation;
typedef struct
{
char commandline[20+1]; /*別名*/
char startdate[10+1]; /*進(jìn)程啟動(dòng)日期*/
char starttime[8+1]; /*進(jìn)程啟動(dòng)時(shí)間*/
char procid[10+1]; /*進(jìn)程ID*/
char object[255+1]; /*進(jìn)程處理對(duì)象*/
char status[10+1]; /*進(jìn)程狀態(tài)*/
char step[10+1]; /*進(jìn)程處理步驟*/
char count[10+1]; /*進(jìn)程處理計(jì)數(shù)器*/
char totalsize[10+1]; /*總共須處理的字節(jié)數(shù)*/
char finishedsize[10+1]; /*已經(jīng)完成的字節(jié)數(shù)*/
char processcpu[10+1]; /*進(jìn)程的cpu使用率*/
char processmem[10+1]; /*進(jìn)程占用的內(nèi)存(KB)*/
unsigned long total; /*從啟動(dòng)到現(xiàn)在處理的話(huà)單數(shù)*/
unsigned long error; /*從啟動(dòng)到現(xiàn)在的錯(cuò)單數(shù)*/
char cdrprocspeed[20+1]; /*處理話(huà)單的速率(條/秒)*/
int CurrentIndex; /*這個(gè)進(jìn)程的共享內(nèi)存號(hào)索引*/
int ChannelCode; /*這個(gè)進(jìn)程的通道號(hào)*/
S_HostInformation hostinformation; /*被監(jiān)控主機(jī)的信息*/
}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--------------------------------------
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -