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

📄 check_status.cxx

📁 HPunix下资源监视程序,查看监视进程的CPU、内存的参数
💻 CXX
字号:
#include <stdio.h>#include <unistd.h>#include "myptop.h"#include "sysmonitor.h"#include <dcepm.h>#include <dstruct.h>#include <oodb.h>#include <sys/select.h>#include <sys/time.h>#include <netdb.h>#include <stdlib.h>#include <iostream.h>#include <fcntl.h>#include <sys/types.h>#include <unistd.h>#include <errno.h>#include <arpa/inet.h>#include <sys/socket.h>#include <string.h>#include <strings.h>#include <signal.h>#include <sys/semaphore.h>extern TB_DESCR tb_descr_Nodeinfo;extern sem_t *sem;extern struct NODE_INFO *nodeinfo_ptr;extern int node_num;extern int moni_interval;int setinfotable(char *hostname){	int recnum,ret,i;	//set Partitioninfo table Flag!	PARTITIONINFO *partinfo_temp;	recnum=oodbfind("Node_name",hostname,&tb_descr_Partitioninfo);	partinfo_temp=(struct PARTITIONINFO *)malloc(sizeof(struct PARTITIONINFO)*recnum);	ret=oodbread_ra(partinfo_temp,"Node_name",hostname,&tb_descr_Partitioninfo,sizeof(PARTITIONINFO)*recnum);	sem_wait(sem);	for(i=0;i<recnum;i++)	{			(partinfo_temp+i)->Flag=1;			ret=oodbupdate_rk(partinfo_temp+i,(partinfo_temp+i)->Id,&tb_descr_Partitioninfo,sizeof(PARTITIONINFO));	}	sem_post(sem);	free(partinfo_temp);		//set Sysinfo table Flag	SYSINFO *sysinfo_temp;	recnum=oodbfind("Node_name",hostname,&tb_descr_Sysinfo);	sysinfo_temp=(struct SYSINFO *)malloc(sizeof(struct SYSINFO)*recnum);	ret=oodbread_ra(sysinfo_temp,"Node_name",hostname,&tb_descr_Sysinfo,sizeof(SYSINFO)*recnum);	sem_wait(sem);	for(i=0;i<recnum;i++)	{			(sysinfo_temp+i)->Flag=1;			ret=oodbupdate_rk(sysinfo_temp+i,(sysinfo_temp+i)->Node_name,&tb_descr_Sysinfo,sizeof(SYSINFO));	}	sem_post(sem);	free(sysinfo_temp);		//set Pthreadinfo table Flag	PTHREADINFO *pthreadinfo_temp;	recnum=oodbfind("Node_name",hostname,&tb_descr_Pthreadinfo);	pthreadinfo_temp=(struct PTHREADINFO *)malloc(sizeof(struct PTHREADINFO)*recnum);	ret=oodbread_ra(pthreadinfo_temp,"Node_name",hostname,&tb_descr_Pthreadinfo,sizeof(PTHREADINFO)*recnum);	sem_wait(sem);	for(i=0;i<recnum;i++)	{			(pthreadinfo_temp+i)->Flag=1;			ret=oodbupdate_rk(pthreadinfo_temp+i,(pthreadinfo_temp+i)->Id,&tb_descr_Pthreadinfo,sizeof(PTHREADINFO));	}	sem_post(sem);	free(pthreadinfo_temp);		//set Netinfo table Flag	NETINFO *netinfo_temp;	recnum=oodbfind("Node_name",hostname,&tb_descr_Netinfo);	netinfo_temp=(struct NETINFO *)malloc(sizeof(struct NETINFO)*recnum);	ret=oodbread_ra(netinfo_temp,"Node_name",hostname,&tb_descr_Netinfo,sizeof(NETINFO)*recnum);	sem_wait(sem);	for(i=0;i<recnum;i++)	{			(netinfo_temp+i)->Flag=1;			ret=oodbupdate_rk(netinfo_temp+i,(netinfo_temp+i)->Id,&tb_descr_Netinfo,sizeof(NETINFO));	}	sem_post(sem);	free(pthreadinfo_temp);	}void check_status(){	char hostname[10];	int ret;	node_num=oodbget_recnum(&tb_descr_Nodeinfo);	nodeinfo_ptr=(NODE_INFO *)malloc(sizeof(struct NODE_INFO)*node_num);		//printf("node_num is %d^^^^^^^^^^^^^^\n",node_num);	for(int i=0;i<node_num;i++)	{		ret = oodbread_rph((void *)(nodeinfo_ptr+i),i,&tb_descr_Nodeinfo,sizeof(NODE_INFO));		if (ret == OO_FAIL)		{			printf("check_status:read nodeinfo table failed!\n");		}	}	while(1)	{		for(int i=0;i<node_num;i++)		{			(nodeinfo_ptr+i)->Node_ticks++;			if((nodeinfo_ptr+i)->Node_ticks==3)			{				(nodeinfo_ptr+i)->Node_status=1;				printf("the client %s is not alive!\n",(nodeinfo_ptr+i)->Node_name);				if(setinfotable((nodeinfo_ptr+i)->Node_name)==-1)				{					printf("check_status:setinfotable failed!\n");					continue;				}			}			if((nodeinfo_ptr+i)->Node_ticks>100000)				(nodeinfo_ptr+i)->Node_ticks=100000;		}		sleep(moni_interval);	}}

⌨️ 快捷键说明

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