(file) Return to CIMOMStatDataProvider.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ControlProviders / Statistic

File: [Pegasus] / pegasus / src / Pegasus / ControlProviders / Statistic / CIMOMStatDataProvider.cpp (download)
Revision: 1.3, Thu Jul 1 01:36:04 2004 UTC (20 years ago) by w.white
Branch: MAIN
CVS Tags: RELEASE_2_4_FC_CANDIDATE_1, MONITOR_CONSOLIDATION_2_5_BRANCH
Changes since 1.2: +121 -40 lines
PEP#: 127

TITLE: Perfomance Statistics for CIM server

Descriiption: made changes to support PEPs 127 and 128

//%2003////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000, 2001, 2002  BMC Software, Hewlett-Packard Development
// Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
// IBM Corp.; EMC Corporation, The Open Group.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//==============================================================================
//
// Author: Arthur Pichlkostner
//             (checked in: Markus Mueller sedgewick_de@yahoo.de)
//
// Modified By:
//
//%/////////////////////////////////////////////////////////////////////////////

#include "CIMOMStatDataProvider.h"

PEGASUS_NAMESPACE_BEGIN

CIMOMStatDataProvider::CIMOMStatDataProvider(void)
{
}

CIMOMStatDataProvider::~CIMOMStatDataProvider(void)
{
}

void CIMOMStatDataProvider::initialize(CIMOMHandle & cimom)
{
   for (Uint32 i=0; i<StatisticalData::length; i++){
      char buffer[32];
      sprintf(buffer, "%d", i);
      _references[i] = CIMObjectPath(
        "CIM_CIMOMStatisticalData.InstanceID=\"CIM_CIMOMStatisticalData"+String(buffer)+"\"");
   }

}

void CIMOMStatDataProvider::terminate(void)
{
   delete this;
}

void CIMOMStatDataProvider::getInstance(
	const OperationContext & context,
	const CIMObjectPath & instanceReference,
        const Boolean includeQualifiers,
        const Boolean includeClassOrigin,
        const CIMPropertyList & propertyList,
	InstanceResponseHandler & handler)
{
	CIMObjectPath localReference = CIMObjectPath(
		String::EMPTY,
		CIMNamespaceName(),
		instanceReference.getClassName(),
		instanceReference.getKeyBindings());

	// begin processing the request
	handler.processing();

	// instance index corresponds to reference index
	for(Uint32 i = 0; i < StatisticalData::NUMBER_OF_TYPES; i++)
	{ // cout << "loop" << endl;
		if(localReference == _references[i])
		{
			// deliver requested instance
			handler.deliver(getInstance(i));
			break;
		}
	}

	// complete processing the request
	handler.complete();
}

void CIMOMStatDataProvider::enumerateInstances(
	const OperationContext & context,
	const CIMObjectPath & classReference,
        const Boolean includeQualifiers,
        const Boolean includeClassOrigin,
        const CIMPropertyList & propertyList,
	InstanceResponseHandler & handler)
{
    // begin processing the request
	handler.processing();

	// instance index corresponds to reference index
	for(Uint32 i = 0; i < StatisticalData::NUMBER_OF_TYPES; i++)
	{
	   // deliver instance
		handler.deliver(getInstance(i));
		
	}

//	printf("have all the instances\n");
	// complete processing the request
	handler.complete();
}

void CIMOMStatDataProvider::enumerateInstanceNames(
	const OperationContext & context,
	const CIMObjectPath & classReference,
	ObjectPathResponseHandler & handler)
{
	// begin processing the request
	handler.processing();

	for(Uint32 i = 0; i < StatisticalData::NUMBER_OF_TYPES; i++)
	{
		// deliver reference
		handler.deliver(_references[i]);
	}

	// complete processing the request
	handler.complete();
}

void CIMOMStatDataProvider::modifyInstance(
	const OperationContext & context,
	const CIMObjectPath & instanceReference,
	const CIMInstance & instanceObject,
        const Boolean includeQualifiers,
        const CIMPropertyList & propertyList,
	ResponseHandler & handler)
{
	throw CIMNotSupportedException("StatisticalData::modifyInstance");
}

void CIMOMStatDataProvider::createInstance(
	const OperationContext & context,
	const CIMObjectPath & instanceReference,
	const CIMInstance & instanceObject,
	ObjectPathResponseHandler & handler)
{
	throw CIMNotSupportedException("StatisticalData::createInstance");
}

void CIMOMStatDataProvider::deleteInstance(
	const OperationContext & context,
	const CIMObjectPath & instanceReference,
	ResponseHandler & handler)
{
throw CIMNotSupportedException("StatisticalData::deleteInstance");
}

CIMInstance CIMOMStatDataProvider::getInstance(Uint16 type)
{

   StatisticalData* sd = StatisticalData::current();
   char buffer[32];
   sprintf(buffer, "%u", type);

   checkObjectManager();

   CIMDateTime cimom_time = toDateTime(sd->cimomTime[type]);
   CIMDateTime provider_time = toDateTime(sd->providerTime[type]);
   Uint16 mof_type = getOpType(type);

   //printf("this is returned form getOpType %d\n",mof_type);

   CIMInstance requestedInstance("CIM_CIMOMStatisticalData");
   requestedInstance.addProperty(CIMProperty("InstanceID",
      CIMValue("CIM_CIMOMStatisticalData"+String(buffer))));
   requestedInstance.addProperty(CIMProperty("OperationType",
      CIMValue(mof_type)));
   requestedInstance.addProperty(CIMProperty("NumberOfOperations",
      CIMValue((Uint64)sd->numCalls[type])));
   requestedInstance.addProperty(CIMProperty("CimomElapsedTime",
      CIMValue(cimom_time)));
   requestedInstance.addProperty(CIMProperty("ProviderElapsedTime",
      CIMValue(provider_time)));
   requestedInstance.addProperty(CIMProperty("RequestSize",
      CIMValue((Uint64)sd->requestSize[type])));
   requestedInstance.addProperty(CIMProperty("ResponseSize",
      CIMValue((Uint64)sd->responseSize[type])));
   requestedInstance.addProperty(CIMProperty("ElementName",
      CIMValue(StatisticalData::requestName[type])));
   requestedInstance.addProperty( CIMProperty("Description",
      CIMValue(String("CIMOM performance statistics for CIM request "))));
   requestedInstance.addProperty(CIMProperty("Caption",
      CIMValue(String("CIMOM performance statistics for CIM request"))));
   

   return requestedInstance;
}


CIMDateTime CIMOMStatDataProvider::toDateTime(Sint64 date)
{

        //break millisecond value into days, hours, minutes, seconds and milliseconds
        //turn each number into a string and append them to each other

        Sint64 ndays = floor (date/86400000000);        //one day = 8.64*10^10 millisecond
        Sint64 rem = date % 86400000000;                //rem_1 is remander of above operation
        char buf_day[8];
        sprintf(buf_day,"%08d",ndays);

String test = String(buf_day);


        Sint64 nhour = floor (rem/3600000000);  //one hour = 3.6*10^9 milliseconds
        Sint64 rem_2 = rem%3600000000;    //rem_2 is remander of above operation
        char buf_hour[2];
        sprintf(buf_hour,"%02d",nhour);

String hour = String(buf_hour);
String dh = test.append(String(buf_hour));
//printf("this is test now after append\n");// %s\n", test.getCString());

        Sint64 nmin = floor (rem_2/60000000);  // one minute = 6*10^7
        Sint64 rem_3 = rem_2%60000000;
        char buf_minute[2];
        sprintf(buf_minute,"%02d",nmin);

String dhm = dh.append(String(buf_minute));
//printf("after second append this is test %s\n", test.getCString());

        Sint64 nsecond = floor (rem_3/1000000); //one second = 10^6 milliseconds
        char buf_second[2];
        sprintf(buf_second,"%02d",nsecond);

String dhms = dhm.append(String(buf_second));
//printf("after third append this is test\n");// %s \n",test.getCString());


        Sint64 nmilsec = rem_3%1000000;
        char buf_milsec[11];
        sprintf(buf_milsec,".%06d:000",nmilsec);

//printf("this is milsec -\n");// %s",buf_milsec);

String dhmsm = dhms.append(String(buf_milsec));
	CIMDateTime ans(dhmsm);

        return ans;

}

void CIMOMStatDataProvider::checkObjectManager()
{
	
	StatisticalData* sData = StatisticalData::current();

	if (!sData->copyGSD)
	{  //set all values to 0 if CIM_ObjectManager is False

		for (Uint16 i=0; i<StatisticalData::length; i++)
		{
		  sData->numCalls[i] = 0;
		  sData->cimomTime[i] = 0;      
		  sData->providerTime[i] = 0;
		  sData->responseSize[i] = 0;
		  sData->requestSize[i] = 0;
		}
//		printf("just set all tha values of StatistcalData to 0\n");

	}

//	printf("at the end of the checkObjectManager func\n");
}




Uint16 CIMOMStatDataProvider::getOpType(Uint16 type)
{
	Uint16 ty, outType;
// the rang of operation types is defined in Message.cpp as 1-113. For operation types
// with values grater then 39 fourty is subtracted (in StatisticalData.h and Message.cpp

// This conversion makes make the OperationType attribute of the CIM_CIMOMStatisticalData
// instances agree with DMTF spec.
		


	ty = type;

 	if ((ty==0) || (ty==1))
 		{outType = type+3;
	//	printf("ty was 0 or 1\n");
	}
 
 	else if ((ty >=3) && (ty <= 23))
 		{outType = ty + 2;
	//	printf("ty was between 3 and 23\n");
	}
 
 	else if ((ty == 2) || ((ty > 23) && (ty < 73)))
 		{ outType = 1;
	//	printf("ty was between 32 and 73 or it was 2\n");
	}
 
 	else 
 	{ outType = 0;
	//printf("ty was out of this world\n");
	}

//	printf("about to return form getOpType\n");
	return outType;
}


PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2