#ifndef _HOST_H_ #define _HOST_H_ #pragma once /* class host { public: host(void); public: virtual ~host(void); }; */ /* $Id: //depot/tools/main/performance/perfstat_cluster/src/host.hpp#36 $ */ #ifdef WIN32 #include #include #include #include #include #else #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "boost/filesystem/path.hpp" #include #include #include "parallelhost.hpp" using namespace std; /********************** DEFINES ****************************************/ #define HOST_NAME_MAX_SIZE 1024 #define HOST_EXE_PATH_LOC_SIZE 5 #define D_CMD_TIMEOUT 70000 #define MSINFO32 "%CommonProgramFiles%\\Microsoft Shared\\MSInfo\\msinfo32.exe" #define BUFSIZE 4096 #define STR_ORACLE_DEFAULT_LOGIN "sys/sys as sysdba" #define STR_SQL_PLUS "sqlplus" #define STR_ITERATION "Iteration: " #define STR_BEGIN_ITER "BEGIN Iteration" #define STR_END_ITER "END Iteration" #define STR_INFO "INFO" #define STR_ERROR "ERROR" #define STR_WARNING "WARNING" #define STR_STATUS "STATUS" #define STR_PROCESSING_CMD "Processing command -- " #define STR_BEGIN_ITER_NUM "Begin Iteration number: " #define STR_END_ITER_NUM "End Iteration number: " #define STR_PERF_EPOCH "\nPERFSTAT_EPOCH: " #define STR_START_PRESTAT "Starting processing of PRESTATS commands." #define STR_FINISH_PRESTAT "Finished processing of PRESTATS commands." #define STR_START_POSTSTAT "Starting processing of POSTSTATS commands." #define STR_FINISH_POSTSTAT "Finished processing of POSTSTATS commands." #define STR_BEGIN_PRESTATS "BEGIN PRESTATS" #define STR_END_PRESTATS "END PRESTATS" #define STR_BEGIN_POSTSTATS "BEGIN POSTSTATS" #define STR_END_POSTSTATS "END POSTSTATS" #define STR_PRESTATS "PRESTATS" #define STR_POSTSTATS "POSTSTATS" #define STR_ORACLE_BEGIN "Oracle AWR report Begin" #define STR_ORACLE_END "Oracle AWR report End" #define STR_HEADER_DESIGN "=-=-=-=-=-= " #define SAFE_DELETE(x) if(x != NULL){delete x; x = NULL;} #define SAFE_ARRAY_DELETE(x) if(x != NULL){delete[] x; x = NULL;} /*********************** CONSTs ***************************************/ //const int cmdRunTime = 120; // 2mins // Do we really need this const int NUM_HOST_SPECIFIC_PATHS = 5; const string fileId = "temp"; // Do we really need this const int opt_cmd_timeout=D_CMD_TIMEOUT; // Do we really need this const int HOST_LOCAL = 1; const int HOST_REMOTE = 2; const int HOST_NONE = 3; class host { public: host(){}; virtual ~host(void); host(presetHandler, CLIHandler*, outputHandler*, int nHostType = HOST_LOCAL); // This is the Function that is called from the node to process the // Host commands void ProcessCommands(int iterNum, boost::barrier *serThreadBar = NULL); // Gets the complete command with the paths added void GetCommand(string& strCmd, presetMetaData pMetaData); // Flag that suggests whether SSH is supported or not bool IsSSHSupported(); string* GetHostSpecificString(); void closeHostFile(); virtual bool ProcessCommand(string command, bool pWriteToFile , ofstream* pFilePtr , vector* v = NULL, connectionHandler* pConnectionHandle = NULL, string strFileName = "temp_file_0", bool bParallel = false) {return "";} string GetOSType(); virtual bool ExecCommand(string strCommand, connectionHandler* pConnectionHandle = NULL){return false;} bool isTempHostFile(string); bool isRHEL5(); // Added BURT_562755 int getNumberOfParallelCommands(); // POSTSTATS bool processPoststats(boost::barrier *serThreadBar, int niterationNumber); // PARALLEL COMMANDS bool StartParallelThread(boost::barrier *serThreadBar = NULL); void setQuickPoststatsRunFlag(bool val); bool getQuickPoststatsRunFlag(); protected: bool ProcessHostCommands(const vector& prestatCommands, bool bquickFlag = false); bool GetOutputFromFile(string fileName, bool bWriteToTemp, ofstream *pFilePtr, vector *vec_strRes); void ProcessPresetCommand(presetMetaData presetInfo); int execCommand(string); virtual bool RemoveFileFromHost(string strFile){return true;} // Most inlined here in Header, need to remove these virtual string GetHostOSType() {return "";} virtual void GenerateSnapFiles(){} virtual void GenerateAwrReportFile(string strFile){} virtual void ProcessParallelData( boost::barrier *parThreadBar, presetMetaData *metaData, string threadId = ""); void ProcessTimer(int* maxTime); void killRshOrSshProcess(); // Need to kill rsh/ssh process launced for host/remotehost data collection // Oracle string m_strHostName; int m_HostType; // Local or Remote Host .. Shd change this to enum in future bool m_bIsSSHSupported; // Is SSH Supported or not string m_strHostType; // Type of the Remote Host string m_strAwrSnapFileName; string m_strSnapShotFileName; CParallelHost** m_pParallelHost; vector m_vecStrlongerRuntimeCmd; presetHandler m_pPresetHandle; // Preset Handler CLIHandler* m_pCLIHandle; // CLI Handler outputHandler* m_pOutputHandle; outputHandler* m_pCommonOutputHandle; controller* m_pSeqController; vector longerRuntimeCmd; ofstream* m_pTempFilePtr; connectionHandler* m_pConnectionHandle; // Actually this should be in Remost host..should look aftr /********************* STATIC MEMBERS ********************************************/ static boost::mutex host_move_mutex; string* m_pStrHostSpecificPaths; // For Completing the command with the path of the Executables bool m_bConfigJustOnce; // Configuration commands should be run once or more bool bRHEL5; // Linux Version int m_nIterationNumber; // Iteration Number int m_nHistoCount; // Total number of samples int m_nHistoInterval; // Sample interval int m_nHistoTotalSecs; // Sample time in seconds // Oracle bool m_bSysDBAFlag; // Should run as Sys DBA or not bool m_bOraclePresent; // Checks whether Oracle is installed on the system or not int m_nBeginID; // Begin ID int m_nEndID; // End ID string m_strOracleLogin; // Oracle Login Creds string m_strRunAsUser; // Run as string m_strSqlPlus; // SQL PLUS command private: bool ProcessPrestatCommands(boost::barrier *serThreadBar = NULL); bool ProcessPoststatCommands(boost::barrier *serThreadBar = NULL); //virtual bool ProcessParallelCommands(boost::barrier *serThreadBar = NULL); //bool StartParallelThread(boost::barrier *serThreadBar = NULL); bool checkSignal(); void ProcessDateCommand(string token = "", boost::barrier *serThreadBar = NULL); string ProcessDateCommand(boost::barrier *serThreadBar); virtual void ProcessParallelDataBind(CParallelHost* pParallelHost, boost::barrier* parThreadBar, presetMetaData* metaData, string threadID); void GetHostSpecificPaths(); void GenerateHeader(boost::barrier* = NULL); vector tokenizeString(string, string); // Duplicated from CLI Handler class bool RunScriptAndGetSnapID(int& nID); string SetPaths(string strPath, string strCmdToFind); void ProcessParallelTimer(int* maxTime); // Oracle void ProcessOraclePrestats(); void ProcessOraclePoststats(); string GetSQLQuery(); int GetSnapID(void); void setAppParams(); string printHeader(string , string , string ); // Added to get the version of the host in case of Linux void getOSVersion(); void sleepBtwIter(int); bool m_bStart; bool bquickPoststatsFlag; // flag to run the poststats quickly at interrupt time_t startTime; // Just a work around to test }; #endif //_HOST_H_