📄 cimperf.cpp
字号:
//%2006//////////////////////////////////////////////////////////////////////////// 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.// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; Symantec 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.////==============================================================================////%//////////////////////////////////////////////////////////////////////////////* This is a simplistic display program for the CIMOM performance characteristics. This version simply gets the instances of the performace class and displays the resulting average counts. TODO KS 1. Convert to use the correct class when it is available. 2. Get the header information from the class, not fixed. 3. Keep history and present so that there is a total 4. Do Total so that we have overall counts. 5. Do percentages*/#include <Pegasus/Common/Config.h>#include <Pegasus/Common/PegasusAssert.h>#include <stdlib.h>#include <Pegasus/Client/CIMClient.h>#include <Pegasus/Common/HTTPConnector.h>#include <Pegasus/Common/OptionManager.h>#include <Pegasus/Common/FileSystem.h>#include <Pegasus/Common/CIMDateTime.h>#include <Pegasus/Common/PegasusVersion.h>#include <Pegasus/Common/StatisticalData.h>PEGASUS_USING_PEGASUS;PEGASUS_USING_STD;const String DEFAULT_NAMESPACE = "root/cimv2";// The table on the right represents the mapping from the enumerated types// in the CIM_CIMOMStatisticalDate class ValueMap versus the internal// message type defined in Message.h.//const char* _OPERATION_NAME[] ={ // Enumerated ValueMap Value // value from from class // internal CIM_StatisticalData // StatisticalData // --------------- ------------------- "GetClass", // 0 3 "GetInstance", // 1 4 "IndicationDelivery", // 2 26 "DeleteClass", // 3 5 "DeleteInstance", // 4 6 "CreateClass", // 5 7 "CreateInstance", // 6 8 "ModifyClass", // 7 9 "ModifyInstance", // 8 10 "EnumerateClasses", // 9 11 "EnumerateClassNames", // 10 12 "EnumerateInstances", // 11 13 "EnumerateInstanceNames", // 12 14 "ExecQuery", // 13 15 "Associators", // 14 16 "AssociatorNames", // 15 17 "References", // 16 18 "ReferenceNames", // 17 19 "GetProperty", // 18 20 "SetProperty", // 19 21 "GetQualifier", // 20 22 "SetQualifier", // 21 23 "DeleteQualifier", // 22 24 "EnumerateQualifiers", // 23 25 "InvokeMethod" // 24 Not Present, use // 1 "Other"};//------------------------------------------------------------------------------//// _indent()////------------------------------------------------------------------------------static void _indent(PEGASUS_STD(ostream)& os, Uint32 level, Uint32 indentSize){ Uint32 n = level * indentSize; if (n > 50) { cout << "Jumped Ship " << level << " size " << indentSize << endl; exit(1); } for (Uint32 i = 0; i < n; i++) os << ' ';}void mofFormat( PEGASUS_STD(ostream)& os, const char* text, Uint32 indentSize){ char* var = new char[strlen(text)+1]; char* tmp = strcpy(var, text); Uint32 count = 0; Uint32 indent = 0; Boolean quoteState = false; Boolean qualifierState = false; char c; char prevchar='\0'; while ((c = *tmp++) != '\0') { count++; // This is too simplistic and must move to a token based mini parser // but will do for now. One problem is tokens longer than 12 characters // that overrun the max line length. switch (c) { case '\n': os << Sint8(c); prevchar = c; count = 0 + (indent * indentSize); _indent(os, indent, indentSize); break; case '\"': // quote os << Sint8(c); prevchar = c; quoteState = !quoteState; break; case ' ': os << Sint8(c); prevchar = c; if (count > 66) { if (quoteState) { os << "\"\n"; _indent(os, indent + 1, indentSize); os <<"\""; } else { os <<"\n"; _indent(os, indent + 1, indentSize); } count = 0 + ((indent + 1) * indentSize); } break; case '[': if (prevchar == '\n') { indent++; _indent(os, indent, indentSize); qualifierState = true; } os << Sint8(c); prevchar = c; break; case ']': if (qualifierState) { if (indent > 0) indent--; qualifierState = false; } os << Sint8(c); prevchar = c; break; default: os << Sint8(c); prevchar = c; } } delete [] var;}/* Method to build an OptionManager object - which holds and organizes options and the properties */void GetOptions( OptionManager& om, int& argc, char** argv, const String& testHome){ static const char* outputFormats[] = { "xml", "mof", "txt"}; static const Uint32 NUM_OUTPUTFORMATS = sizeof(outputFormats) / sizeof(outputFormats[0]); static struct OptionRow optionsTable[] = //The values in the OptionRows below are: //optionname, defaultvalue, is required, type, domain, domainsize, flag, // hlpmsg { {"port", "5988", false, Option::INTEGER, 0, 0, "p", "specifies port"}, {"location", "localhost", false, Option::STRING, 0, 0, "h", "specifies hostname of system"}, {"version", "false", false, Option::BOOLEAN, 0, 0, "-version", "Displays software Version "}, {"help", "false", false, Option::BOOLEAN, 0, 0, "-help", "Prints help message with command line options "}, {"user name","",false,Option::STRING, 0, 0, "u", "specifies user loging in"}, {"password","",false,Option::STRING, 0, 0, "w", "login password for user"}, }; const Uint32 NUM_OPTIONS = sizeof(optionsTable) / sizeof(optionsTable[0]); om.registerOptions(optionsTable, NUM_OPTIONS); //We want to make this code common to all of the commands String configFile = "/CLTest.conf"; if (FileSystem::exists(configFile)) { om.mergeFile(configFile); } om.mergeCommandLine(argc, argv); om.checkRequiredOptions();}/* Method that maps from operation type to operation name. */const char* opTypeToOpName(Uint16 type){ const char* opName = NULL; switch (type) { case 3: opName = _OPERATION_NAME[StatisticalData::GET_CLASS]; break; case 4: opName = _OPERATION_NAME[StatisticalData::GET_INSTANCE]; break; case 5: opName = _OPERATION_NAME[StatisticalData::DELETE_CLASS]; break; case 6: opName = _OPERATION_NAME[StatisticalData::DELETE_INSTANCE]; break; case 7: opName = _OPERATION_NAME[StatisticalData::CREATE_CLASS]; break; case 8: opName = _OPERATION_NAME[StatisticalData::CREATE_INSTANCE]; break; case 9: opName = _OPERATION_NAME[StatisticalData::MODIFY_CLASS]; break; case 10: opName = _OPERATION_NAME[StatisticalData::MODIFY_INSTANCE]; break; case 11: opName = _OPERATION_NAME[StatisticalData::ENUMERATE_CLASSES]; break; case 12: opName = _OPERATION_NAME[StatisticalData::ENUMERATE_CLASS_NAMES]; break; case 13: opName = _OPERATION_NAME[StatisticalData::ENUMERATE_INSTANCES]; break; case 14: opName = _OPERATION_NAME[StatisticalData::ENUMERATE_INSTANCE_NAMES]; break; case 15: opName = _OPERATION_NAME[StatisticalData::EXEC_QUERY]; break; case 16: opName = _OPERATION_NAME[StatisticalData::ASSOCIATORS]; break; case 17: opName = _OPERATION_NAME[StatisticalData::ASSOCIATOR_NAMES]; break; case 18: opName = _OPERATION_NAME[StatisticalData::REFERENCES]; break; case 19: opName = _OPERATION_NAME[StatisticalData::REFERENCE_NAMES]; break; case 20: opName = _OPERATION_NAME[StatisticalData::GET_PROPERTY]; break; case 21: opName = _OPERATION_NAME[StatisticalData::SET_PROPERTY]; break; case 22: opName = _OPERATION_NAME[StatisticalData::GET_QUALIFIER]; break; case 23: opName = _OPERATION_NAME[StatisticalData::SET_QUALIFIER];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -