/* $Id$ */ #include #include #include #define SHELL "/bin/sh" /**This is required to keep avoid linking errors for error LNK2001: unresolved external symbol _GetModuleBaseNameA@16 error LNK2001: unresolved external symbol _EnumProcessModules@16 error LNK2001: unresolved external symbol _EnumProcesses@12 */ #ifdef WIN32 #pragma comment(lib, "Psapi") #endif #include #include #define MAX_PARALLEL_THREAD 5 //Most of the known SSH configurations in C-mode has CPS rate 10. #define LEGACY_MODE_COMMAND_TIME 70000 //const int cmdRunTime = 120; // 2mins string fileID = "temp"; // Just a temporary place, need to make this as a member or ?? //bool bQuickPoststatRunFlag = false; node::node(presetHandler pHandle, CLIHandler * cHandle, outputHandler* oHandle, string IP, string nodePrompt, string spasswd, bool hostflag, bool switchflag, bool clusterFlag, bool legacyFlag) { parallelStatFlag = false; quickPostStatFlag = false; presetHandle = pHandle; cliHandle = cHandle; commonOutputHandle = oHandle; nodeIP = IP; systemShellPasswd = spasswd; currentIteration = 0; outputHandle = new outputHandler(); boost::algorithm::trim(nodePrompt); if (!(cliHandle->getFilerMode().compare("10-mode"))) { (*outputHandle).createNodeDataHandler(cliHandle->getOutputFileName(), nodeIP, cliHandle->findNodeCluster(nodeIP)); } else { (*outputHandle).createNodeDataHandler(cliHandle->getOutputFileName(), nodeIP); } string nodeDirPath = (*outputHandle).getNodeDataDir(); cliHandle->setNodeDirectory(nodeIP,nodeDirPath); //Added CLIHandler in the constructor connectionHandle = new connectionHandler(cHandle->getSSHKey(), nodeIP, cHandle->getRequestTimeoutSecs(), commonOutputHandle, cHandle, nodePrompt); statsConnectionHandle = new connectionHandler(cliHandle->getSSHKey(), nodeIP, cliHandle->getRequestTimeoutSecs(), commonOutputHandle, cHandle, connectionHandle->getNodePrompt(),false); systemShellLoginFlag = true; configJustOnce = false; systemShellLoginJustOnce = false; seqController = new controller(); //Make sure we collect host data only with one controller hostFlag=hostflag; //Make sure we collect switch data only with one controller switchFlag = switchflag; // Added for cluster mode commands bstatisticsShow = clusterFlag; // Added for BURT_562755 remoteHostThreadBar = NULL; localHostThreadBar = NULL; remoteHostThreadGroup = NULL; localHostThreadGroup = NULL; // BURT_562755 if(!cliHandle->getHostOrFilerFlag()) { if(hostFlag) { localHostThreadBar = new boost::barrier(1); localHostThreadGroup = new boost::thread_group(); localHostObj = new LocalHost(presetHandle, cliHandle, commonOutputHandle); } } if(cliHandle->GetRemoteHostFlag()) { vector tmpvec = cliHandle->GetRemoteHosts(); if(hostflag) { if(remoteHostThreadBar == NULL && tmpvec.size() > 0) { remoteHostThreadBar = new boost::barrier(tmpvec.size()); remoteHostThreadGroup = new boost::thread_group(); } pRemoteHost = new host*[(int)tmpvec.size()]; for(int i = 0; i < (int)tmpvec.size(); i++) { pRemoteHost[i] = new RemoteHost(presetHandle, cliHandle, commonOutputHandle, tmpvec[i]); } } } numberOfProcessors = 1; // Default processor count nosVersion = 8100; // Default is RR.0 i.e; 8.1.0 statsStartTime = 0; // Default time // BURT 543517, 546794 //664426 Perfstat disconnect ssh for high value of option t statsIdentifierTime = 0; //Commands added for SN userspaceIdentifierTime = 0; nbladeIdentifierTime = 0; dbladeIdentifierTime = 0; protocolIdentifierTime = 0; legacyCmd = ""; //string user = "root"; string user = cliHandle->getFilerLoginUser(); string passwd = ""; nodeDetails.ip = IP; vector nodeCreds = cliHandle->getFilerCreds(IP); if(cliHandle->getSSHKeyProvidedFlag() == false) { if(cliHandle->getLegacyMode() == true) { #ifdef WIN32 if(cliHandle->getSSHFlag() == true) { if(nodeCreds.size() == 2) { user = nodeCreds.at(0); passwd = nodeCreds.at(1); } } #endif } else { if(nodeCreds.size() == 2) { user = nodeCreds.at(0); passwd = nodeCreds.at(1); } } } nodeDetails.userName = user; nodeDetails.ngPasswd = passwd; nodeDetails.systemShellPasswd = spasswd; setLegacyCommand(user, passwd); legacyFilePtr = NULL; // for Legacy Mode legacyModeFlag = legacyFlag; if(legacyModeFlag == true) { cliHandle->setMapData("LEGACY_MODE", nodeIP); } } //This piece of code is repeated in node.cpp, perfstat.cpp, threadHandler.cpp and parallelNode.cpp void node :: setLegacyCommand(string user, string passwd) { if(cliHandle->getFilerMode().compare("10-mode") == 0) { return; } #ifdef WIN32 // If --ssh-privatekey option is not present if(cliHandle->getSSHKeyProvidedFlag() == false) { //if(cliHandle->getSSHFlag() == false) { legacyCmd = "rsh.exe " + nodeIP; legacyCmd = legacyCmd + " -l " + user + " "; //} /* We would have failed earlier because with Legacy mode OpenSSH is compulsory from Perfstat v8.3*/ /* else { legacyCmd = "plink.exe -ssh -x -a -batch -pw "; //legacyCmd = "plink.exe -ssh -pw "; legacyCmd = legacyCmd + passwd + " -l " + user; legacyCmd = legacyCmd + " " + nodeIP; legacyCmd = legacyCmd + " "; commonOutputHandle->writeDataToLogFile("STATUS","This is a Bug. Please file a defect"); std::ostringstream error; error << "File " << __FILE__ << "Line " << __LINE__; commonOutputHandle->writeDataToLogFile("STATUS",error.str()); exit(0); } */ } else { if(cliHandle->getOPenSSHFlag() == true) { string strPrivKeyPath = cliHandle->getSSHPrivateKeyPath(); string strSSHKnownHostsFilePath = cliHandle->getSSHKnownHostsFilePath(); string temp = "known_hosts"; if(strSSHKnownHostsFilePath.empty()) { strSSHKnownHostsFilePath = strPrivKeyPath; strSSHKnownHostsFilePath.replace(strSSHKnownHostsFilePath.find_last_of("\\") + 1, temp.length(), temp); } strSSHKnownHostsFilePath.insert(0,"UserKnownHostsFile="); legacyCmd = "ssh.exe -l "; legacyCmd = legacyCmd + user + " -i "; legacyCmd = legacyCmd + "\"" + strPrivKeyPath + "\"" + " -o " + "\"" + strSSHKnownHostsFilePath + "\"" + " "; legacyCmd = legacyCmd + nodeIP + " "; } else { // This code is not needed,as the control wont come here. // Need to check this out and Remove this if case //if(cliHandle->getSSHFlag() == false) { legacyCmd = "rsh.exe " + nodeIP; legacyCmd = legacyCmd + " -l " + user + " "; //} /* else { // In-case of Legacy mode always consider OpenSSH. plink deprecated. string privKeyPath = cliHandle->getSSHPrivateKeyPath(); legacyCmd = "plink.exe -ssh -x -a "; legacyCmd = legacyCmd + nodeIP + " -l " + user + " -i "; legacyCmd = legacyCmd + "\"" + privKeyPath + "\"" +" "; } */ } } #else if(cliHandle->getSSHKeyProvidedFlag() == false) { // If --ssh-privatekey is not provided run with RSH legacyCmd = "rsh " + nodeIP; legacyCmd = legacyCmd + " -l " + user + " "; } else { if( cliHandle->getSSHFlag() == true) { string privKeyPath = cliHandle->getSSHPrivateKeyPath(); legacyCmd = "ssh -l "; legacyCmd = legacyCmd + user + " -i "; legacyCmd = legacyCmd + privKeyPath; legacyCmd.append(" "); legacyCmd.append(nodeIP); legacyCmd.append(" "); } else { legacyCmd = "rsh " + nodeIP; legacyCmd = legacyCmd + " -l " + user + " "; } } #endif } string node::getNodeIP() { return nodeIP; } void node::processCommands(boost::barrier *serThreadBar) { try { int numOfIter = cliHandle->getNumberOfIter(); string startIter = "BEGIN Iteration"; string endIter = "END Iteration"; bool syslog = false; if(legacyModeFlag == false) { commonOutputHandle->writeDataToLogFile("INFO", nodeIP, "Connecting to node."); } if(cliHandle->getSystemShellExcludedFlag() == true || !cliHandle->getSystemShellLoginFlag()) { #ifndef WIN32 sleep(1); #else boost::xtime currTime; boost::xtime_get(&currTime, boost::TIME_UTC_); currTime.sec += 5; boost::thread::sleep(currTime); #endif } perfstat::setNodeEntered(true); string autosupportCmd = ""; bool bAutoSupport = false; string outFileName = cliHandle->getOutputFileName(); if(legacyModeFlag == true) { //legacyFilePtr = outputHandle->createTempFile("Legacy_Output"); } // Handling Legacy Mode if(legacyModeFlag == false) { if((cliHandle->getFilerMode()).compare("10-mode") != 0 && cliHandle->getSSHKeyProvidedFlag() == false) { connectionStatus = (*connectionHandle).connectToFiler(nodeDetails.ngPasswd); } else { connectionStatus = (*connectionHandle).connectToFiler(); } if(connectionStatus) { commonOutputHandle->writeDataToLogFile("INFO", nodeIP, "Connected to node."); commonOutputHandle->writeDataToLogFile("INFO", nodeIP, "Gathering config data from the node."); } else { commonOutputHandle->writeDataToLogFile("ERROR", nodeIP, "Error while Connecting to node."); } } // If 7-Mode ASUP should work for all the nodes..else it will work for the whole cluster in case of cluster mode if((cliHandle->getFilerMode()).compare("10-mode") != 0) { bstatisticsShow = true; } if(bstatisticsShow == true) { // As AUTOSUPPORT is a cluster command, we run it only once per perfstat run for the entire cluster. // AUTO SUPPORT // Keep the dependency of the AUTOSUPPORT in preset file // Check whether ASUP command is present in the preset file or not ? vector poststatsVec = presetHandle.getAllPoststatsCommands("NODE"); for(int nIndex = 0; nIndex < poststatsVec.size(); ++nIndex) { string poststatCmd = poststatsVec[nIndex].getCommand(); if(poststatCmd.compare("AUTOSUPPORT") == 0) { bAutoSupport = true; break; } } // Check whether the health of all the Nodes in the cluster is true or not ? if(bAutoSupport == true && ((cliHandle->getFilerMode()).compare("10-mode") == 0)) { bAutoSupport = checkClusterHealth(); if(bAutoSupport == false) { commonOutputHandle->writeDataToLogFile("INFO", nodeIP, "AUTOSUPPORT command cannot be executed, as the health of the node in the cluster is false"); } } if(bAutoSupport == true) { if((cliHandle->getFilerMode()).compare("10-mode")) { autosupportCmd = "priv set -q diag;options autosupport.doit \"Starting perfstat whose ouput file is \"" + outFileName; } else { //autosupportCmd = "autosupport invoke -node local -type all -message "; autosupportCmd = "options autosupport.doit \"Starting perfstat whose ouput file is \"" + outFileName; } if(legacyModeFlag == false) { connectionHandle->sendCommandToFiler(autosupportCmd); } else { sendLegacyCommand(autosupportCmd); } } } if(legacyModeFlag == false) { if((cliHandle->getFilerMode()).compare("10-mode") != 0 && cliHandle->getSSHKeyProvidedFlag() == false) { statConnectionStatus = (*statsConnectionHandle).connectToFiler(nodeDetails.ngPasswd); } else { statConnectionStatus = (*statsConnectionHandle).connectToFiler(); } } // Added to check whether CTRL+C is used bool bcheckSignal = checkSignal(); //setup connection for parallel stat commands //We will not have Parallel_Prestats and Parallel_Poststats commands collectConfigData(serThreadBar); // Added to check whether CTRL+C is used bcheckSignal = checkSignal(); getValidFilerCommands(); generateHeader(serThreadBar); //Lets get the vfiler data for vfiler commands. We collect it only for 7-mode. if((cliHandle->getFilerMode()).compare("10-mode")) { bool status = getVfilerData(serThreadBar); if(!status) { commonOutputHandle->writeDataToLogFile("ERROR", nodeIP, "Error while collecting the vfiler config data"); } } else { // For cmode, make sure to stop any stats start sessions in flight to avoid burt 832289 commonOutputHandle->writeDataToLogFile("INFO", nodeIP, "Stopping any background stats samples"); stopStatsSamples(); } //start iter loop for(int i=0; i(i + 1) + "/" + boost::lexical_cast(numOfIter) + ":\n"; commonOutputHandle->writeDataToLogFile("STATUS", nodeIP, temp); temp = "Begin Iteration number: "; temp.append(boost::lexical_cast(i + 1)); commonOutputHandle->writeDataToLogFile("INFO", nodeIP, temp); //start iter stmt (*outputHandle).writeIterToNodeFile(i, startIter, dateStr); //clear the long run command vector longerRuntimeCmd.clear(); if(legacyModeFlag == false) { (*connectionHandle).setIterationChanged(true); if(!(cliHandle->getFilerMode()).compare("10-mode")) { (*statsConnectionHandle).setIterationChanged(true); } } bool status = processPrestatsCommands(serThreadBar); if(!status) { break; } // Added for BURT_562755 else { bool blocalFlag = false; bool bremoteFlag = false; bool bQuickPoststatRunFlag = false; status = runHostPrestats(serThreadBar, i + 1, blocalFlag, bremoteFlag, bQuickPoststatRunFlag); // Added BURT_562755, Wait for the Host and Node Prestats to complete (*serThreadBar).wait(); if(bQuickPoststatRunFlag == true) { quickPostStatFlag = true; if(!(cliHandle->getFilerMode()).compare("10-mode")) { seqController->parallelCmdThreadFinish(); // Added to handle interrupt at prestat stage seqController->waitParallelStatsCmdThread(); } processPoststatsCommands(serThreadBar); (*serThreadBar).wait(); if(hostFlag && !cliHandle->getHostOrFilerFlag() && blocalFlag) { localHostThreadGroup->create_thread(boost::bind(&node::processHostPoststats, *this, localHostObj, localHostThreadBar, i + 1)); //localHostThreadBar->wait(); localHostThreadGroup->join_all(); } // REMOTE HOST COLLECTION if(cliHandle->GetRemoteHostFlag() && hostFlag && bremoteFlag) { int remoteHostSize = (cliHandle->GetRemoteHosts()).size(); for(int remoteIndex = 0; remoteIndex < remoteHostSize; ++remoteIndex) { remoteHostThreadGroup->create_thread(boost::bind(&node::processHostPoststats, *this, pRemoteHost[remoteIndex], remoteHostThreadBar, i + 1)); //remoteHostThreadBar->wait(); } remoteHostThreadGroup->join_all(); } // (*serThreadBar).wait(); break; } } //For 7-mode, we need to ensure that all parallel commands return within maxTime period //If they dont finish, we kill them startParallelThread(serThreadBar, i+1); //waitForParallelThread(); //664426 Perfstat disconnect ssh for high value of option t //checkConnection() not to be run with Legacy mode if(cliHandle->getLegacyMode() == false) { connectionHandle->checkConnection(true); } (*serThreadBar).wait(); status = processPoststatsCommands(serThreadBar); if(!status) { break; } dateStr = processDateCommand(serThreadBar); if(hostFlag && !cliHandle->getHostOrFilerFlag()) { localHostThreadGroup->create_thread(boost::bind(&node::processHostPoststats, *this, localHostObj, localHostThreadBar, i + 1)); //localHostThreadBar->wait(); localHostThreadGroup->join_all(); } // REMOTE HOST COLLECTION if(cliHandle->GetRemoteHostFlag() && hostFlag) { int remoteHostSize = (cliHandle->GetRemoteHosts()).size(); for(int remoteIndex = 0; remoteIndex < remoteHostSize; ++remoteIndex) { remoteHostThreadGroup->create_thread(boost::bind(&node::processHostPoststats, *this, pRemoteHost[remoteIndex], remoteHostThreadBar, i + 1)); //remoteHostThreadBar->wait(); } remoteHostThreadGroup->join_all(); } time_t cmdEndTime; time(&cmdEndTime); string data="--- EXE-TIME of : Iteration number: "; data.append(boost::lexical_cast(i + 1) + " : "); data.append(boost::lexical_cast(cmdEndTime - cmdStartTime) + " seconds"); commonOutputHandle->writeDataToLogFile("INFO", nodeIP, data); (*outputHandle).writeIterToNodeFile(i, endIter, dateStr); temp = "End Iteration number: " + boost::lexical_cast(i + 1); commonOutputHandle->writeDataToLogFile("INFO", nodeIP, temp); //check for long runtime commands if(longerRuntimeCmd.size() != 0) { for(int k=0; k<(int)longerRuntimeCmd.size(); k++) { string tmp = "Execution time for command \'" + longerRuntimeCmd[k]; tmp.append("\' was more than 2 mins"); commonOutputHandle->writeDataToLogFile("WARNING", nodeIP, tmp); } } //sleep between iter if(i+1 != numOfIter) { sleepBtwIter(cliHandle->getSampleTimeBtwIter()); temp = "Sleeping for: "; temp.append(boost::lexical_cast(cliHandle->getSampleTimeBtwIter()) + " seconds."); commonOutputHandle->writeDataToLogFile("INFO", nodeIP, temp); } else { // To keep the dependency of the AUTOSUPPORT in preset file if(bAutoSupport == true) { if((cliHandle->getFilerMode()).compare("10-mode")) { autosupportCmd = "priv set -q diag;options autosupport.doit \"Ending perfstat whose ouput file is \"" + outFileName; } else { //autosupportCmd = "autosupport invoke -node local -type all -message "; autosupportCmd = "options autosupport.doit \"Ending perfstat whose ouput file is \"" + outFileName; } if(legacyModeFlag == false) { connectionHandle->sendCommandToFiler(autosupportCmd); } else { sendLegacyCommand(autosupportCmd); } } } (*serThreadBar).wait(); } // vol_db for each node. //check if vol_db lookup for waffi_id has to be collected if(cliHandle->getVol_dbFlag()) { getVol_dbLookupInfo(serThreadBar); } /* In-case of 7-mode revert back the syslog.conf file BURT - 679978*/ if ((cliHandle->getFilerMode()).compare("10-mode")) { syslog = syslogRvertChanges(serThreadBar); } // This is made false again.So that,perfstat.cpp will now handle the case of ctrl+C perfstat::setNodeEntered(false); // Added to Extract Files from controller if(cliHandle->getProfileFlag() == true || cliHandle->getModuleInstFlag() == true || cliHandle->getSKTraceFlag() == true || cliHandle->getBackUpLogFlag() == true) { getFilesFromFiler(); (*serThreadBar).wait(); // Make sure all download happens at same time } // Delete the allocated local host object if(hostFlag && !cliHandle->getHostOrFilerFlag()) { SAFE_DELETE(localHostObj); } // Delete the allocated remote host objects if(cliHandle->GetRemoteHostFlag() && hostFlag) { vector tmpvec = cliHandle->GetRemoteHosts(); for(int nIndex = 0; nIndex < tmpvec.size(); ++nIndex) { SAFE_DELETE(pRemoteHost[nIndex]); } SAFE_ARRAY_DELETE(pRemoteHost); } (*outputHandle).closeNodeFile(); if(legacyModeFlag == false) { (*connectionHandle).disconnectToFiler(); if(!(cliHandle->getFilerMode()).compare("10-mode")) { //this statsConnection is again the overlapped connection to the connectionHandle. So once we have disconnected with //connectionHandle, the ssh connection is already terminated and hence we dont close statsConnection. (*statsConnectionHandle).disconnectToFiler(); } } // remove the Legacy file if(legacyModeFlag == true) { outputHandle->removeTempFile("Legacy_Output"); outputHandle->removeTempFile("error"); } } catch(std::exception& e) { string tmp = "Exception : node : processCommands :"; tmp.append(e.what()); commonOutputHandle->writeDataToLogFile("ERROR", nodeIP, tmp); } } bool node::processPrestatsCommands(boost::barrier *serThreadBar) { try { commonOutputHandle->writeDataToLogFile("INFO", nodeIP, "Starting processing of PRESTATS commands."); string startStats = "BEGIN PRESTATS"; string endStats = "END PRESTATS"; processDateCommand("PRESTATS", serThreadBar); (*outputHandle).writeSTATSToNodeFile(startStats, nodeIP); bool sigStat = checkSignal(); if(sigStat) { seqController->startPreStatsCommands(); return false; } //process config commands if(!configJustOnce) { // Check whether to collect CONFIG information in all the iterations !!! if(!cliHandle->getConfigAllFlag()) { configJustOnce = true; } //added NODE hardware, Get all the NODE related CONFIG commands vector prestatsconfigVec = presetHandle.getPrestatsCommands("TYPE", "CONFIG", "NODE"); for(int i = 0; i < (int)prestatsconfigVec.size(); i++) { //As systemshell commands in 7-mode triggers disconnect/connect sequence after every command //due to the uncertainity of the next command's SHELL. So to minimize this penalty in case //the next command's SHELL is systemshell, we would not trigger disconnect/connect. if(!(cliHandle->getFilerMode()).compare("10-mode")) { processOneCommand(prestatsconfigVec[i]); } else { //Get the SHELL type of the next command bool systemShellPresentFlag = false; if(i < (int)prestatsconfigVec.size() && (i + 1) != (int)prestatsconfigVec.size() ) { string currshell,nextShell; currshell = prestatsconfigVec[i].getShell(); nextShell = prestatsconfigVec[i+1].getShell(); if(currshell.compare("SYSTEMSHELL") == 0 && nextShell.compare("SYSTEMSHELL") == 0) { systemShellPresentFlag = true; } } processOneCommand(prestatsconfigVec[i], systemShellPresentFlag); } //reach the bar // Commented, to make sure that all the prestat commands wait at the last of the prestats. //(*serThreadBar).wait(); // BURT_562755 sigStat = checkSignal(); //Logout only in case NON-LEGACY MODE if(sigStat) { if((cliHandle->getFilerMode()).compare("10-mode") != 0 && (prestatsconfigVec[i].getShell()).compare("SYSTEMSHELL") == 0 && connectionHandle != NULL) { if(legacyModeFlag == false) { connectionHandle->logoutSystemShell(); } } break; } } } // Wait for all CONFIG commands to join at the same time (*serThreadBar).wait(); commonOutputHandle->writeDataToLogFile("INFO", nodeIP, "Finished processing of PRESTATS CONFIG commands"); seqController->startPreStatsCommands(); //added NODE hardware, Get all the NODE related PERF commands vector prestatsVec = presetHandle.getPrestatsCommands("TYPE", "PERF","NODE"); for(int i=0; i<(int)prestatsVec.size(); i++) { if(!(cliHandle->getFilerMode()).compare("10-mode")) { processOneCommand(prestatsVec[i]); // Added to make sure that all the statistic show wait and procede from same place if((prestatsVec[i].getShortname()).compare("statistics show") == 0) { (*serThreadBar).wait(); } } else { //Get the SHELL type of the next command bool systemShellPresentFlag = false; if(i < (int)prestatsVec.size() && (i + 1) != (int)prestatsVec.size()) { string currshell,nextShell; currshell = prestatsVec[i].getShell(); nextShell = prestatsVec[i+1].getShell(); if(currshell.compare("SYSTEMSHELL") == 0 && nextShell.compare("SYSTEMSHELL") == 0) { systemShellPresentFlag = true; } } // we need to consider the case when sktrace collection is enabled. // As sktrace would be the last Systemshell command to be executed in Prestats, // we need to set the systemShellPresentFlag flag. if((((i + 1) == (int)prestatsVec.size()) && ((prestatsVec[i].getShell()).compare("SYSTEMSHELL") == 0)) && cliHandle->getSKTraceFlag()) { systemShellPresentFlag = true; } processOneCommand(prestatsVec[i], systemShellPresentFlag); } //reach the bar // Commented, to make sure that all the prestat perf commands wait at the last of the prestats. //(*serThreadBar).wait(); // BURT_562755 sigStat = checkSignal(); // Logout only in case of NON-LEGACY MODE if(sigStat) { if((cliHandle->getFilerMode()).compare("10-mode") != 0 && (prestatsVec[i].getShell()).compare("SYSTEMSHELL") == 0 && connectionHandle != NULL) { if(legacyModeFlag == false) { connectionHandle->logoutSystemShell(); } } break; } } //check If SKtrace need to be collected //SKTRACE collection is done in the case of NON-LEGACY MODE if(legacyModeFlag == false) { if(cliHandle->getSKTraceFlag()) { prestatsSKtrace(); } } // Added to make sure that all the PERF Commands join at the same time (*serThreadBar).wait(); // BURT_562755, Added commonOutputHandle->writeDataToLogFile("INFO", nodeIP, "Finished processing of PRESTATS PERF commands"); // If there is an interrupt signal, quickly process POSTSTATS if(sigStat) { //We run Parallel_Prestat/Parallel_Poststat commands only for 10-mode. Hence we dont require to collect the temp stat data if(!(cliHandle->getFilerMode()).compare("10-mode")) { seqController->parallelCmdThreadFinish(); // Added to handle interrupt at prestat stage seqController->waitParallelStatsCmdThread(); //move data from temp file to main data file (*outputHandle).MoveFromTempToDataFile(fileID); //Delete the temp file (*outputHandle).removeTempFile(fileID); (*outputHandle).writeSTATSToNodeFile(endStats, nodeIP); } commonOutputHandle->writeDataToLogFile("STATUS", nodeIP, "Lets quickly run the POSTSTAT before exiting.."); //set the quickPostStatFlag quickPostStatFlag = true; // Quickly run the POSTSTATS bool result = processPoststatsCommands(serThreadBar); if(!result) { commonOutputHandle->writeDataToLogFile("ERROR",nodeIP, "Failed to execute the poststat commands: "); } return false; } else { if(!(cliHandle->getFilerMode()).compare("10-mode")) { commonOutputHandle->writeDataToLogFile("INFO", nodeIP, \ "Finished processing of PRESTATS commands. Waiting for PARALLEL_PRESTATS commands to finish"); // Wait for remaing threads to join here. (*serThreadBar).wait(); seqController->waitParallelStatsCmdThread(); //move data from temp file to main data file (*outputHandle).MoveFromTempToDataFile(fileID); //Delete the temp file (*outputHandle).removeTempFile(fileID); (*outputHandle).writeSTATSToNodeFile(endStats, nodeIP); //to make sure all the stats threads for all nodes are done too } (*serThreadBar).wait(); commonOutputHandle->writeDataToLogFile("INFO", nodeIP, "Finished processing of PRESTATS commands."); //seqController->startPreStatsCmd = false; seqController->resetPrestatVariable(); } } catch(std::exception& e) { string tmp = "Exception : node : processPrestatsCommands :"; tmp.append(e.what()); commonOutputHandle->writeDataToLogFile("ERROR", nodeIP, tmp); } return true; } bool node::processPoststatsCommands(boost::barrier *serThreadBar) { try { bool sigStat = checkSignal(); commonOutputHandle->writeDataToLogFile("INFO", nodeIP, "Starting processing of POSTSTATS commands."); string startStats = "BEGIN POSTSTATS"; string endStats = "END POSTSTATS"; (*outputHandle).writeSTATSToNodeFile(startStats, nodeIP); if(sigStat) { //(*parStatThreadBar).wait(); // We return only in non emergancy situations. // We might have come to process poststats commands as we have recieved timeout or interrupt //during the prestat phase if(!quickPostStatFlag) { return false; } } //(*parStatThreadBar).wait(); vector poststatsVec = presetHandle.getAllPoststatsCommands("NODE"); for(int i=0; i<(int)poststatsVec.size(); i++) { //processOneCommand(poststatsVec[i]); if(!(cliHandle->getFilerMode()).compare("10-mode")) { processOneCommand(poststatsVec[i]); // Added to make sure that commands after statistics show start at same time if((poststatsVec[i].getShortname()).compare("statistics show") == 0) { (*serThreadBar).wait(); } } else { //Get the SHELL type of the next command bool systemShellPresentFlag = false; if(i < (int)poststatsVec.size() && (i+1) != (int)poststatsVec.size()) { string currshell,nextShell; currshell = poststatsVec[i].getShell(); nextShell = poststatsVec[i+1].getShell(); if(currshell.compare("SYSTEMSHELL")==0 && nextShell.compare("SYSTEMSHELL")==0) { systemShellPresentFlag = true; } } processOneCommand(poststatsVec[i], systemShellPresentFlag); } //reach the bar //(*serThreadBar).wait(); // Commented for BURT_562755 //We have received the interrupt during prestat so logically we should execute all the poststat commands and then return sigStat = checkSignal(); if(!quickPostStatFlag) { //sigStat = checkSignal(); if(sigStat) { if((cliHandle->getFilerMode()).compare("10-mode") != 0 && (poststatsVec[i].getShell()).compare("SYSTEMSHELL") == 0 && connectionHandle != NULL) { // Logout only in the case of NON-LEGACY Mode if(legacyModeFlag == false) { connectionHandle->logoutSystemShell(); } } break; } } } (*serThreadBar).wait(); // Added for BURT_562755 if(sigStat) { //We run Parallel_Prestat/Parallel_Poststat commands only for 10-mode. Hence we dont require to collect the temp stat data if(!(cliHandle->getFilerMode()).compare("10-mode")) { seqController->waitParallelStatsCmdThread(); if(!parallelStatFlag) { //move data from temp file to main data file (*outputHandle).MoveFromTempToDataFile(fileID); //Delete the temp file (*outputHandle).removeTempFile(fileID); } (*outputHandle).writeSTATSToNodeFile(endStats, nodeIP); } return false; } else { //We run Parallel_Prestat/Parallel_Poststat commands only for 10-mode. Hence we dont require to collect the temp stat data if(!(cliHandle->getFilerMode()).compare("10-mode")) { commonOutputHandle->writeDataToLogFile("INFO", nodeIP, "Finished processing of POSTSTATS commands. Waiting for PARALLEL_POSTSTATS commands to finish"); seqController->waitParallelStatsCmdThread(); //move data from temp file to main data file (*outputHandle).MoveFromTempToDataFile(fileID); //Delete the temp file (*outputHandle).removeTempFile(fileID); (*outputHandle).writeSTATSToNodeFile(endStats, nodeIP); } processDateCommand("POSTSTATS", serThreadBar); commonOutputHandle->writeDataToLogFile("INFO", nodeIP, "Finished processing of POSTSTATS commands."); //to make sure all the stats threads for all nodes are done too (*serThreadBar).wait(); } } catch(std::exception& e) { string tmp = "Exception : node : processPoststatsCommands :"; tmp.append(e.what()); commonOutputHandle->writeDataToLogFile("ERROR", nodeIP, tmp); } return true; } void node::processDateCommand(string token, boost::barrier *serThreadBar) { vector data; data.push_back(token); data.push_back("PERF"); data.push_back(""); data.push_back("*"); data.push_back("*"); data.push_back("NODERUN"); data.push_back(""); data.push_back(""); data.push_back("date"); data.push_back("true"); presetMetaData dateCmd = presetMetaData(data); processOneCommand(dateCmd); (*serThreadBar).wait(); } string node::processDateCommand(boost::barrier *serThreadBar) { string command; if(!(cliHandle->getFilerMode()).compare("10-mode")) { command = "node run -node local -command \"priv set -q diag;date\""; } else { // string command = "\"priv set -q diag;date\""; command = "priv set -q diag;date"; command=command+'\r'; } string output = ""; if(legacyModeFlag == false) { connectionStatus = (*connectionHandle).sendCommandToFiler(command); if(connectionStatus) output = (*connectionHandle).readResponseBufferWithPoll(outputHandle); } else { sendLegacyCommand(command); output = collectLegacyData(false); } (*serThreadBar).wait(); return output; } string node :: nodeIPint(string tempnodeIP){ string dot = "."; int dotposition = tempnodeIP.find(dot); while(dotposition != string::npos) { tempnodeIP.replace(dotposition, dot.length(), ""); dotposition = tempnodeIP.find(dot); } return(tempnodeIP); } void node::processOneCommand(presetMetaData oneCmd, bool nextSystemShellCommand) { try { string::size_type pos; bool bDisplaySystemShellForLegacy = true; //burt 662532 "wafl_bufstats" need to be removed if((cliHandle->getWaflBufstatsFlag() == false) && (oneCmd.getCommand().find("wafl bufstats") != string::npos)){ return; } if(legacyModeFlag == true) { string shell = oneCmd.getShell(); if(shell.find("SYSTEMSHELL") != string::npos) { bDisplaySystemShellForLegacy = false; } } if(bDisplaySystemShellForLegacy == true) { string temp = "Processing command -- "; temp.append(oneCmd.toString()); commonOutputHandle->writeDataToLogFile("INFO", nodeIP, temp); } /* string temp = "Processing command -- "; temp.append(oneCmd.toString()); commonOutputHandle->writeDataToLogFile("INFO", nodeIP, temp); */ string command = generateFullCommand(oneCmd,nextSystemShellCommand); string prepareCommand; //664426 Perfstat disconnect ssh for high value of option t string temp = "stats start"; size_t found = command.find(temp); if(found!=string::npos) { time ( &statsIdentifierTime ); command.replace(found, temp.length(), "stats start -I Perfstat_" + boost::lexical_cast(statsIdentifierTime)); } temp = "stats stop"; found = command.find(temp); if(found!=string::npos) { command.replace(found, temp.length(), "stats stop -I Perfstat_" + boost::lexical_cast(statsIdentifierTime)); } //Commands added for SN temp = "statistics start -sample userspace"; found = command.find(temp); if(found != string::npos) { time ( &userspaceIdentifierTime); string UserspaceIdentifierString = "statistics start -sample userspace_" + nodeIPint(nodeIP) + "_" + boost::lexical_cast(userspaceIdentifierTime); command.replace(found, temp.length(), UserspaceIdentifierString); } temp = "statistics show -sample userspace"; found = command.find(temp); if(found != string::npos) { string UserspaceIdentifierString = "statistics show -sample userspace_" + nodeIPint(nodeIP) + "_" + boost::lexical_cast(userspaceIdentifierTime); command.replace(found, temp.length(), UserspaceIdentifierString); } temp = "statistics samples delete -sample userspace"; found = command.find(temp); if(found != string::npos) { string UserspaceIdentifierString = "statistics samples delete -sample userspace_" + nodeIPint(nodeIP) + "_" + boost::lexical_cast(userspaceIdentifierTime); command.replace(found, temp.length(), UserspaceIdentifierString); } /* temp = "statistics start -sample dblade"; found = command.find(temp); if(found != string::npos) { time ( &dbladeIdentifierTime); string dbladeIdentifierString = "statistics start -sample dblade_" + nodeIPint(nodeIP) + "_" + boost::lexical_cast(dbladeIdentifierTime); command.replace(found, temp.length(), dbladeIdentifierString); } temp = "statistics show -sample dblade"; found = command.find(temp); if(found != string::npos) { string dbladeIdentifierString = "statistics show -sample dblade_" + nodeIPint(nodeIP) + "_" + boost::lexical_cast(dbladeIdentifierTime); command.replace(found, temp.length(), dbladeIdentifierString); } temp = "statistics samples delete -sample dblade"; found = command.find(temp); if(found != string::npos) { string dbladeIdentifierString = "statistics samples delete -sample dblade_" + nodeIPint(nodeIP) + "_" + boost::lexical_cast(dbladeIdentifierTime); command.replace(found, temp.length(), dbladeIdentifierString); } temp = "statistics start -sample nblade"; found = command.find(temp); if(found != string::npos) { time ( &nbladeIdentifierTime); string nbladeIdentifierString = "statistics start -sample nblade_" + nodeIPint(nodeIP) + "_" + boost::lexical_cast(nbladeIdentifierTime); command.replace(found, temp.length(), nbladeIdentifierString); } temp = "statistics show -sample nblade"; found = command.find(temp); if(found != string::npos) { string nbladeIdentifierString = "statistics show -sample nblade_" + nodeIPint(nodeIP) + "_" + boost::lexical_cast(nbladeIdentifierTime); command.replace(found, temp.length(), nbladeIdentifierString); } temp = "statistics samples delete -sample nblade"; found = command.find(temp); if(found != string::npos) { string nbladeIdentifierString = "statistics samples delete -sample nblade_" + nodeIPint(nodeIP) + "_" + boost::lexical_cast(nbladeIdentifierTime); command.replace(found, temp.length(), nbladeIdentifierString); } */ // temp = "statistics start -sample protocol"; found = command.find(temp); if(found != string::npos) { time ( &protocolIdentifierTime); string protocolIdentifierString = "statistics start -sample protocol_" + nodeIPint(nodeIP) + "_" + boost::lexical_cast(protocolIdentifierTime); command.replace(found, temp.length(), protocolIdentifierString); } temp = "statistics show -sample protocol"; found = command.find(temp); if(found != string::npos) { string protocolIdentifierString = "statistics show -sample protocol_" + nodeIPint(nodeIP) + "_" + boost::lexical_cast(protocolIdentifierTime); command.replace(found, temp.length(), protocolIdentifierString); } temp = "statistics samples delete -sample protocol"; found = command.find(temp); if(found != string::npos) { string protocolIdentifierString = "statistics samples delete -sample protocol_" + nodeIPint(nodeIP) + "_" + boost::lexical_cast(protocolIdentifierTime); command.replace(found, temp.length(), protocolIdentifierString); } temp = "statistics start -sample aggregated"; found = command.find(temp); if(found != string::npos) { time (&aggregatedIdentifierTime); string aggregatedIdentifierString = "statistics start -sample aggregated_" + nodeIPint(nodeIP) + "_" + boost::lexical_cast(aggregatedIdentifierTime); command.replace(found, temp.length(), aggregatedIdentifierString); } temp = "statistics show -sample aggregated"; found = command.find(temp); if(found != string::npos) { string aggregatedIdentifierString = "statistics show -sample aggregated_" + nodeIPint(nodeIP) + "_" + boost::lexical_cast(aggregatedIdentifierTime); command.replace(found, temp.length(), aggregatedIdentifierString); } temp = "statistics samples delete -sample aggregated"; found = command.find(temp); if(found != string::npos) { string aggregatedIdentifierString = "statistics samples delete -sample aggregated_" + nodeIPint(nodeIP) + "_" + boost::lexical_cast(aggregatedIdentifierTime); command.replace(found, temp.length(), aggregatedIdentifierString); } temp = "statistics show"; found = command.find(temp); if(found != string::npos) { temp = "statistics"; } if(command != "") { time_t cmdStartTime; time(&cmdStartTime); // Adding this case for cluster Commands string clusterCmd = oneCmd.getCommand(); if(clusterCmd.compare("statistics show -sample aggregated") == 0) { if(bstatisticsShow == true) { commonOutputHandle->writeDataToLogFile("INFO", nodeIP, "Execution of statistics show command takes some time.please wait..."); connectionStatus = (*connectionHandle).sendCommandToFiler(command); if(connectionStatus) { processStatisticsShow(oneCmd); } } } else if(clusterCmd.find("statistics show -sample userspace") != string::npos) { commonOutputHandle->writeDataToLogFile("INFO", nodeIP, "Execution of statistics show command takes some time.please wait..."); connectionStatus = (*connectionHandle).sendCommandToFiler(command); if(connectionStatus) { processStatisticsShow(oneCmd); } } /* else if(clusterCmd.find("statistics show -sample dblade") != string::npos) { commonOutputHandle->writeDataToLogFile("INFO", nodeIP, "Execution of statistics show command takes some time.please wait..."); connectionStatus = (*connectionHandle).sendCommandToFiler(command); if(connectionStatus) { processStatisticsShow(oneCmd); } } else if(clusterCmd.find("statistics show -sample nblade") != string::npos) { commonOutputHandle->writeDataToLogFile("INFO", nodeIP, "Execution of statistics show command takes some time.please wait..."); connectionStatus = (*connectionHandle).sendCommandToFiler(command); if(connectionStatus) { processStatisticsShow(oneCmd); } } */ else if(clusterCmd.find("statistics show -sample protocol") != string::npos) { commonOutputHandle->writeDataToLogFile("INFO", nodeIP, "Execution of statistics show command takes some time.please wait..."); connectionStatus = (*connectionHandle).sendCommandToFiler(command); if(connectionStatus) { processStatisticsShow(oneCmd); } } else if((oneCmd.getShortname().compare("statistics start -sample AGGREGATED") == 0) || (oneCmd.getShortname().compare("statistics samples delete -sample AGGREGATED") == 0)) { if(bstatisticsShow == true) { commonOutputHandle->writeDataToLogFile("INFO", nodeIP, "Execution of statistics start cluster commands"); connectionStatus = (*connectionHandle).sendCommandToFiler(command); if(connectionStatus) { string data = ""; string totalOutput = ""; data = "=-=-=-=-=-= " + oneCmd.getType() + " " + nodeIP + " "; data.append(oneCmd.getSection() + " =-=-=-=-=-= "); string nameToAppend = oneCmd.getShortname(); if(nameToAppend.compare("") == 0) { nameToAppend = oneCmd.getCommand(); } data += nameToAppend; totalOutput = "\nPERFSTAT_EPOCH: "; totalOutput.append(boost::lexical_cast(cmdStartTime)); totalOutput.append(perfstat::convert_EPOCH_to_gmtime(cmdStartTime)); totalOutput.append("\n"); (*outputHandle).writeDataToNodeFile(data, totalOutput); (*connectionHandle).readResponseFromFilerWithPoll(outputHandle); time_t cmdEndTime; time(&cmdEndTime); data = "\n--- EXE-TIME of : " + oneCmd.getCommand() + " : "; data.append(boost::lexical_cast(cmdEndTime - cmdStartTime) + " seconds"); outputHandle->writeDataToNodeFile(data); } } } //check if the command is a RAS tracing command else if(strstr(command.c_str(),"rastrace enable" )|| strstr(command.c_str(),"rastrace disable")) { // Added to ensure that MODULE_INST is used at the command line if(cliHandle->getModuleInstFlag() == false) { return; } string moduleNumber; vector tmpInstanceIds; command.erase(command.end()-1); //erase the '\r' character coming with the command string string temp1 = ""; int moduleid = 5; int position = command.find(temp1); if(position != string::npos) { command.replace(position, temp1.length(), boost::lexical_cast(moduleid)); } //Check if the target instances have been provided for the given module if(cliHandle->getModuleInstFlag()) { tmpInstanceIds = cliHandle->getModuleInstances(); } //lets handle ras trace enable and disable seperately if(strstr(command.c_str(),"rastrace enable")) { time ( &statsStartTime ); if(tmpInstanceIds.size() == 0) { //this is the dafult case so we collect ras trace for instance '1' only command = command + " " + "-i 1"; if(!(cliHandle->getFilerMode()).compare("10-mode")) { command = command + "\""; } //Now send the command to the controller // LEGACY MODE check if(legacyModeFlag == false) { connectionStatus = (*connectionHandle).sendCommandToFiler(command); } else { sendLegacyCommand(command); } prepareCommand = command; } else { string tmpCommand; for(int i=0; igetFilerMode()).compare("10-mode")) { tmpCommand = tmpCommand + "\""; } //Now send the command to the controller if(legacyModeFlag == false) { connectionStatus = (*connectionHandle).sendCommandToFiler(tmpCommand); } else { sendLegacyCommand(tmpCommand); } prepareCommand = tmpCommand; } } } if(strstr(command.c_str(),"rastrace disable")) { string dumpRasCommand; if(!(cliHandle->getFilerMode()).compare("10-mode")) { dumpRasCommand = "node run -node local -command \"priv set -q diag;rastrace dump -m " ; } else { dumpRasCommand = "priv set -q diag;rastrace dump -m "; } //get the moduleNumber from the command pos = command.find("-m"); moduleNumber = command.substr(pos+2); time ( &statsStartTime ); if(tmpInstanceIds.size() == 0) { //this is the dafult case so we collect ras trace for instance '1' only dumpRasCommand = dumpRasCommand + " " + moduleNumber; dumpRasCommand = dumpRasCommand + " -i 1 "; if(!(cliHandle->getFilerMode()).compare("10-mode")) { dumpRasCommand = dumpRasCommand + "\""; } command = command + " " + "-i 1"; if(!(cliHandle->getFilerMode()).compare("10-mode")) { command = command + "\""; } //Now send the command to the controller if(legacyModeFlag == false) { connectionStatus = (*connectionHandle).sendCommandToFiler(dumpRasCommand); connectionStatus = (*connectionHandle).sendCommandToFiler(command); } else { sendLegacyCommand(dumpRasCommand); sendLegacyCommand(command); } prepareCommand = command; } else { string tmpCommand; string tmpDumpCommand; for(int i=0; igetFilerMode()).compare("10-mode")) { tmpDumpCommand = tmpDumpCommand + "\""; } tmpCommand = command; tmpCommand = tmpCommand + " " + "-i " + tmpInstanceIds[i]; if(!(cliHandle->getFilerMode()).compare("10-mode")) { tmpCommand = tmpCommand + "\""; } //Now send the command to the controller if(legacyModeFlag == false) { connectionStatus = (*connectionHandle).sendCommandToFiler(tmpDumpCommand); connectionStatus = (*connectionHandle).sendCommandToFiler(tmpCommand); } else { sendLegacyCommand(tmpDumpCommand); sendLegacyCommand(tmpCommand); } } prepareCommand = tmpCommand; } } // As the default value of the Module inst is used..This should be set to true // if rastrace command is executed cliHandle->setModuleInstFlag(true); //Write the stuff into node output file string data = "=-=-=-=-=-= " + oneCmd.getType() + " " + nodeIP + " "; data.append(oneCmd.getSection() + " =-=-=-=-=-= "); pos=prepareCommand.find(";"); //string tmpCommand=prepareCommand.substr(pos+1); data.append(prepareCommand.substr(pos+1)); string totalOutput ; totalOutput.append("\nPERFSTAT_EPOCH: "); totalOutput.append(boost::lexical_cast(cmdStartTime)); totalOutput.append(perfstat::convert_EPOCH_to_gmtime(cmdStartTime)); totalOutput.append("\n"); (*outputHandle).writeDataToNodeFile(data, totalOutput); if(legacyModeFlag == false) { if(connectionStatus) { (*connectionHandle).readResponseFromFilerWithPoll(outputHandle); } } else { collectLegacyData(); } time_t cmdEndTime; time(&cmdEndTime); data="\n--- EXE-TIME of : " + prepareCommand + " : "; data.append(boost::lexical_cast(cmdEndTime - cmdStartTime) + " seconds"); (*outputHandle).writeDataToNodeFile(data); } //Check if the command is a Vfiler template command. else if(strstr(command.c_str(),"VFPATH") || strstr(command.c_str(),"VFNAME")) { //Now loop thru Vfilers data and execute this command for all the Vfilers existing on the controller map::const_iterator myMapIter = vfileData.begin(); while(myMapIter != vfileData.end()) { string tmpCommand = command; if(strstr(tmpCommand.c_str(),"VFPATH")) { pos=tmpCommand.find("VFPATH"); tmpCommand.replace(pos,6,myMapIter->second); } else { pos=tmpCommand.find("VFNAME"); tmpCommand.replace(pos,6,myMapIter->first); } //Now send the command to the controller if(legacyModeFlag == false) { connectionStatus = (*connectionHandle).sendCommandToFiler(tmpCommand); } else { sendLegacyCommand(tmpCommand); } //set stats start time string data = "=-=-=-=-=-= " + oneCmd.getType() + " " + nodeIP + " "; data.append(oneCmd.getSection() + " =-=-=-=-=-= "); pos=tmpCommand.find(";"); string tmpComm=tmpCommand.substr(pos+1); data.append(tmpComm); string totalOutput; totalOutput.append("\nPERFSTAT_EPOCH: "); totalOutput.append(boost::lexical_cast(cmdStartTime)); totalOutput.append(perfstat::convert_EPOCH_to_gmtime(cmdStartTime)); totalOutput.append("\n"); (*outputHandle).writeDataToNodeFile(data, totalOutput); if(legacyModeFlag == false) { if(connectionStatus) { (*connectionHandle).readResponseFromFilerWithPoll(outputHandle); } } else { collectLegacyData(); } time_t cmdEndTime; time(&cmdEndTime); data="\n--- EXE-TIME of : " + tmpComm + " : "; data.append(boost::lexical_cast(cmdEndTime - cmdStartTime) + " seconds"); (*outputHandle).writeDataToNodeFile(data); if((int)(cmdEndTime - cmdStartTime) > cmdRunTime) { longerRuntimeCmd.push_back(tmpComm); } ++myMapIter; } } else if(command.compare("AUTOSUPPORT") == 0) { // If Command is AUTOSUPPORT...Do nothing } else { time_t cmdEndTime; string data = ""; string totalOutput = ""; string delta = ""; ofstream* pfilePtr = NULL; bool bstatsStop = false; if(legacyModeFlag == false) { connectionStatus = (*connectionHandle).sendCommandToFiler(command); } else { sendLegacyCommand(command); connectionStatus= true; } if(connectionStatus) { // Check for stats start/wafl start /* if((oneCmd.getCommand().compare("stats start") == 0) || (oneCmd.getCommand().compare("wafltop start") == 0) ) { time ( &statsStartTime ); } */ //BURT 542949 if((oneCmd.getCommand()).find("stats start") != string::npos || (oneCmd.getCommand()).find("wafltop start") != string::npos) { time ( &statsStartTime ); } // Check for stats stop/wafl stop if(((oneCmd.getCommand()).find("stats stop") != string::npos) || ((oneCmd.getCommand()).find("wafltop stop") != string::npos) ) { delta = getStatsTimeDelta(); if(legacyModeFlag == false) { pfilePtr = outputHandle->createTempFile("tmp_stats"); } bstatsStop = true; } // Generic case for all except stats/wafl stop if(bstatsStop == false) { data = "=-=-=-=-=-= " + oneCmd.getType() + " " + nodeIP + " "; data.append(oneCmd.getSection() + " =-=-=-=-=-= "); string nameToAppend = oneCmd.getShortname(); if(nameToAppend.compare("") == 0) { nameToAppend = oneCmd.getCommand(); } data += nameToAppend; totalOutput = "\nPERFSTAT_EPOCH: "; totalOutput.append(boost::lexical_cast(cmdStartTime)); totalOutput.append(perfstat::convert_EPOCH_to_gmtime(cmdStartTime)); totalOutput.append("\n"); (*outputHandle).writeDataToNodeFile(data, totalOutput); } if(legacyModeFlag == false) { (*connectionHandle).readResponseFromFilerWithPoll(outputHandle, pfilePtr); } else { collectLegacyData(true, bstatsStop); } time(&cmdEndTime); if(bstatsStop == true) { //(*connectionHandle). //put_StderrToStdout(false); map > statsInformation; bool bstart = false; string fileName = outputHandle->getNodeDataDir(); if(legacyModeFlag == false) { fileName.append("/output.tmp_stats"); } else { fileName.append("/output.Legacy_Output"); } // Write the output of the file to the node output data = "=-=-=-=-=-= " + oneCmd.getType() + " " + nodeIP + " "; data.append(oneCmd.getSection()); data += " =-=-=-=-=-= stats.out"; totalOutput = "\nPERFSTAT_EPOCH: "; totalOutput.append(boost::lexical_cast(cmdStartTime)); totalOutput.append(boost::lexical_cast(delta)); totalOutput.append("\n"); (*outputHandle).writeDataToNodeFile(data, totalOutput); //outputHandle->MoveFromTempToDataFile("tmp_stats"); // The following piece of code can be replaced with MoveFromTempToDataFile ifstream inFile; inFile.open(fileName.c_str()); if(inFile.is_open()) { string dataLine; while (!inFile.eof() ) { getline(inFile,dataLine); outputHandle->writeDataToNodeFile(dataLine); } inFile.close(); } else { commonOutputHandle->writeDataToLogFile("ERROR", nodeIP, "Failed to open the file " + fileName); } data = "\n--- EXE-TIME of : " + oneCmd.getCommand() + " : "; data.append(boost::lexical_cast(cmdEndTime - cmdStartTime) + " seconds"); outputHandle->writeDataToNodeFile(data); //663869 perfstat8 crashed: double free or corruption !prev: 0xd95504e8 if(cliHandle->getstatformatflag()) { format_stats_output(cmdStartTime, boost::lexical_cast(delta), fileName, oneCmd.getType(), oneCmd.getSection()); } // BURT 535443 if(legacyModeFlag == false) { outputHandle->closeTempFile(pfilePtr); outputHandle->removeTempFile("tmp_stats"); } } else { //time(&cmdEndTime); data = "\n--- EXE-TIME of : " + oneCmd.getCommand() + " : "; data.append(boost::lexical_cast(cmdEndTime - cmdStartTime) + " seconds"); outputHandle->writeDataToNodeFile(data); } if((int)(cmdEndTime - cmdStartTime) > cmdRunTime) { longerRuntimeCmd.push_back(oneCmd.toString()); } } } } } catch(std::exception& e) { string tmp = "Exception : node : processOneCommand :"; tmp.append(e.what()); commonOutputHandle->writeDataToLogFile("ERROR", nodeIP, tmp); } } string node::getStatsTimeDelta() { time_t rawtime; struct tm * timeinfo; char buffer [80]; string timeStr; time ( &rawtime ); timeinfo = gmtime ( &rawtime ); strftime (buffer,80,"%a %b %d %H:%M:%S GMT %Y",timeinfo); timeStr = buffer; string data = "\nTIME: " + timeStr + "\nTIME_DELTA: "; if(statsStartTime < 0) { statsStartTime = 0; } time_t tmp = rawtime - statsStartTime; timeinfo = gmtime ( &tmp ); char nbuffer [80]; strftime (nbuffer,80,"%H:%M:%S",timeinfo); timeStr = nbuffer; data.append(timeStr + " (" + boost::lexical_cast(tmp) + "s)\n\n"); return data; } string node::generateFullCommand(presetMetaData presetCmd, bool nextSystemShellCommand) { string shell = presetCmd.getShell(); string command = presetCmd.getCommand(); string temp = "