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

📄 check_status.cxx.bak

📁 HPunix下资源监视程序,查看监视进程的CPU、内存的参数
💻 BAK
字号:
#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;void check_status(int moni_interval){	char hostname[10];	node_num=oodbget_recnum(&tb_descr_Nodeinfo);	nodeinfo_ptr=(NODEINFO *)malloc(sizeof(struct NODEINFO)*node_num);	for(int i=0;i<node_num;i++)	{		(nodeinfo_ptr+i)->ticks=0;		(nodeinfo_ptr+i)->status=0;	}	while(1)	{		for(int i=0;i<node_num;i++)		{			(nodeinfo_ptr+i)->ticks++;			if((nodeinfo_ptr+i)->ticks==3)			{				(nodeinfo_ptr+i)->status=1;				if(setinfotable(hostname)==-1)				{					printf("check_status:setinfotable failed!\n")					continue;				}			}			if((nodeinfo_ptr+i)->ticks>100000;				((nodeinfo_ptr+i)->ticks=100000;		}	}}int setinfotable(char *hostname){	//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)->Id,&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);	}

⌨️ 快捷键说明

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