From: Tyrel D. <ty...@us...> - 2011-12-23 01:53:47
|
Update of /cvsroot/sblim/gather/plugin In directory vz-cvs-3.sog:/tmp/cvs-serv22257/plugin Modified Files: metricUnixProcess.c Log Message: Rejected 3098510: add process name to UnixProcessMetric (reverted to revision 1.13 of metricUnixProcess) Index: metricUnixProcess.c =================================================================== RCS file: /cvsroot/sblim/gather/plugin/metricUnixProcess.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- metricUnixProcess.c 18 Oct 2011 22:38:43 -0000 1.17 +++ metricUnixProcess.c 23 Dec 2011 01:53:45 -0000 1.18 @@ -38,8 +38,6 @@ #include <sys/types.h> #include <dirent.h> -#define BUFSIZE 1024 - /* ---------------------------------------------------------------------------*/ static MetricDefinition metricDef[6]; @@ -172,8 +170,6 @@ char * ptr = NULL; char * end = NULL; char * hlp = NULL; - char procname[BUFSIZE]; - char resname[2*BUFSIZE]; char buf[4096]; char os_buf[4096]; int _enum_size = 0; @@ -223,16 +219,8 @@ strcat(buf,_enum_pid + (i*64)); strcat(buf,"/stat"); if( (fhd = fopen(buf,"r")) != NULL ) { - fscanf(fhd,"%s %s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %lld %lld", - &resname, - &procname, + fscanf(fhd,"%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %lld %lld", &u_time,&k_time ); - - /* remove parens from procname and concatenate as "pid.procname" */ - procname[0] = '.'; - procname[strlen(procname) - 1] = 0; - strcat(resname, procname); - fclose(fhd); } @@ -242,7 +230,7 @@ mv = calloc( 1, sizeof(MetricValue) + (strlen(buf)+1) + - (strlen(resname)+1) ); + (strlen(_enum_pid+(i*64))+1) ); if (mv) { mv->mvId = mid; mv->mvTimeStamp = time(NULL); @@ -251,7 +239,7 @@ mv->mvData = (char*)mv + sizeof(MetricValue); strncpy( mv->mvData, buf, strlen(buf) ); mv->mvResource = (char*)mv + sizeof(MetricValue) + (strlen(buf)+1); - strcpy(mv->mvResource,resname); + strcpy(mv->mvResource,_enum_pid+(i*64)); mret(mv); } } @@ -272,8 +260,6 @@ MetricValue * mv = NULL; FILE * fhd = NULL; char * _enum_pid = NULL; - char resname[2*BUFSIZE]; - char procname[BUFSIZE]; char buf[254]; int _enum_size = 0; int i = 0; @@ -302,24 +288,16 @@ strcat(buf,_enum_pid + (i*64)); strcat(buf,"/stat"); if( (fhd = fopen(buf,"r")) != NULL ) { - fscanf(fhd,"%s %s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s " + fscanf(fhd,"%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s " "%*s %*s %*s %*s %*s %*s %*s %*s %*s %lld %*s", - &resname, - &procname, &rss); - - /* remove parens from procname and concatenate as "pid.procname" */ - procname[0] = '.'; - procname[strlen(procname) - 1] = 0; - strcat(resname, procname); - fclose(fhd); size = rss * sysconf(_SC_PAGESIZE); } mv = calloc( 1, sizeof(MetricValue) + sizeof(unsigned long long) + - (strlen(resname)+1) ); + (strlen(_enum_pid + (i*64))+1) ); if (mv) { mv->mvId = mid; mv->mvTimeStamp = time(NULL); @@ -328,7 +306,7 @@ mv->mvData = (char*)mv + sizeof(MetricValue); *(unsigned long long *)mv->mvData = htonll(size); mv->mvResource = (char*)mv + sizeof(MetricValue) + sizeof(unsigned long long); - strcpy(mv->mvResource,resname); + strcpy(mv->mvResource,_enum_pid + (i*64)); mret(mv); } } @@ -349,8 +327,6 @@ MetricValue * mv = NULL; FILE * fhd = NULL; char * _enum_pid = NULL; - char resname[2*BUFSIZE]; - char procname[BUFSIZE]; char buf[254]; int _enum_size = 0; int i = 0; @@ -379,22 +355,14 @@ strcat(buf,"/stat"); if( (fhd = fopen(buf,"r")) != NULL ) { fscanf(fhd, - "%s %s %*s %*s %*s %*s %*s %*s %*s %*s %*s %lld", - &resname, - &procname, + "%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %lld", &page); - - /* remove parens from procname and concatenate as "pid.procname" */ - procname[0] = '.'; - procname[strlen(procname) - 1] = 0; - strcat(resname, procname); - fclose(fhd); } mv = calloc( 1, sizeof(MetricValue) + sizeof(unsigned long long) + - (strlen(resname)+1) ); + (strlen(_enum_pid + (i*64))+1) ); if (mv) { mv->mvId = mid; mv->mvTimeStamp = time(NULL); @@ -403,7 +371,7 @@ mv->mvData = (char*)mv + sizeof(MetricValue); *(unsigned long long*)mv->mvData = htonll(page); mv->mvResource = (char*)mv + sizeof(MetricValue) + sizeof(unsigned long long); - strcpy(mv->mvResource,resname); + strcpy(mv->mvResource,_enum_pid + (i*64)); mret(mv); } } @@ -424,8 +392,6 @@ MetricValue * mv = NULL; FILE * fhd = NULL; char * _enum_pid = NULL; - char resname[2*BUFSIZE]; - char procname[BUFSIZE]; char buf[254]; int _enum_size = 0; int i = 0; @@ -454,24 +420,16 @@ strcat(buf,"/stat"); if( (fhd = fopen(buf,"r")) != NULL ) { fscanf(fhd, - "%s %s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s " + "%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s " "%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s " "%*s %*s %*s %*s %lld", - &resname, - &procname, &page); - - /* remove parens from procname and concatenate as "pid.procname" */ - procname[0] = '.'; - procname[strlen(procname) - 1] = 0; - strcat(resname, procname); - fclose(fhd); } mv = calloc( 1, sizeof(MetricValue) + sizeof(unsigned long long) + - (strlen(resname)+1) ); + (strlen(_enum_pid + (i*64))+1) ); if (mv) { mv->mvId = mid; mv->mvTimeStamp = time(NULL); @@ -480,7 +438,7 @@ mv->mvData = (char*)mv + sizeof(MetricValue); *(unsigned long long*)mv->mvData = htonll(page); mv->mvResource = (char*)mv + sizeof(MetricValue) + sizeof(unsigned long long); - strcpy(mv->mvResource,resname); + strcpy(mv->mvResource,_enum_pid + (i*64)); mret(mv); } } @@ -501,8 +459,6 @@ MetricValue * mv = NULL; FILE * fhd = NULL; char * _enum_pid = NULL; - char resname[2*BUFSIZE]; - char procname[BUFSIZE]; char buf[254]; int _enum_size = 0; int i = 0; @@ -529,23 +485,15 @@ strcat(buf,_enum_pid + (i*64)); strcat(buf,"/stat"); if( (fhd = fopen(buf,"r")) != NULL ) { - fscanf(fhd,"%s %s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s " + fscanf(fhd,"%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s " "%*s %*s %*s %*s %*s %*s %*s %*s %lld", - &resname, - &procname, &size); - - /* remove parens from procname and concatenate as "pid.procname" */ - procname[0] = '.'; - procname[strlen(procname) - 1] = 0; - strcat(resname, procname); - fclose(fhd); } mv = calloc( 1, sizeof(MetricValue) + sizeof(unsigned long long) + - (strlen(resname)+1) ); + (strlen(_enum_pid + (i*64))+1) ); if (mv) { mv->mvId = mid; mv->mvTimeStamp = time(NULL); @@ -554,7 +502,7 @@ mv->mvData = (char*)mv + sizeof(MetricValue); *(unsigned long long *)mv->mvData = htonll(size); mv->mvResource = (char*)mv + sizeof(MetricValue) + sizeof(unsigned long long); - strcpy(mv->mvResource,resname); + strcpy(mv->mvResource,_enum_pid + (i*64)); mret(mv); } } @@ -575,8 +523,6 @@ MetricValue * mv = NULL; FILE * fhd = NULL; char * _enum_pid = NULL; - char resname[2*BUFSIZE]; - char procname[BUFSIZE]; char buf[254]; int _enum_size = 0; int i = 0; @@ -608,26 +554,11 @@ fclose(fhd); } - memset(buf,0,sizeof(buf)); - strcpy(buf,"/proc/"); - strcat(buf,_enum_pid + (i*64)); - strcat(buf,"/stat"); - if ((fhd = fopen(buf,"r")) != NULL) { - fscanf(fhd,"%s %s", &resname, &procname); - - /* remove parens from procname and concatenate as "pid.procname" */ - procname[0] = '.'; - procname[strlen(procname) - 1] = 0; - strcat(resname, procname); - - fclose(fhd); - } - size = size * sysconf(_SC_PAGESIZE); mv = calloc( 1, sizeof(MetricValue) + sizeof(unsigned long long) + - (strlen(resname)+1) ); + (strlen(_enum_pid + (i*64))+1) ); if (mv) { mv->mvId = mid; mv->mvTimeStamp = time(NULL); @@ -636,7 +567,7 @@ mv->mvData = (char*)mv + sizeof(MetricValue); *(unsigned long long *)mv->mvData = htonll(size); mv->mvResource = (char*)mv + sizeof(MetricValue) + sizeof(unsigned long long); - strcpy(mv->mvResource,resname); + strcpy(mv->mvResource,_enum_pid + (i*64)); mret(mv); } } |