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 //
21 // 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 // Author: Arthur Pichlkostner
33 // (checked in: Markus Mueller sedgewick_de@yahoo.de)
34 w.white 1.1 //
|
35 a.arora 1.8 // Modified By: Amit K Arora, IBM (amita@in.ibm.com) for Bug#1939
|
36 w.white 1.1 //
37 //%/////////////////////////////////////////////////////////////////////////////
38
39 #include "CIMOMStatDataProvider.h"
40
|
41 kumpf 1.15 #include <Pegasus/Common/PegasusVersion.h>
|
42 jim.wunderlich 1.20 #include <Pegasus/Common/Message.h>
43
|
44 karl 1.6
45 PEGASUS_USING_STD;
|
46 w.white 1.1 PEGASUS_NAMESPACE_BEGIN
47
|
48 w.white 1.5 CIMOMStatDataProvider::CIMOMStatDataProvider()
|
49 w.white 1.1 {
|
50 w.white 1.7 for (Uint32 i=0; i<StatisticalData::length; i++){
51 char buffer[32];
52 sprintf(buffer, "%d", i);
53 _references[i] = CIMObjectPath(
54 "CIM_CIMOMStatisticalData.InstanceID=\"CIM_CIMOMStatisticalData"+String(buffer)+"\"");
55 }
56
|
57 w.white 1.1 }
58
|
59 w.white 1.5 CIMOMStatDataProvider::~CIMOMStatDataProvider()
|
60 w.white 1.1 {
61 }
62
63 void CIMOMStatDataProvider::initialize(CIMOMHandle & cimom)
64 {
|
65 a.arora 1.8 _cimom = cimom;
|
66 w.white 1.1 for (Uint32 i=0; i<StatisticalData::length; i++){
67 char buffer[32];
68 sprintf(buffer, "%d", i);
69 _references[i] = CIMObjectPath(
70 "CIM_CIMOMStatisticalData.InstanceID=\"CIM_CIMOMStatisticalData"+String(buffer)+"\"");
71 }
72
73 }
74
75 void CIMOMStatDataProvider::terminate(void)
76 {
77 delete this;
78 }
79
80 void CIMOMStatDataProvider::getInstance(
81 const OperationContext & context,
82 const CIMObjectPath & instanceReference,
83 const Boolean includeQualifiers,
84 const Boolean includeClassOrigin,
85 const CIMPropertyList & propertyList,
86 InstanceResponseHandler & handler)
87 w.white 1.1 {
88 CIMObjectPath localReference = CIMObjectPath(
89 String::EMPTY,
90 CIMNamespaceName(),
91 instanceReference.getClassName(),
92 instanceReference.getKeyBindings());
93
94 // begin processing the request
95 handler.processing();
96
97 // instance index corresponds to reference index
98 for(Uint32 i = 0; i < StatisticalData::NUMBER_OF_TYPES; i++)
|
99 w.white 1.7 { //cout << "this is what we are looking at " << _references[i].toString() <<endl <<endl;
|
100 w.white 1.1 if(localReference == _references[i])
101 {
102 // deliver requested instance
|
103 a.arora 1.8 handler.deliver(getInstance(i, instanceReference));
|
104 w.white 1.1 break;
105 }
106 }
107
108 // complete processing the request
109 handler.complete();
110 }
111
112 void CIMOMStatDataProvider::enumerateInstances(
113 const OperationContext & context,
114 const CIMObjectPath & classReference,
115 const Boolean includeQualifiers,
116 const Boolean includeClassOrigin,
117 const CIMPropertyList & propertyList,
118 InstanceResponseHandler & handler)
119 {
120 // begin processing the request
121 handler.processing();
122
123 // instance index corresponds to reference index
124 for(Uint32 i = 0; i < StatisticalData::NUMBER_OF_TYPES; i++)
125 w.white 1.1 {
126 // deliver instance
|
127 a.arora 1.8 handler.deliver(getInstance(i, classReference));
|
128 w.white 1.3
|
129 w.white 1.1 }
130
|
131 w.white 1.3 // printf("have all the instances\n");
|
132 w.white 1.1 // complete processing the request
133 handler.complete();
134 }
135
136 void CIMOMStatDataProvider::enumerateInstanceNames(
137 const OperationContext & context,
138 const CIMObjectPath & classReference,
139 ObjectPathResponseHandler & handler)
140 {
141 // begin processing the request
142 handler.processing();
143
144 for(Uint32 i = 0; i < StatisticalData::NUMBER_OF_TYPES; i++)
145 {
146 // deliver reference
147 handler.deliver(_references[i]);
148 }
149
150 // complete processing the request
151 handler.complete();
152 }
153 w.white 1.1
154 void CIMOMStatDataProvider::modifyInstance(
155 const OperationContext & context,
156 const CIMObjectPath & instanceReference,
157 const CIMInstance & instanceObject,
158 const Boolean includeQualifiers,
159 const CIMPropertyList & propertyList,
160 ResponseHandler & handler)
161 {
162 throw CIMNotSupportedException("StatisticalData::modifyInstance");
163 }
164
165 void CIMOMStatDataProvider::createInstance(
166 const OperationContext & context,
167 const CIMObjectPath & instanceReference,
168 const CIMInstance & instanceObject,
169 ObjectPathResponseHandler & handler)
170 {
171 throw CIMNotSupportedException("StatisticalData::createInstance");
172 }
173
174 w.white 1.1 void CIMOMStatDataProvider::deleteInstance(
175 const OperationContext & context,
176 const CIMObjectPath & instanceReference,
177 ResponseHandler & handler)
178 {
179 throw CIMNotSupportedException("StatisticalData::deleteInstance");
180 }
181
|
182 a.arora 1.8 CIMInstance CIMOMStatDataProvider::getInstance(Uint16 type, CIMObjectPath cimRef)
|
183 w.white 1.1 {
184
185 StatisticalData* sd = StatisticalData::current();
186 char buffer[32];
187 sprintf(buffer, "%u", type);
188
|
189 w.white 1.3 checkObjectManager();
190
|
191 w.white 1.14 CIMDateTime cimom_time = CIMDateTime((sd->cimomTime[type]), true);
192 CIMDateTime provider_time = CIMDateTime((sd->providerTime[type]), true);
|
193 w.white 1.3 Uint16 mof_type = getOpType(type);
|
194 w.white 1.1
|
195 w.white 1.17
|
196 w.white 1.1
197 CIMInstance requestedInstance("CIM_CIMOMStatisticalData");
198 requestedInstance.addProperty(CIMProperty("InstanceID",
199 CIMValue("CIM_CIMOMStatisticalData"+String(buffer))));
200 requestedInstance.addProperty(CIMProperty("OperationType",
|
201 w.white 1.3 CIMValue(mof_type)));
202 requestedInstance.addProperty(CIMProperty("NumberOfOperations",
203 CIMValue((Uint64)sd->numCalls[type])));
|
204 w.white 1.1 requestedInstance.addProperty(CIMProperty("CimomElapsedTime",
205 CIMValue(cimom_time)));
206 requestedInstance.addProperty(CIMProperty("ProviderElapsedTime",
207 CIMValue(provider_time)));
208 requestedInstance.addProperty(CIMProperty("RequestSize",
|
209 w.white 1.3 CIMValue((Uint64)sd->requestSize[type])));
|
210 w.white 1.1 requestedInstance.addProperty(CIMProperty("ResponseSize",
|
211 w.white 1.3 CIMValue((Uint64)sd->responseSize[type])));
|
212 w.white 1.1 requestedInstance.addProperty(CIMProperty("ElementName",
213 CIMValue(StatisticalData::requestName[type])));
214 requestedInstance.addProperty( CIMProperty("Description",
|
215 w.white 1.3 CIMValue(String("CIMOM performance statistics for CIM request "))));
|
216 w.white 1.1 requestedInstance.addProperty(CIMProperty("Caption",
|
217 w.white 1.3 CIMValue(String("CIMOM performance statistics for CIM request"))));
|
218 a.arora 1.8
|
219 denise.eckstein 1.18 requestedInstance.setPath(_references[type]);
|
220 w.white 1.1
|
221 w.white 1.7 //cout << "at the end of getinstance of CIMOMStat" << endl;
|
222 w.white 1.1 return requestedInstance;
223 }
224
|
225 w.white 1.14 /*CIMDateTime CIMOMStatDataProvider::toDateTime(Sint64 date)
|
226 w.white 1.1 {
|
227 w.white 1.3 //break millisecond value into days, hours, minutes, seconds and milliseconds
228 //turn each number into a string and append them to each other
229
|
230 w.white 1.4 const Sint64 oneDay = Sint64(864) * 100000000;
231
232 Sint64 ndays = date/oneDay; //one day = 8.64*10^10 millisecond
233 Sint64 rem = date % oneDay; //rem_1 is remander of above operation
|
234 karl 1.11 char buf_day[9];
|
235 w.white 1.10 sprintf(buf_day,"%08d",(int)ndays);
|
236 w.white 1.3
237 String test = String(buf_day);
238
239
|
240 w.white 1.10 Sint64 nhour = rem/PEGASUS_UINT64_LITERAL(3600000000); //one hour = 3.6*10^9 milliseconds
241 Sint64 rem_2 = rem%PEGASUS_UINT64_LITERAL(3600000000); //rem_2 is remander of above operation
|
242 karl 1.11 char buf_hour[3];
|
243 w.white 1.10 sprintf(buf_hour,"%02d",(int)nhour);
|
244 w.white 1.3
245 String hour = String(buf_hour);
246 String dh = test.append(String(buf_hour));
247 //printf("this is test now after append\n");// %s\n", test.getCString());
248
|
249 w.white 1.4 Sint64 nmin = rem_2/60000000; // one minute = 6*10^7
|
250 w.white 1.3 Sint64 rem_3 = rem_2%60000000;
|
251 karl 1.11 char buf_minute[3];
|
252 w.white 1.10 sprintf(buf_minute,"%02d",(int)nmin);
|
253 w.white 1.3
254 String dhm = dh.append(String(buf_minute));
255 //printf("after second append this is test %s\n", test.getCString());
256
|
257 w.white 1.4 Sint64 nsecond = rem_3/1000000; //one second = 10^6 milliseconds
|
258 karl 1.11 char buf_second[3];
|
259 w.white 1.10 sprintf(buf_second,"%02d",(int)nsecond);
|
260 w.white 1.3
261 String dhms = dhm.append(String(buf_second));
262 //printf("after third append this is test\n");// %s \n",test.getCString());
263
264
265 Sint64 nmilsec = rem_3%1000000;
|
266 karl 1.11 char buf_milsec[20];
|
267 w.white 1.10 sprintf(buf_milsec,".%06d:000",(int)nmilsec);
|
268 w.white 1.3
269 String dhmsm = dhms.append(String(buf_milsec));
|
270 karl 1.13 //cout << "String for datetime= " << dhmsm << endl;
271 CIMDateTime ans;
272 try
273 {
274 ans.set(dhmsm);
275 }
276 catch(Exception& e)
277 {
278 cout << "Error in string convert of " << dhmsm << " " << e.getMessage() << endl;;
279 ans.clear();
280 }
|
281 w.white 1.4 //cout<<"this is being passed back for toDateTime" << ans.toString() << endl;
|
282 w.white 1.3
283 return ans;
284
|
285 w.white 1.14 } */
|
286 w.white 1.3
|
287 karl 1.13
|
288 w.white 1.3 void CIMOMStatDataProvider::checkObjectManager()
289 {
|
290 w.white 1.1
|
291 w.white 1.3 StatisticalData* sData = StatisticalData::current();
292
293 if (!sData->copyGSD)
294 { //set all values to 0 if CIM_ObjectManager is False
295
296 for (Uint16 i=0; i<StatisticalData::length; i++)
297 {
298 sData->numCalls[i] = 0;
299 sData->cimomTime[i] = 0;
300 sData->providerTime[i] = 0;
301 sData->responseSize[i] = 0;
302 sData->requestSize[i] = 0;
303 }
304 // printf("just set all tha values of StatistcalData to 0\n");
305
306 }
307
308 // printf("at the end of the checkObjectManager func\n");
309 }
310
311
|
312 jim.wunderlich 1.20 // The range of operation types is defined in Message.h as 1-113.
313 // For operation types with values grater than 39, forty is subtracted
314 // (in StatisticalData.h and Message.cpp
315 //
316 // This conversion makes make the OperationType attribute of the
317 // CIM_CIMOMStatisticalData instances agree with DMTF spec.
318 // The CIM_StatisticalData class specifys type 0 as "unknown"
319 // and 1 as "other"
320 //
321 // The internal message types are subject to change so the symblic
322 // enumerated values are used within a select statement rather than
323 // a one dimensional array that is simply indexed to determine the
324 // output type.
|
325 w.white 1.1
|
326 w.white 1.3 Uint16 CIMOMStatDataProvider::getOpType(Uint16 type)
327 {
|
328 jim.wunderlich 1.20 Uint16 outType;
|
329 w.white 1.3
330
|
331 jim.wunderlich 1.20 switch (type)
332 {
333 case DUMMY_MESSAGE:
334 outType=0;
335 break;
336
337 case CIM_GET_CLASS_REQUEST_MESSAGE:
338 outType= 3 ;
339 break;
340
341 case CIM_GET_INSTANCE_REQUEST_MESSAGE:
342 outType= 4;
343 break;
344
345 case CIM_DELETE_CLASS_REQUEST_MESSAGE:
346 outType= 5;
347 break;
348
349 case CIM_DELETE_INSTANCE_REQUEST_MESSAGE:
350 outType= 6;
351 break;
352 jim.wunderlich 1.20
353 case CIM_CREATE_CLASS_REQUEST_MESSAGE:
354 outType= 7;
355 break;
356
357 case CIM_CREATE_INSTANCE_REQUEST_MESSAGE:
358 outType= 8;
359 break;
360
361 case CIM_MODIFY_CLASS_REQUEST_MESSAGE:
362 outType= 9;
363 break;
364
365 case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE:
366 outType= 10;
367 break;
368
369 case CIM_ENUMERATE_CLASSES_REQUEST_MESSAGE:
370 outType= 11;
371 break;
372
373 jim.wunderlich 1.20 case CIM_ENUMERATE_CLASS_NAMES_REQUEST_MESSAGE:
374 outType= 12;
375 break;
376
377 case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE:
378 outType= 13;
379 break;
380
381 case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE:
382 outType= 14;
383 break;
384
385 case CIM_EXEC_QUERY_REQUEST_MESSAGE:
386 outType= 15;
387 break;
388
389 case CIM_ASSOCIATORS_REQUEST_MESSAGE:
390 outType= 16;
391 break;
392
393 case CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE:
394 jim.wunderlich 1.20 outType= 17;
395 break;
396
397 case CIM_REFERENCES_REQUEST_MESSAGE:
398 outType= 18;
399 break;
400
401 case CIM_REFERENCE_NAMES_REQUEST_MESSAGE:
402 outType= 19;
403 break;
404
405 case CIM_GET_PROPERTY_REQUEST_MESSAGE:
406 outType= 20;
407 break;
408
409 case CIM_SET_PROPERTY_REQUEST_MESSAGE:
410 outType= 21;
411 break;
412
413 case CIM_GET_QUALIFIER_REQUEST_MESSAGE:
414 outType= 22;
415 jim.wunderlich 1.20 break;
416
417 case CIM_SET_QUALIFIER_REQUEST_MESSAGE:
418 outType= 23;
419 break;
420
421 case CIM_DELETE_QUALIFIER_REQUEST_MESSAGE:
422 outType= 24;
423 break;
424
425 case CIM_ENUMERATE_QUALIFIERS_REQUEST_MESSAGE:
426 outType= 25;
427 break;
428
429 case CIM_EXPORT_INDICATION_REQUEST_MESSAGE:
430 outType= 26;
431 break;
432
433 case CIM_INVOKE_METHOD_REQUEST_MESSAGE:
434 outType= 1;
435 break;
436 jim.wunderlich 1.20
437 default:
438 // If this is a response type then ouput "other"
439 if (type < CIM_DELETE_SUBSCRIPTION_RESPONSE_MESSAGE)
440 outType=1;
441 else
442 // This type is unknown so output "Unknown"
443 outType=0;
444 break;
|
445 w.white 1.3
446
|
447 jim.wunderlich 1.20 }
|
448 w.white 1.1
|
449 jim.wunderlich 1.20 // printf("about to return form getOpType type = %d, outType = %d\n",type, outType);
450 return outType;
|
451 w.white 1.1 }
452
453
454 PEGASUS_NAMESPACE_END
|