/* $Id$ */ #ifndef NODE_H #define NODE_H #ifdef WIN32 #include #include #include #include #include #else #include #include #endif #include #include #include #include "boost/lexical_cast.hpp" #include #include #include #include #include #include #include #include #include #include #include #include #ifndef WIN32 #include #endif const int NUMBER_OF_OPTIONS = 2; class host; typedef struct node_details { string ip; string userName; string ngPasswd; string systemShellPasswd; } NODE_DETAILS; class node { presetHandler presetHandle; CLIHandler * cliHandle; outputHandler * outputHandle; connectionHandler * connectionHandle; outputHandler* commonOutputHandle; parallelNode* pnode; host* localHostObj; targetSwitch* tswitch; bool hostFlag; bool switchFlag; bool parallelStatFlag; bool quickPostStatFlag; int connectionPort; bool systemShellLoginFlag; bool configJustOnce; bool systemShellLoginJustOnce; string systemShellPasswd; string model; string uptime; string osversion; string license; string nodeName; string nodeIP; string health; string serialNumber; string systemID; int numberOfProcessors; time_t statsStartTime; //664426 Perfstat disconnect ssh for high value of option t time_t statsIdentifierTime; //Commands added for SN time_t userspaceIdentifierTime; time_t nbladeIdentifierTime; time_t dbladeIdentifierTime; time_t protocolIdentifierTime; time_t aggregatedIdentifierTime; bool connectionStatus; vector longerRuntimeCmd; connectionHandler* statsConnectionHandle; connectionHandler* sysShellConnectionHandle; bool statConnectionStatus; string statsDataBuffer; controller* seqController; ofstream* tempFilePtr; map vfileData; void sleepBtwIter(int); void collectConfigData(boost::barrier *); string generateFullCommand(presetMetaData,bool nextSystemShellCommand=false); //added the flag for systemShell commands in 7-mode void processSystemShellCmd(presetMetaData,bool nextSystemShellCommand=false); //added the flag for systemShell commands in 7-mode string processDateCommand(boost::barrier *); host **pRemoteHost; void processDateCommand(string, boost::barrier *); void generateHeader(boost::barrier*); string printHeader(string, string, string); string getStatsTimeDelta(); vector safeVols; // Safe volumes for registry walk map licenses; // Added to hold the name of the Licenses that are present/enabled map mapOptions; // Added to hold the options int nosVersion; // for os version int currentIteration; NODE_DETAILS nodeDetails; boost::barrier *remoteHostThreadBar; boost::barrier *localHostThreadBar; boost::thread_group *remoteHostThreadGroup; boost::thread_group *localHostThreadGroup; bool bstatisticsShow; ofstream* legacyFilePtr; //Added for Legacy Mode, This can be removed...Now,just for Testing string legacyCmd; bool legacyModeFlag; // Flag to identify Legacy Mode...true means LEGACVY MODE.. bool bAutoSupportFlag; void setLegacyCommand(string user, string passwd); bool checkSignal(); void checkCommandOutput(string, string); void processParData(parallelNode *, boost::barrier *, presetMetaData *); void processSwitchData(targetSwitch *, boost::barrier *, int); //void ProcessRemoteHostData(host*, boost::barrier *, int); void processHostData(host*, boost::barrier *, int); void processHostPoststats(host* hostObj, boost::barrier *threadBar, int iterNum); void processHostParallels(host* hostObj, boost::barrier *localHostThreadBar); //int*); //string generateUniqueID(); //supporting tokenizer for 7-mode config data string tokenizeString(string , int); bool getOutputFromFile(string fileName, map > &statsInformation); void getLicenses(); bool enabledOptions(string option); void getOSVersion(); int getNumericalOSValue(string version); bool isFilerVersionJustified(presetMetaData metaData); bool isLicenseVerified(presetMetaData metaData); bool isCommandValid(presetMetaData metaData); void getValidFilerCommands(); void registryWalk(string strToFind, vector& safeVols); void parseStatisticsShowOutput(map > &statisticsShowMap); void processStatisticsShow(presetMetaData oneCmd); //remove dot from node IP string nodeIPint(string); void getVol_dbLookupInfo(boost::barrier *serThreadBar); bool syslogRvertChanges(boost::barrier *); public: /** empty constructor */ node() {}; /** constructor * takes presetHnadler onbect, CLIHandler object * and nodename as args */ // Added bool at last for cluster mode commands node(presetHandler, CLIHandler*, outputHandler*, string, string, string, bool, bool, bool, bool); /**provides node name * */ string getNodeIP(); /** main method to start iteration and * start preocessing commands * param serail thread barrier */ void processCommands(boost::barrier*); /** method to process prestats commands * param serail thread barrier */ bool processPrestatsCommands(boost::barrier*); /** method to process poststats commands * param serail thread barrier */ bool processPoststatsCommands(boost::barrier*); /** method to process the command by sending * it controller nas reading the response. * param command meta data */ void processOneCommand(presetMetaData, bool nextSystemShellCommand=false); //added this flag for reducing overhead for systemshell commands in 7-mode /** wakes up the serial thread when parallel * threads are done */ void startParallelThread(boost::barrier*, int); void startSwitchThread(boost::barrier*, int); //added for switch void startRemoteHostThread(int); // Thread for Remote Host void startLocalHostThread(int iter); /** makes serial thread wait and * start all parallel threads */ void waitForParallelThread(); void waitForParallelStatsThread(); void processParallelStatsData(); //void processParallelStats(); void processParallelStatsCommands(); bool processParallelPrestatsCommands(); bool processParallelPoststatsCommands(); bool processParallelStatsData(presetMetaData, string); bool getVfilerData(boost::barrier*); void setVfilerData(); void processParallelTimerData( int*, boost::thread_group *); void stopStatsSamples(); bool os_gt(int a, int b); bool os_gte(int a, int b); bool os_lt(int a, int b); bool os_lte(int a, int b); bool os_eq(int a, int b); bool os_neq(int a, int b); bool dynamicVersionCheck(string cmdVersion); int getCmdVersionNum(string getCmdVersion); string getCmdVersionOperator(string getCmdVersion); #ifdef WIN32 int killProcess(char *); //required to kill the plink.exe and rsh.exe process in 7-mode #endif void killRshOrSshProcess(); void prestatsSKtrace(); bool is7ModeSystemShell(); connectionHandler* getConnectionHandle() const; bool runHostPrestats(boost::barrier *serThreadBar, int index, bool &blocal, bool &bremote, bool& bquickFlag); #ifndef WIN32 void getFilesFromFilerUsingSCP(); private: bool getFileNames(vector& vecFileNames, string fileName); bool donwloadFileFromFiler(const string& location, vector fileNames, const string& destLocation); #endif bool isRunInLegacyMode(); bool sendLegacyCommand(const string& command, bool copyFiles = false); string collectLegacyData(bool bWriteToFile = true, bool bStatData = false); void getFilesFromFiler(); void getFiles(const string& filesLocation, vector& files); bool checkClusterHealth(); #ifdef WIN32 void do_system(string strCommand); #endif void checkAndRemoveFile(const string& fileName); void format_stats_output(time_t , string, string , string , string ); }; #endif