From: Heidi N. <hei...@us...> - 2005-04-06 15:43:26
|
Update of /cvsroot/sblim/cmpi-base In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12058 Modified Files: CHANGE.LOG README.INDICATION cmpiOSBase_OperatingSystem.c cmpiOSBase_OperatingSystemProvider.c Log Message: ported OperatingSystem'S process indication of OperationalStatus to become a life-cycle indication Index: cmpiOSBase_OperatingSystemProvider.c =================================================================== RCS file: /cvsroot/sblim/cmpi-base/cmpiOSBase_OperatingSystemProvider.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- cmpiOSBase_OperatingSystemProvider.c 3 Feb 2005 18:19:34 -0000 1.11 +++ cmpiOSBase_OperatingSystemProvider.c 6 Apr 2005 15:43:16 -0000 1.12 @@ -374,7 +374,7 @@ #ifndef NOEVENTS -#define INDCLASSNAME "Linux_OperatingSystemIndication" +#define INDCLASSNAME "CIM_InstModification" #define INDNAMESPACE "root/cimv2" #define IND_NUMBER_OF_DYNAMIC_PROPERTIES 5 @@ -384,6 +384,10 @@ static int ind_OperationalStatus = 2; +static CMPIInstance *sourceInstance = NULL; +static CMPIInstance *previousInstance = NULL; + + IndErrorT CIM_Indication_IndicationIdentifier(CMPIData *v) { CMPIString *str; @@ -391,7 +395,7 @@ _OSBASE_TRACE(1,("--- %s CIM_Indication_IndicationIdentifier() called",_ClassName)); - str = CMNewString(_broker,_ClassName, &rc); + str = CMNewString(_broker,INDCLASSNAME,&rc); v->type = CMPI_string; v->value.string = str; v->state = CMPI_goodValue; @@ -429,44 +433,57 @@ return IND_OK; } -IndErrorT Linux_OperatingSystemIndication_Name(CMPIData *v) +IndErrorT CIM_InstModification_SourceInstance(CMPIData *v) { - CMPIString *str = NULL; CMPIStatus rc; - _OSBASE_TRACE(1,("--- %s Linux_OperatingSystemIndication_Name() called",_ClassName)); + _OSBASE_TRACE(1,("--- %s CIM_InstModification_SourceInstance() called",_ClassName)); - str = CMNewString(_broker,get_system_name(), &rc); - v->type = CMPI_string; - v->value.string = str; + v->type = CMPI_instance; + v->value.inst = CMClone(sourceInstance,&rc); v->state = CMPI_goodValue; return IND_OK; } -IndErrorT Linux_OperatingSystemIndication_OperationalStatus(CMPIData *v) +IndErrorT CIM_InstModification_PreviousInstance(CMPIData *v) { - CMPIString *str = NULL; CMPIStatus rc; - _OSBASE_TRACE(1,("--- %s Linux_OperatingSystemIndication_OperationalStatus() called",_ClassName)); + _OSBASE_TRACE(1,("--- %s CIM_InstModification_PreviousInstance() called",_ClassName)); - if(ind_OperationalStatus==2) { str = CMNewString(_broker,"OK", &rc); } - if(ind_OperationalStatus==4) { str = CMNewString(_broker,"Stressed", &rc); } - - v->type = CMPI_string; - v->value.string = str; + v->type = CMPI_instance; + v->value.inst = CMClone(previousInstance,&rc); v->state = CMPI_goodValue; return IND_OK; } + IndErrorT check(CMPIData *v) { + CMPIObjectPath *cop = NULL; + CMPIStatus rc; + _OSBASE_TRACE(1,("--- %s check() called",_ClassName)); /* call function to check OperationalStatus */ ind_new = check_OperationalStatus(&ind_OperationalStatus); + if(ind_new!=0) + _OSBASE_TRACE(2,("--- %s check(): Event occured",_ClassName)); + + if(previousInstance) { + CMRelease(previousInstance); + previousInstance=NULL; + } + if(sourceInstance) { + previousInstance = CMClone(sourceInstance,&rc); + CMRelease(sourceInstance); + sourceInstance=NULL; + } + + cop = CMNewObjectPath( _broker,INDNAMESPACE,_ClassName,&rc); + sourceInstance = CMClone(_makeInst_OperatingSystem(_broker,NULL,cop,NULL,&rc),&rc); v->state = CMPI_goodValue; v->type = CMPI_uint16; @@ -483,8 +500,8 @@ {"IndicationIdentifier", "CorrelatedIndications", "IndicationTime", - "Name", - "OperationalStatus" + "SourceInstance", + "PreviousInstance" }; /* The list of property functions */ @@ -492,20 +509,27 @@ {CIM_Indication_IndicationIdentifier, CIM_Indication_CorrelatedIndications, CIM_Indication_IndicationTime, - Linux_OperatingSystemIndication_Name, - Linux_OperatingSystemIndication_OperationalStatus + CIM_InstModification_SourceInstance, + CIM_InstModification_PreviousInstance }; static void ind_init(CMPIContext *ctx) { + CMPIObjectPath *cop = NULL; + CMPIStatus rc; + if (ind_inited==0) { _OSBASE_TRACE(1,("--- %s ind_init() called",_ClassName)); - + + cop = CMNewObjectPath( _broker,INDNAMESPACE,_ClassName,&rc); + sourceInstance = CMClone(_makeInst_OperatingSystem(_broker,NULL,cop,NULL,&rc),&rc); + /* register the broker and context */ if(ind_reg(_broker, ctx) != IND_OK) { _OSBASE_TRACE(1,("--- %s ind_init() failed",_ClassName)); + CMRelease(sourceInstance); return; } @@ -515,6 +539,7 @@ check, 10) != IND_OK) { _OSBASE_TRACE(1,("--- %s ind_init() failed: register poll function",_ClassName)); + CMRelease(sourceInstance); return; } @@ -524,6 +549,7 @@ Linux_OperatingSystemIndication_DYNAMIC_FUNCTIONS, IND_NUMBER_OF_DYNAMIC_PROPERTIES) != IND_OK) { _OSBASE_TRACE(1,("--- %s ind_init() failed: register functions of dynamic properties",_ClassName)); + CMRelease(sourceInstance); return; } @@ -532,6 +558,7 @@ INDCLASSNAME, INDCLASSNAME) != IND_OK) { _OSBASE_TRACE(1,("--- %s ind_init() failed: set connection between poll function and dynamic properties",_ClassName)); + CMRelease(sourceInstance); return; } @@ -547,6 +574,8 @@ CMPIContext * ctx) { _OSBASE_TRACE(1,("--- %s CMPI IndicationCleanup() called",_ClassName)); + CMRelease(sourceInstance); + CMRelease(previousInstance); ind_shutdown(); ind_inited = 0; ind_enabled = 0; @@ -631,7 +660,7 @@ if (strcasecmp(indType,INDCLASSNAME)==0) { if(ind_unreg_select(INDNAMESPACE, INDCLASSNAME, filter) == IND_OK) { - _OSBASE_TRACE(1,("--- %s CMPI ActivateFilter() exited: filter deactivated",_ClassName)); + _OSBASE_TRACE(1,("--- %s CMPI DeActivateFilter() exited: filter deactivated",_ClassName)); CMReturn(CMPI_RC_OK); } } Index: CHANGE.LOG =================================================================== RCS file: /cvsroot/sblim/cmpi-base/CHANGE.LOG,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- CHANGE.LOG 6 Apr 2005 15:17:27 -0000 1.13 +++ CHANGE.LOG 6 Apr 2005 15:43:16 -0000 1.14 @@ -61,5 +61,7 @@ * updated README.INDICATION with better description and sample for openPegasus * restructured init process for SBLIM tracing into a file +* ported OperatingSystem's process indication of OperationalStatus + to become a life-cycle indication // =================================================================== Index: README.INDICATION =================================================================== RCS file: /cvsroot/sblim/cmpi-base/README.INDICATION,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- README.INDICATION 17 Mar 2005 08:39:53 -0000 1.2 +++ README.INDICATION 6 Apr 2005 15:43:16 -0000 1.3 @@ -28,11 +28,9 @@ - install the SBLIM package indication_helper. Please follow the instructions in the package. - remove -DNOEVENTS from the CFLAGS (makefile) -- enable the class definition of Linux_OperatingSystemIndication in the - mof/Linux_Base.mof file - for PEGASUS: - edit mof/makefile.pegasus to enable the registration of the Indication - class and provider + class and provider (SimpleDisplayConsumerR.mof, Linux_BaseIndicationReg.mof) - now build the cmpi-base package as described in the README Index: cmpiOSBase_OperatingSystem.c =================================================================== RCS file: /cvsroot/sblim/cmpi-base/cmpiOSBase_OperatingSystem.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- cmpiOSBase_OperatingSystem.c 3 Feb 2005 18:19:34 -0000 1.14 +++ cmpiOSBase_OperatingSystem.c 6 Apr 2005 15:43:16 -0000 1.15 @@ -145,9 +145,9 @@ unsigned long user, system, nice, idle; FILE * fcpuinfo = fopen("/proc/stat","r"); if (cps && fcpuinfo) { - fscanf(fcpuinfo,"%*s %ld %ld %ld %ld",&user,&system,&nice,&idle); + fscanf(fcpuinfo,"%*s %ld %ld %ld %ld",&user,&nice,&system,&idle); fclose(fcpuinfo); - cps->total=user+system+nice+idle; + cps->total=user+system+idle; cps->cpu=cps->total - idle; return 0; } @@ -172,6 +172,9 @@ CMPIArray * opstat = NULL; unsigned short status = 2; /* Enabled */ unsigned short opstatval = 2; /* 2 ... OK ; 4 ... Stressed */ +#ifndef NOEVENTS + int opval = 2; +#endif #endif _OSBASE_TRACE(2,("--- _makeOS() called")); @@ -221,7 +224,7 @@ free(keys); /* calculate cpu percentage */ - if(getcpu(&cs) == 0) { pctcpu = 100*cs.cpu/cs.total; } + if(getcpu(&cs) == 0) { pctcpu = (100*cs.cpu)/cs.total; } CMSetProperty( ci, "CSCreationClassName", CSCreationClassName, CMPI_chars ); CMSetProperty( ci, "CSName", get_system_name(), CMPI_chars ); @@ -306,7 +309,12 @@ goto exit; } else { +#ifndef NOEVENTS + check_OperationalStatus(&opval); + opstatval = opval; +#else if( pctcpu > 90 ) { opstatval = 4; } +#endif CMSetArrayElementAt(opstat,0,(CMPIValue*)&(opstatval),CMPI_uint16); CMSetProperty( ci, "OperationalStatus", (CMPIValue*)&(opstat), CMPI_uint16A); } @@ -336,7 +344,9 @@ if(getcpu(&cs) == 0) { pctcpu = 100*cs.cpu/cs.total; + _OSBASE_TRACE(2,("--- _check_OperationalStatus value : %d",pctcpu)); if(pctcpu>=90 && *OperationalStatus!=4) { + // if(pctcpu>=10 && *OperationalStatus!=4) { *OperationalStatus = 4; return 1; } |