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

  1 karl  1.19 //%2006////////////////////////////////////////////////////////////////////////
  2 w.white 1.1  //
  3 karl    1.9  // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4              // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5              // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6 w.white 1.1  // IBM Corp.; EMC Corporation, The Open Group.
  7 karl    1.9  // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8              // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl    1.12 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10              // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl    1.19 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12              // EMC Corporation; Symantec Corporation; The Open Group.
 13 w.white 1.1  //
 14              // Permission is hereby granted, free of charge, to any person obtaining a copy
 15              // of this software and associated documentation files (the "Software"), to
 16              // deal in the Software without restriction, including without limitation the
 17              // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18              // sell copies of the Software, and to permit persons to whom the Software is
 19              // furnished to do so, subject to the following conditions:
 20 ms.aruran 1.22 //
 21 w.white   1.1  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22                // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23                // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24                // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25                // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26                // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27                // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28                // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29                //
 30                //==============================================================================
 31                //
 32                //%/////////////////////////////////////////////////////////////////////////////
 33                
 34                #include "CIMOMStatDataProvider.h"
 35 kumpf     1.15 #include <Pegasus/Common/PegasusVersion.h>
 36 karl      1.6  
 37                PEGASUS_USING_STD;
 38 w.white   1.1  PEGASUS_NAMESPACE_BEGIN
 39                
 40 w.white   1.5  CIMOMStatDataProvider::CIMOMStatDataProvider()
 41 w.white   1.1  {
 42 dave.sudlik 1.23     for (Uint32 i=0; i<StatisticalData::length; i++)
 43                      {
 44                          char buffer[32];
 45 kumpf       1.24         sprintf(buffer, "%u", i);
 46 dave.sudlik 1.23         _references[i] = CIMObjectPath(
 47                              "CIM_CIMOMStatisticalData.InstanceID=\"CIM_CIMOMStatisticalData"+
 48                              String(buffer)+"\"");
 49                      }
 50 w.white     1.7  
 51 w.white     1.1  }
 52                  
 53 w.white     1.5  CIMOMStatDataProvider::~CIMOMStatDataProvider()
 54 w.white     1.1  {
 55                  }
 56                  
 57                  void CIMOMStatDataProvider::getInstance(
 58 dave.sudlik 1.23     const OperationContext & context,
 59                      const CIMObjectPath & instanceReference,
 60                      const Boolean includeQualifiers,
 61                      const Boolean includeClassOrigin,
 62                      const CIMPropertyList & propertyList,
 63                      InstanceResponseHandler & handler)
 64                  {
 65                      CIMObjectPath localReference = CIMObjectPath(
 66                          String::EMPTY,
 67                          CIMNamespaceName(),
 68                          instanceReference.getClassName(),
 69                          instanceReference.getKeyBindings());
 70                  
 71                      // begin processing the request
 72                      handler.processing();
 73 w.white     1.1  
 74 dave.sudlik 1.23     // instance index corresponds to reference index
 75                      for (Uint32 i = 0; i < StatisticalData::NUMBER_OF_TYPES; i++)
 76                      {
 77                          if (localReference == _references[i])
 78                          {
 79                              // deliver requested instance
 80                              handler.deliver(getInstance(i, instanceReference));
 81                              break;
 82                          }
 83                      }
 84                  
 85                      // complete processing the request
 86                      handler.complete();
 87 w.white     1.1  }
 88                  
 89                  void CIMOMStatDataProvider::enumerateInstances(
 90 dave.sudlik 1.23     const OperationContext & context,
 91                      const CIMObjectPath & classReference,
 92                      const Boolean includeQualifiers,
 93                      const Boolean includeClassOrigin,
 94                      const CIMPropertyList & propertyList,
 95                      InstanceResponseHandler & handler)
 96 w.white     1.1  {
 97                      // begin processing the request
 98 dave.sudlik 1.23     handler.processing();
 99                  
100                      // instance index corresponds to reference index
101                      for (Uint32 i = 0; i < StatisticalData::NUMBER_OF_TYPES; i++)
102                      {
103                          // deliver instance
104                          handler.deliver(getInstance(i, classReference));
105                  
106                      }
107 w.white     1.1  
108 dave.sudlik 1.23     // complete processing the request
109                      handler.complete();
110 w.white     1.1  }
111                  
112                  void CIMOMStatDataProvider::enumerateInstanceNames(
113 dave.sudlik 1.23     const OperationContext & context,
114                      const CIMObjectPath & classReference,
115                      ObjectPathResponseHandler & handler)
116                  {
117                      // begin processing the request
118                      handler.processing();
119                  
120                      for (Uint32 i = 0; i < StatisticalData::NUMBER_OF_TYPES; i++)
121                      {
122                          // deliver reference
123                          handler.deliver(_references[i]);
124                      }
125 w.white     1.1  
126 dave.sudlik 1.23     // complete processing the request
127                      handler.complete();
128 w.white     1.1  }
129                  
130                  void CIMOMStatDataProvider::modifyInstance(
131 dave.sudlik 1.23     const OperationContext & context,
132                      const CIMObjectPath & instanceReference,
133                      const CIMInstance & instanceObject,
134                      const Boolean includeQualifiers,
135                      const CIMPropertyList & propertyList,
136                      ResponseHandler & handler)
137 w.white     1.1  {
138 dave.sudlik 1.23     throw CIMNotSupportedException("StatisticalData::modifyInstance");
139 w.white     1.1  }
140                  
141                  void CIMOMStatDataProvider::createInstance(
142 dave.sudlik 1.23     const OperationContext & context,
143                      const CIMObjectPath & instanceReference,
144                      const CIMInstance & instanceObject,
145                      ObjectPathResponseHandler & handler)
146 w.white     1.1  {
147 dave.sudlik 1.23     throw CIMNotSupportedException("StatisticalData::createInstance");
148 w.white     1.1  }
149                  
150                  void CIMOMStatDataProvider::deleteInstance(
151 dave.sudlik 1.23     const OperationContext & context,
152                      const CIMObjectPath & instanceReference,
153                      ResponseHandler & handler)
154 w.white     1.1  {
155 dave.sudlik 1.23     throw CIMNotSupportedException("StatisticalData::deleteInstance");
156 w.white     1.1  }
157                  
158 dave.sudlik 1.23 CIMInstance CIMOMStatDataProvider::getInstance(
159                      Uint16 type, 
160                      CIMObjectPath cimRef)
161 w.white     1.1  {
162                  
163 dave.sudlik 1.23     StatisticalData* sd = StatisticalData::current();
164                      char buffer[32];
165 kumpf       1.24     sprintf(buffer, "%hu", type);
166 w.white     1.1  
167 dave.sudlik 1.23     checkObjectManager();
168 w.white     1.3  
169 dave.sudlik 1.23     CIMDateTime cimom_time = CIMDateTime((sd->cimomTime[type]), true);
170                      CIMDateTime provider_time = CIMDateTime((sd->providerTime[type]), true);
171                      Uint16 mof_type = getOpType(type);
172 w.white     1.1  
173 w.white     1.17 
174 w.white     1.1  
175 dave.sudlik 1.23     CIMInstance requestedInstance("CIM_CIMOMStatisticalData");
176                      requestedInstance.addProperty(CIMProperty("InstanceID",
177                          CIMValue("CIM_CIMOMStatisticalData"+String(buffer))));
178                      requestedInstance.addProperty(CIMProperty("OperationType",
179                          CIMValue(mof_type)));
180                      requestedInstance.addProperty(CIMProperty("NumberOfOperations",
181                          CIMValue((Uint64)sd->numCalls[type])));
182                      requestedInstance.addProperty(CIMProperty("CimomElapsedTime",
183                          CIMValue(cimom_time)));
184                      requestedInstance.addProperty(CIMProperty("ProviderElapsedTime",
185                          CIMValue(provider_time)));
186                      requestedInstance.addProperty(CIMProperty("RequestSize",
187                          CIMValue((Uint64)sd->requestSize[type])));
188                      requestedInstance.addProperty(CIMProperty("ResponseSize",
189                          CIMValue((Uint64)sd->responseSize[type])));
190                      requestedInstance.addProperty( CIMProperty("Description",
191                          CIMValue(String("CIMOM performance statistics for CIM request "))));
192                      requestedInstance.addProperty(CIMProperty("Caption",
193                          CIMValue(String("CIMOM performance statistics for CIM request"))));
194 a.arora     1.8  
195 dave.sudlik 1.23     requestedInstance.setPath(_references[type]);
196 w.white     1.1  
197 dave.sudlik 1.23     return requestedInstance;
198 w.white     1.1  }
199                  
200 w.white     1.14 /*CIMDateTime CIMOMStatDataProvider::toDateTime(Sint64 date)
201 dave.sudlik 1.23 { 
202                      // Break millisecond value into days, hours, minutes, seconds and 
203                      // milliseconds.
204                      // Turn each number into a string and append them to each other.
205 w.white     1.3  
206 dave.sudlik 1.23     const Sint64 oneDay = Sint64(864) * 100000000;
207 w.white     1.4  
208                          Sint64 ndays = date/oneDay;        //one day = 8.64*10^10 millisecond
209 dave.sudlik 1.23         Sint64 rem = date % oneDay;      //rem_1 is remander of above operation
210 karl        1.11         char buf_day[9];
211 w.white     1.10         sprintf(buf_day,"%08d",(int)ndays);
212 w.white     1.3  
213                  String test = String(buf_day);
214                  
215 dave.sudlik 1.23         //one hour = 3.6*10^9 milliseconds
216                          Sint64 nhour = rem/PEGASUS_UINT64_LITERAL(3600000000);  
217                          //rem_2 is remander of above operation
218                          Sint64 rem_2 = rem%PEGASUS_UINT64_LITERAL(3600000000);    
219 karl        1.11         char buf_hour[3];
220 w.white     1.10         sprintf(buf_hour,"%02d",(int)nhour);
221 w.white     1.3  
222                  String hour = String(buf_hour);
223                  String dh = test.append(String(buf_hour));
224                  //printf("this is test now after append\n");// %s\n", test.getCString());
225                  
226 w.white     1.4          Sint64 nmin = rem_2/60000000;  // one minute = 6*10^7
227 w.white     1.3          Sint64 rem_3 = rem_2%60000000;
228 karl        1.11         char buf_minute[3];
229 w.white     1.10         sprintf(buf_minute,"%02d",(int)nmin);
230 w.white     1.3  
231                  String dhm = dh.append(String(buf_minute));
232                  //printf("after second append this is test %s\n", test.getCString());
233                  
234 w.white     1.4          Sint64 nsecond = rem_3/1000000; //one second = 10^6 milliseconds
235 karl        1.11         char buf_second[3];
236 w.white     1.10         sprintf(buf_second,"%02d",(int)nsecond);
237 w.white     1.3  
238                  String dhms = dhm.append(String(buf_second));
239                  //printf("after third append this is test\n");// %s \n",test.getCString());
240                  
241                  
242                          Sint64 nmilsec = rem_3%1000000;
243 karl        1.11         char buf_milsec[20];
244 w.white     1.10         sprintf(buf_milsec,".%06d:000",(int)nmilsec);
245 w.white     1.3  
246                  String dhmsm = dhms.append(String(buf_milsec));
247 karl        1.13     //cout << "String for datetime= " << dhmsm << endl;
248                      CIMDateTime ans;
249                      try
250                      {
251                          ans.set(dhmsm);
252                      }
253                      catch(Exception& e)
254                      {
255 dave.sudlik 1.23         cout << "Error in string convert of " << dhmsm << " " << 
256                              e.getMessage() << endl;;
257 karl        1.13         ans.clear();
258                      }
259 w.white     1.4  //cout<<"this is being passed back for toDateTime" << ans.toString() << endl;
260 w.white     1.3  
261                          return ans;
262                  
263 w.white     1.14 } */
264 w.white     1.3  
265 karl        1.13 
266 w.white     1.3  void CIMOMStatDataProvider::checkObjectManager()
267                  {
268 dave.sudlik 1.23     StatisticalData* sData = StatisticalData::current();
269 ms.aruran   1.22 
270 dave.sudlik 1.23     if (!sData->copyGSD)
271                      {  
272                         //set all values to 0 if CIM_ObjectManager is False
273                  
274                          for (Uint16 i=0; i<StatisticalData::length; i++)
275                          {
276                              sData->numCalls[i] = 0;
277                              sData->cimomTime[i] = 0;
278                              sData->providerTime[i] = 0;
279                              sData->responseSize[i] = 0;
280                              sData->requestSize[i] = 0;
281                          }
282                      }
283 w.white     1.3  }
284                  
285                  
286 ms.aruran   1.22 // This conversion makes make the OperationType attribute of the
287 jim.wunderlich 1.20 // CIM_CIMOMStatisticalData instances agree with DMTF spec.
288 ms.aruran      1.22 // The CIM_StatisticalData class specifys type 0 as "unknown"
289 jim.wunderlich 1.20 // and 1 as "other"
290                     //
291 ms.aruran      1.22 // The internal message types are subject to change so the symblic
292                     // enumerated values are used within a select statement rather than
293                     // a one dimensional array that is simply indexed to determine the
294                     // output type.
295 w.white        1.1  
296 w.white        1.3  Uint16 CIMOMStatDataProvider::getOpType(Uint16 type)
297                     {
298 jim.wunderlich 1.20     Uint16 outType;
299 w.white        1.3  
300 jim.wunderlich 1.20     switch (type)
301                         {
302 dave.sudlik    1.23         case StatisticalData::GET_CLASS:
303                                 outType= 3 ;
304                                 break;
305                     
306                             case StatisticalData::GET_INSTANCE:
307                                 outType= 4;
308                                 break;
309                     
310                             case StatisticalData::INDICATION_DELIVERY:
311                                 outType= 26;
312                                 break;
313                     
314                             case StatisticalData::DELETE_CLASS:
315                                 outType= 5;
316                                 break;
317                     
318                             case StatisticalData::DELETE_INSTANCE:
319                                 outType= 6;
320                                 break;
321                     
322                             case StatisticalData::CREATE_CLASS:
323 dave.sudlik    1.23             outType= 7;
324                                 break;
325                     
326                             case StatisticalData::CREATE_INSTANCE:
327                                 outType= 8;
328                                 break;
329                     
330                             case StatisticalData::MODIFY_CLASS:
331                                 outType= 9;
332                                 break;
333                     
334                             case StatisticalData::MODIFY_INSTANCE:
335                                 outType= 10;
336                                 break;
337                     
338                             case StatisticalData::ENUMERATE_CLASSES:
339                                 outType= 11;
340                                 break;
341                     
342                             case StatisticalData::ENUMERATE_CLASS_NAMES:
343                                 outType= 12;
344 dave.sudlik    1.23             break;
345                     
346                             case StatisticalData::ENUMERATE_INSTANCES:
347                                 outType= 13;
348                                 break;
349                     
350                             case StatisticalData::ENUMERATE_INSTANCE_NAMES:
351                                 outType= 14;
352                                 break;
353                     
354                             case StatisticalData::EXEC_QUERY:
355                                 outType= 15;
356                                 break;
357                     
358                             case StatisticalData::ASSOCIATORS:
359                                 outType= 16;
360                                 break;
361                     
362                             case StatisticalData::ASSOCIATOR_NAMES:
363                                 outType= 17;
364                                 break;
365 dave.sudlik    1.23 
366                             case StatisticalData::REFERENCES:
367                                 outType= 18;
368                                 break;
369                     
370                             case StatisticalData::REFERENCE_NAMES:
371                                 outType= 19;
372                                 break;
373                     
374                             case StatisticalData::GET_PROPERTY:
375                                 outType= 20;
376                                 break;
377                     
378                             case StatisticalData::SET_PROPERTY:
379                                 outType= 21;
380                                 break;
381                     
382                             case StatisticalData::GET_QUALIFIER:
383                                 outType= 22;
384                                 break;
385                     
386 dave.sudlik    1.23         case StatisticalData::SET_QUALIFIER:
387                                 outType= 23;
388                                 break;
389                     
390                             case StatisticalData::DELETE_QUALIFIER:
391                                 outType= 24;
392                                 break;
393                     
394                             case StatisticalData::ENUMERATE_QUALIFIERS:
395                                 outType= 25;
396                                 break;
397                     
398                             case StatisticalData::INVOKE_METHOD:
399                                 outType= 1;
400                                 break;
401 jim.wunderlich 1.20 
402                             default:
403 dave.sudlik    1.23             // This type is unknown so output "Unknown"
404                                 outType=0;
405                                 break;
406 jim.wunderlich 1.20     }
407 w.white        1.1  
408 jim.wunderlich 1.20     return outType;
409 w.white        1.1  }
410                     
411                     PEGASUS_NAMESPACE_END
412 dave.sudlik    1.23     

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2