From: Viktor M. <mih...@us...> - 2005-05-31 14:28:36
|
Update of /cvsroot/sblim/cmpi-base In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20526 Modified Files: AUTHORS ChangeLog NEWS OSBase_OperatingSystem.c OSBase_UnixProcess.c README configure.ac Log Message: Bugs fixed: 1211913 UnixProcess data extraction and formatting. 1198184 implemented Ferenc Szalai's suggestion for release determination. Index: configure.ac =================================================================== RCS file: /cvsroot/sblim/cmpi-base/configure.ac,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- configure.ac 11 May 2005 11:40:08 -0000 1.6 +++ configure.ac 31 May 2005 14:28:08 -0000 1.7 @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT(SBLIM BaseOS Providers Base, 1.5.0a, sbl...@li...,sblim-cmpi-base) +AC_INIT(SBLIM BaseOS Providers Base, 1.5.1, sbl...@li...,sblim-cmpi-base) AC_CONFIG_SRCDIR([OSBase_Common.c]) AC_CONFIG_HEADER([config.h]) AM_INIT_AUTOMAKE Index: ChangeLog =================================================================== RCS file: /cvsroot/sblim/cmpi-base/ChangeLog,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- ChangeLog 12 May 2005 15:15:07 -0000 1.8 +++ ChangeLog 31 May 2005 14:28:08 -0000 1.9 @@ -1,3 +1,11 @@ +2005-05-31 <mih...@dy...> + + * OSBase_UnixProcess.c: + Bug 1211913: Fixed the UnixProcess field formatting problems. + Uses ps -p <pid> to retrieve single process data now. + Process name is determined using basename and brackets are stripped + from kernel daemons. + 2005-05-12 <mih...@dy...> * provider-register.sh: Updated for OpenWBEM support. Index: README =================================================================== RCS file: /cvsroot/sblim/cmpi-base/README,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- README 20 Apr 2005 11:34:56 -0000 1.12 +++ README 31 May 2005 14:28:08 -0000 1.13 @@ -110,8 +110,8 @@ Load Schema into CIMOM's repository ................................... -with Pegasus : -.............. +with Pegasus / OpenWBEM /sfcb : +............................... The loading and registering of the classes/associations and their provider is done during the "make postinstall". Index: NEWS =================================================================== RCS file: /cvsroot/sblim/cmpi-base/NEWS,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- NEWS 12 May 2005 15:15:07 -0000 1.4 +++ NEWS 31 May 2005 14:28:08 -0000 1.5 @@ -6,3 +6,4 @@ - 1199449 Fixed compile problem with new indication_helper 0.4.0 . - 1198184 Fixed release determination logic. - 1183805 Added support for OpenWBEM provider registration. +- 1211913 Fixed UnixProcess Name, State and Argument field scanning and formatting. Index: OSBase_OperatingSystem.c =================================================================== RCS file: /cvsroot/sblim/cmpi-base/OSBase_OperatingSystem.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- OSBase_OperatingSystem.c 12 May 2005 15:15:07 -0000 1.18 +++ OSBase_OperatingSystem.c 31 May 2005 14:28:08 -0000 1.19 @@ -13,6 +13,7 @@ * Author: Heidi Neumann <hei...@de...> * Contributors: Viktor Mihajlovski <mih...@de...> * C. Eric Wu <cw...@us...> + * Ferenc Szalai <sz...@ei...> * * Description: * This shared library provides resource access functionality for the class @@ -125,6 +126,7 @@ char * get_os_distro() { char ** hdout = NULL; char * ptr = NULL; + char * cmd = NULL; int strl = 0; int i = 0; int rc = 0; @@ -133,25 +135,40 @@ _OSBASE_TRACE(4,("--- get_os_distro() called : init")); - rc = runcommand( "cat `find /etc/ -type f -maxdepth 1 -name *release* 2>/dev/null`" , NULL , &hdout , NULL ); - if( rc == 0 ) { - while ( hdout[i]) { - strl = strl+strlen(hdout[i])+1; - ptr = strchr(hdout[i], '\n'); + rc = runcommand( "find /etc/ -type f -maxdepth 1 -name *release* 2>/dev/null" , NULL , &hdout , NULL ); + if( rc == 0 && hdout != NULL && hdout[0] && strcmp (hdout[0], "") ) { + strl = strlen ("cat 2>/dev/null") + strlen (hdout[0]) + 1; + ptr = strchr(hdout[0], '\n'); + if (ptr) { *ptr = '\0'; + } + cmd = calloc (strl, sizeof(char)); + snprintf(cmd, strl, "cat %s 2>/dev/null", hdout[0]); + freeresultbuf(hdout); + hdout = NULL; + strl = 0; + rc = runcommand(cmd, NULL , &hdout , NULL ); + if( rc == 0 ) { + while ( hdout[i]) { + strl = strl+strlen(hdout[i])+1; + ptr = strchr(hdout[i], '\n'); + if (ptr) { + *ptr = '\0'; + } + i++; + } + i=0; + CIM_OS_DISTRO = calloc(1,strl); + strcpy( CIM_OS_DISTRO , hdout[0] ); i++; - } - i=0; - CIM_OS_DISTRO = calloc(1,strl); - strcpy( CIM_OS_DISTRO , hdout[0] ); - i++; - while ( hdout[i]) { - strcat( CIM_OS_DISTRO , " " ); - strcat( CIM_OS_DISTRO , hdout[i] ); - i++; + while ( hdout[i]) { + strcat( CIM_OS_DISTRO , " " ); + strcat( CIM_OS_DISTRO , hdout[i] ); + i++; + } } - } - else { + free (cmd); + } else { CIM_OS_DISTRO = calloc(1,6); strcpy( CIM_OS_DISTRO , "Linux" ); } Index: OSBase_UnixProcess.c =================================================================== RCS file: /cvsroot/sblim/cmpi-base/OSBase_UnixProcess.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- OSBase_UnixProcess.c 24 Jan 2005 12:05:52 -0000 1.11 +++ OSBase_UnixProcess.c 31 May 2005 14:28:08 -0000 1.12 @@ -30,6 +30,7 @@ #include <fcntl.h> #include <errno.h> #include <dirent.h> +#include <libgen.h> #include <sys/stat.h> #include <sys/wait.h> #include <sys/time.h> @@ -59,7 +60,7 @@ _OSBASE_TRACE(3,("--- enum_all_process() called")); - rc = runcommand( "ps --no-headers -eo pid,ppid,tty,pri,nice,uid,gid,pmem,pcpu,cputime,comm,session,state,args" , NULL, &hdout, NULL ); + rc = runcommand( "ps --no-headers -eo pid,ppid,tty,pri,nice,uid,gid,pmem,pcpu,cputime,session,state,args" , NULL, &hdout, NULL ); if( rc == 0 ) { lptrhelp = (struct processlist *)calloc(1,sizeof(struct processlist)); @@ -91,17 +92,10 @@ _OSBASE_TRACE(3,("--- get_process_data() called")); - cmd = (char*)malloc((strlen(pid)+7)); - strcpy(cmd, "/proc/"); - strcat(cmd, pid); - dpid=opendir(cmd); - if(cmd) free(cmd); - - if ( dpid != NULL ) { - cmd = (char*)malloc((strlen(pid)+95)); - strcpy(cmd, "ps --no-headers -eo pid,ppid,tty,pri,nice,uid,gid,pmem,pcpu,cputime,comm,session,state | grep "); - strcat(cmd, pid); + cmd = (char*)malloc((strlen(pid)+100)); + sprintf(cmd, "ps -p %s --no-headers -eo pid,ppid,tty,pri,nice,uid,gid,pmem,pcpu,cputime,session,state,args",pid); rc = runcommand( cmd , NULL, &hdout, NULL ); + if (rc == 0) { while( hdout[i] ) { if((ptr=strchr(hdout[i], '\n'))) { *ptr = '\0'; } str = hdout[i]; @@ -126,11 +120,9 @@ static int _process_data( char * phd , struct cim_process ** sptr ){ char ** parr = NULL; - char ** hdout = NULL; char * d = NULL; char * end = NULL; char * cmd = NULL; - char * ptr = NULL; FILE * fpstat = NULL; struct tm tmdate; unsigned long long kmtime = 0; // Kernel Mode Time @@ -170,8 +162,7 @@ (*sptr)->pmem = atoll(parr[7]); (*sptr)->pcpu = atol(parr[8]); - (*sptr)->pcmd = strdup(parr[10]); - (*sptr)->sid = atoll(parr[11]); + (*sptr)->sid = atoll(parr[10]); /* state of Linux processes : D uninterruptible sleep (usually IO) = Blocked (4) @@ -192,34 +183,19 @@ * 8 ... Stopped * 9 ... Growing */ - if(strcmp(parr[12],"R")==0) + if(strcmp(parr[11],"R")==0) (*sptr)->state = 3 ; - else if( strcmp(parr[12],"D")==0) + else if( strcmp(parr[11],"D")==0) (*sptr)->state = 4 ; - else if( strcmp(parr[12],"S")==0) + else if( strcmp(parr[11],"S")==0) (*sptr)->state = 6 ; - else if( strcmp(parr[12],"Z")==0) + else if( strcmp(parr[11],"Z")==0) (*sptr)->state = 7 ; - else if( strcmp(parr[12],"T")==0) + else if( strcmp(parr[11],"T")==0) (*sptr)->state = 8 ; /* values for array of Parameters */ - if( parr[13] == NULL ) { - cmd = (char*)malloc((strlen((*sptr)->pid)+28)); - memset(cmd, 0, (strlen((*sptr)->pid)+28)); - strcpy(cmd, "ps -p"); - strcat(cmd, (*sptr)->pid); - strcat(cmd, " --no-headers -o args"); - rc = runcommand( cmd, NULL, &hdout, NULL ); - if((ptr=strchr(hdout[0], '\n'))) { *ptr = '\0'; } - if( rc == 0 ) { - (*sptr)->args = line_to_array( hdout[0], ' ' ); - } - if(cmd) free(cmd); - freeresultbuf(hdout); - } - else { - i=13; + i=12; j=0; (*sptr)->args = calloc(100,sizeof(char*)); while(( parr[i] != NULL ) && (i < 100)) /* preventing buffer overflows */ { @@ -228,8 +204,12 @@ j++; i++; } + if (parr[12][0]=='[' && parr[12][strlen(parr[12])-1]==']') { + (*sptr)->pcmd = calloc(strlen(parr[12])-1,1); + strncpy((*sptr)->pcmd,parr[12]+1,strlen(parr[12])-2); + } else { + (*sptr)->pcmd = strdup(basename(parr[12])); } - freeresultbuf(parr); /* ModulePath */ @@ -288,7 +268,7 @@ buf = (char*)malloc(1024); memset(buf, 0, 1024); - rc = readlink(path, buf, sizeof(buf)); + rc = readlink(path, buf, 1024); if( rc == -1 ) { free(buf); buf = strdup(cmd); Index: AUTHORS =================================================================== RCS file: /cvsroot/sblim/cmpi-base/AUTHORS,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- AUTHORS 20 Apr 2005 11:34:55 -0000 1.2 +++ AUTHORS 31 May 2005 14:28:08 -0000 1.3 @@ -6,3 +6,6 @@ support for class Linux_OperatingSytemStatisticalData and the association Linux_OperatingSystemStatistics was done by Michael Schuele <sch...@de...> ... thx :) + +bugfix for release determination if no /etc/*release* file is found has +been suggested by Ferenc Szalai <sz...@ei...> |