From 4e6e5647ef182e3d5d71119e2f83b31a40a77e3b Mon Sep 17 00:00:00 2001 From: David Hill Date: Fri, 21 Sep 2018 10:40:05 -0500 Subject: [PATCH] MCOL-520 --- dbcon/joblist/resourcemanager.h | 7 ++++--- ddlproc/ddlproc.cpp | 4 +++- dmlproc/dmlproc.cpp | 3 ++- oamapps/serverMonitor/cpuMonitor.cpp | 20 +++++++++++++++----- oamapps/serverMonitor/hardwareMonitor.cpp | 11 ++++++++--- oamapps/serverMonitor/main.cpp | 8 ++++++++ oamapps/serverMonitor/memoryMonitor.cpp | 9 +++++++-- oamapps/serverMonitor/msgProcessor.cpp | 9 +++++++-- primitives/primproc/primproc.cpp | 3 ++- utils/idbdatafile/IDBPolicy.cpp | 22 +++++----------------- writeengine/splitter/we_cmdargs.cpp | 3 +-- 11 files changed, 62 insertions(+), 37 deletions(-) diff --git a/dbcon/joblist/resourcemanager.h b/dbcon/joblist/resourcemanager.h index 5d7a7e873..4a92a35b2 100644 --- a/dbcon/joblist/resourcemanager.h +++ b/dbcon/joblist/resourcemanager.h @@ -34,6 +34,7 @@ #include "configcpp.h" #include "calpontselectexecutionplan.h" #include "resourcedistributor.h" +#include "installdir.h" #include "atomicops.h" @@ -82,7 +83,7 @@ const uint32_t defaultProcessorThreadsPerScan = 16; const uint32_t defaultJoinerChunkSize = 16 * 1024 * 1024; //bucketreuse -const std::string defaultTempDiskPath = "/var/tmp"; +const std::string defaultTempDiskPath = "/tmp"; const std::string defaultWorkingDir = "."; //"/tmp"; //largedatalist @@ -282,7 +283,7 @@ public: std::string getScTempDiskPath() const { - return getStringVal(fSystemConfigStr, "TempDiskPath", defaultTempDiskPath ); + return startup::StartUp::tmpDir(); } uint64_t getScTempSaveSize() const { @@ -290,7 +291,7 @@ public: } std::string getScWorkingDir() const { - return getStringVal(fSystemConfigStr, "WorkingDir", defaultWorkingDir ); + return startup::StartUp::tmpDir(); } uint32_t getTwMaxSize() const diff --git a/ddlproc/ddlproc.cpp b/ddlproc/ddlproc.cpp index 03cbe08cd..e721462fe 100644 --- a/ddlproc/ddlproc.cpp +++ b/ddlproc/ddlproc.cpp @@ -62,6 +62,8 @@ using namespace execplan; #include "utils_utf8.h" #include "crashtrace.h" +#include "installdir.h" + namespace fs = boost::filesystem; @@ -71,7 +73,7 @@ DistributedEngineComm* Dec; void setupCwd() { - string workdir = config::Config::makeConfig()->getConfig("SystemConfig", "WorkingDir"); + string workdir = startup::StartUp::tmpDir(); if (workdir.length() == 0) workdir = "."; diff --git a/dmlproc/dmlproc.cpp b/dmlproc/dmlproc.cpp index 9c34dd7a5..dec752213 100644 --- a/dmlproc/dmlproc.cpp +++ b/dmlproc/dmlproc.cpp @@ -83,6 +83,7 @@ using namespace joblist; #include "utils_utf8.h" #include "crashtrace.h" +#include "installdir.h" namespace fs = boost::filesystem; @@ -493,7 +494,7 @@ void rollbackAll(DBRM* dbrm) void setupCwd() { - string workdir = Config::makeConfig()->getConfig("SystemConfig", "WorkingDir"); + string workdir = startup::StartUp::tmpDir(); if (workdir.length() == 0) workdir = "."; diff --git a/oamapps/serverMonitor/cpuMonitor.cpp b/oamapps/serverMonitor/cpuMonitor.cpp index 873de17c1..58c5bb24f 100644 --- a/oamapps/serverMonitor/cpuMonitor.cpp +++ b/oamapps/serverMonitor/cpuMonitor.cpp @@ -47,6 +47,8 @@ const int RESOURCE_DEBUG = false; static unsigned int usage[LOG_FREQ / MONITOR_FREQ]; static int usageCount = 0; +extern string tmpDir; + /***************************************************************************************** * @brief cpuMonitor Thread * @@ -518,10 +520,13 @@ void ServerMonitor::logCPUstat (int usageCount) void ServerMonitor::getCPUdata() { pcl.clear(); + + string tmpProcessCpu = tmpDir + "/processCpu"; + + string cmd = "top -b -n1 | head -12 | awk '{print $9,$12}' | tail -5 > " + tmpProcessCpu; + system(cmd.c_str()); - system("top -b -n1 | head -12 | awk '{print $9,$12}' | tail -5 > /tmp/columnstore_tmp_files/processCpu"); - - ifstream oldFile1 ("/tmp/columnstore_tmp_files/processCpu"); + ifstream oldFile1 (tmpProcessCpu); // read top 5 users int i = 0; @@ -547,9 +552,14 @@ void ServerMonitor::getCPUdata() // // get and check Total CPU usage // - system("top -b -n 6 -d 1 | awk '{print $5}' | grep %id > /tmp/columnstore_tmp_files/systemCpu"); + - ifstream oldFile ("/tmp/columnstore_tmp_files/systemCpu"); + string tmpsystemCpu = tmpDir + "/processCpu"; + + cmd = "top -b -n 6 -d 1 | awk '{print $5}' | grep %id > " + tmpsystemCpu; + system(cmd.c_str()); + + ifstream oldFile (tmpsystemCpu); float systemIdle = 0; // skip first line in file, and average the next 5 entries which contains idle times diff --git a/oamapps/serverMonitor/hardwareMonitor.cpp b/oamapps/serverMonitor/hardwareMonitor.cpp index 7beda22f4..8e6a19dc7 100644 --- a/oamapps/serverMonitor/hardwareMonitor.cpp +++ b/oamapps/serverMonitor/hardwareMonitor.cpp @@ -31,6 +31,8 @@ using namespace logging; using namespace servermonitor; //using namespace procheartbeat; +extern string tmpDir; + /************************************************************************************************************ * @brief hardwareMonitor function @@ -72,7 +74,10 @@ void hardwareMonitor(int IPMI_SUPPORT) if ( IPMI_SUPPORT == 0) { - int returnCode = system("ipmitool sensor list > /tmp/harwareMonitor.txt"); + string tmpharwareMonitor = tmpDir + "/harwareMonitor.txt"; + + string cmd = "ipmitool sensor list > > " + tmpharwareMonitor; + int returnCode = system(cmd.c_str()); if (returnCode) { @@ -128,7 +133,7 @@ void hardwareMonitor(int IPMI_SUPPORT) { // parse output file - ifstream File ("/tmp/harwareMonitor.txt"); + ifstream File (tmpharwareMonitor); if (!File) { @@ -137,7 +142,7 @@ void hardwareMonitor(int IPMI_SUPPORT) MessageLog ml(lid); Message msg; Message::Args args; - args.add("Error opening /tmp/harwareMonitor.txt!!!"); + args.add("Error opening harwareMonitor.txt!!!"); msg.format(args); ml.logWarningMessage(msg); sleep(300); diff --git a/oamapps/serverMonitor/main.cpp b/oamapps/serverMonitor/main.cpp index a4422aa04..6908cbe86 100644 --- a/oamapps/serverMonitor/main.cpp +++ b/oamapps/serverMonitor/main.cpp @@ -19,6 +19,7 @@ #include "serverMonitor.h" #include "crashtrace.h" +#include "installdir.h" using namespace std; using namespace servermonitor; @@ -27,6 +28,8 @@ using namespace logging; extern int swapFlag; +string tmpDir; + /***************************************************************************** * @brief main * @@ -39,6 +42,11 @@ int main (int argc, char** argv) { ServerMonitor serverMonitor; Oam oam; + + string TempFileDir; + oam.getSystemConfig("TempFileDir", TempFileDir); + + tmpDir = startup::StartUp::tmpDir() + TempFileDir; struct sigaction ign; diff --git a/oamapps/serverMonitor/memoryMonitor.cpp b/oamapps/serverMonitor/memoryMonitor.cpp index 0e120ed46..ec3d2fcb2 100644 --- a/oamapps/serverMonitor/memoryMonitor.cpp +++ b/oamapps/serverMonitor/memoryMonitor.cpp @@ -39,6 +39,8 @@ uint64_t totalMem; pthread_mutex_t MEMORY_LOCK; +extern string tmpDir; + /***************************************************************************************** * @brief memoryMonitor Thread * @@ -500,9 +502,12 @@ void ServerMonitor::outputProcMemory(bool log) // get top 5 Memory users by process // - system("ps -e -orss=1,args= | sort -b -k1,1n |tail -n 5 | awk '{print $1,$2}' > /tmp/columnstore_tmp_files/processMem"); + string tmpprocessMem = tmpDir + "/processMem"; + + string cmd = "ps -e -orss=1,args= | sort -b -k1,1n |tail -n 5 | awk '{print $1,$2}' > " + tmpprocessMem; + system(cmd.c_str()); - ifstream oldFile ("/tmp/columnstore_tmp_files/processMem"); + ifstream oldFile (tmpprocessMem); string process; long long memory; diff --git a/oamapps/serverMonitor/msgProcessor.cpp b/oamapps/serverMonitor/msgProcessor.cpp index aede14ace..9b66e0a6e 100644 --- a/oamapps/serverMonitor/msgProcessor.cpp +++ b/oamapps/serverMonitor/msgProcessor.cpp @@ -39,6 +39,8 @@ extern ProcessMemoryList pml; extern pthread_mutex_t CPU_LOCK; extern pthread_mutex_t MEMORY_LOCK; +extern string tmpDir; + /** * constants define */ @@ -252,9 +254,12 @@ void msgProcessor() ByteStream ackmsg; // get cache MEMORY stats - system("cat /proc/meminfo | grep Cached -m 1 | awk '{print $2}' > /tmp/cached"); + string tmpcached = tmpDir + "/cached"; + + string cmd = "cat /proc/meminfo | grep Cached -m 1 | awk '{print $2}' > " + tmpcached; + system(cmd.c_str()); - ifstream oldFile ("/tmp/cached"); + ifstream oldFile (tmpcached); string strCache; long long cache; diff --git a/primitives/primproc/primproc.cpp b/primitives/primproc/primproc.cpp index 1b19ccd0f..0ff38f0de 100644 --- a/primitives/primproc/primproc.cpp +++ b/primitives/primproc/primproc.cpp @@ -72,6 +72,7 @@ using namespace idbdatafile; #include "cgroupconfigurator.h" #include "crashtrace.h" +#include "installdir.h" namespace primitiveprocessor { @@ -147,7 +148,7 @@ void setupSignalHandlers() void setupCwd(Config* cf) { - string workdir = cf->getConfig("SystemConfig", "WorkingDir"); + string workdir = startup::StartUp::tmpDir(); if (workdir.length() == 0) workdir = "."; diff --git a/utils/idbdatafile/IDBPolicy.cpp b/utils/idbdatafile/IDBPolicy.cpp index 0514eca8b..7822bf891 100644 --- a/utils/idbdatafile/IDBPolicy.cpp +++ b/utils/idbdatafile/IDBPolicy.cpp @@ -34,6 +34,9 @@ #include "utils_utf8.h" #endif +#include "installdir.h" + + using namespace std; namespace idbdatafile @@ -213,23 +216,8 @@ void IDBPolicy::configIDBPolicy() } // Directory in which to place file buffer temporary files. - string hdfsRdwrScratch = cf->getConfig("SystemConfig", "hdfsRdwrScratch"); - - if ( hdfsRdwrScratch.length() == 0 ) - { - string tmpPath = cf->getConfig("SystemConfig", "TempDiskPath"); - - if ( tmpPath.length() == 0 ) - { - hdfsRdwrScratch = "/tmp/hdfsscratch"; - } - else - { - hdfsRdwrScratch = tmpPath; - hdfsRdwrScratch += "/hdfsscratch"; - } - - } + string tmpDir = startup::StartUp::tmpDir(); + string hdfsRdwrScratch = tmpDir + "/rdwrscratch"; IDBPolicy::init( idblog, bUseRdwrMemBuffer, hdfsRdwrScratch, hdfsRdwrBufferMaxSize ); diff --git a/writeengine/splitter/we_cmdargs.cpp b/writeengine/splitter/we_cmdargs.cpp index 41fe68e21..e64d9a4f9 100644 --- a/writeengine/splitter/we_cmdargs.cpp +++ b/writeengine/splitter/we_cmdargs.cpp @@ -1418,8 +1418,7 @@ std::string WECmdArgs::getTmpFileDir() { if (!fTmpFileDir.empty()) return fTmpFileDir; - fTmpFileDir = config::Config::makeConfig()->getConfig("SystemConfig", - "TempFileDir"); + fTmpFileDir = startup::StartUp::tmpDir() + "columnstore_tmp_files"; if (fTmpFileDir.empty()) throw( runtime_error("Config ERROR: TmpFileDir not found!!"));