From f417d8cfd32a6f6d182d1d82abeb8b7a1b4cbe70 Mon Sep 17 00:00:00 2001 From: David Hill Date: Wed, 19 Sep 2018 14:26:21 -0500 Subject: [PATCH] merge --- procmon/main.cpp | 14 +++---- procmon/processmonitor.cpp | 85 +++++++------------------------------- 2 files changed, 20 insertions(+), 79 deletions(-) diff --git a/procmon/main.cpp b/procmon/main.cpp index eb2e6dd1f..9e27f805d 100644 --- a/procmon/main.cpp +++ b/procmon/main.cpp @@ -344,6 +344,7 @@ int main(int argc, char** argv) // sleep (1); string cmd = startup::StartUp::installDir() + "/bin/infinidb stop > /dev/null 2>&1"; + system(cmd.c_str()); } @@ -437,7 +438,7 @@ int main(int argc, char** argv) } catch (...) { - log.writeLog(__LINE__, "wating for good return from getModuleStatus", LOG_TYPE_DEBUG); + log.writeLog(__LINE__, "waiting for good return from getModuleStatus", LOG_TYPE_DEBUG); sleep (1); } } @@ -553,6 +554,7 @@ int main(int argc, char** argv) if ( retry == 20 ) { log.writeLog(__LINE__, "Check DB mounts failed, shutting down", LOG_TYPE_CRITICAL); + //Set the alarm // aMonitor.sendAlarm(config.moduleName().c_str(), STARTUP_DIAGNOTICS_FAILURE, SET); // sleep (1); @@ -582,7 +584,7 @@ int main(int argc, char** argv) while (!mainResumeFlag) { - log.writeLog(__LINE__, "WATING FOR mainResumeFlag to be set", LOG_TYPE_DEBUG); + log.writeLog(__LINE__, "WAITING FOR mainResumeFlag to be set", LOG_TYPE_DEBUG); sleep(1); } @@ -1131,9 +1133,6 @@ static void messageThread(MonitorConfig config) string cmd = "fuser -k " + port + "/tcp >/dev/null 2>&1"; - if ( !rootUser) - cmd = "sudo fuser -k " + port + "/tcp >/dev/null 2>&1"; - system(cmd.c_str()); for (;;) @@ -2363,10 +2362,7 @@ static void statusControlThread() string port = sysConfig->getConfig(portName, "Port"); string cmd = "fuser -k " + port + "/tcp >/dev/null 2>&1"; - if ( !rootUser) - cmd = "sudo fuser -k " + port + "/tcp >/dev/null 2>&1"; - - system(cmd.c_str()); + system(cmd.c_str()); } catch (...) { diff --git a/procmon/processmonitor.cpp b/procmon/processmonitor.cpp index 2eb038189..2adf793be 100644 --- a/procmon/processmonitor.cpp +++ b/procmon/processmonitor.cpp @@ -1062,8 +1062,9 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO msg >> manualFlag; int requestStatus = oam::API_SUCCESS; log.writeLog(__LINE__, "MSG RECEIVED: Start All process request..."); - + //start the mysqld daemon + try { oam.actionMysqlCalpont(MYSQL_START); @@ -1762,20 +1763,10 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO if (!oam.checkLogStatus("/tmp/umount.txt", "busy")) break; - if ( rootUser) - { - cmd = "lsof " + startup::StartUp::installDir() + "/data" + dbrootID + " >> /tmp/umount.txt 2>&1"; - system(cmd.c_str()); - cmd = "fuser -muvf " + startup::StartUp::installDir() + "/data" + dbrootID + " >> /tmp/umount.txt 2>&1"; - system(cmd.c_str()); - } - else - { - cmd = "sudo lsof " + startup::StartUp::installDir() + "/data" + dbrootID + " >> /tmp/umount.txt 2>&1"; - system(cmd.c_str()); - cmd = "sudo fuser -muvf " + startup::StartUp::installDir() + "/data" + dbrootID + " >> /tmp/umount.txt 2>&1"; - system(cmd.c_str()); - } + cmd = "lsof " + startup::StartUp::installDir() + "/data" + dbrootID + " >> /tmp/umount.txt 2>&1"; + system(cmd.c_str()); + cmd = "fuser -muvf " + startup::StartUp::installDir() + "/data" + dbrootID + " >> /tmp/umount.txt 2>&1"; + system(cmd.c_str()); sleep(2); //Flush the cache @@ -1834,7 +1825,7 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO if ( !rootUser) { - cmd = "sudo chown -R " + USER + ":" + USER + " " + startup::StartUp::installDir() + "/data" + dbrootID + " > /dev/null"; + cmd = "chown -R " + USER + ":" + USER + " " + startup::StartUp::installDir() + "/data" + dbrootID + " > /dev/null"; system(cmd.c_str()); } @@ -1876,15 +1867,7 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO if (WEXITSTATUS(status) != 0 ) { - if ( rootUser) - { - cmd = "echo " + entry + " >> /etc/fstab"; - } - else - { - cmd = "sudo echo " + entry + " >> /etc/fstab"; - } - + cmd = "echo " + entry + " >> /etc/fstab"; system(cmd.c_str()); log.writeLog(__LINE__, "Add line entry to /etc/fstab : " + entry); @@ -1896,14 +1879,7 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO if (WEXITSTATUS(status) != 0 ) { - if ( rootUser) - { - cmd = "echo " + entry + " >> " + startup::StartUp::installDir() + "/local/etc/pm1/fstab"; - } - else - { - cmd = "sudo echo " + entry + " >> " + startup::StartUp::installDir() + "/local/etc/pm1/fstab"; - } + cmd = "echo " + entry + " >> " + startup::StartUp::installDir() + "/local/etc/pm1/fstab"; system(cmd.c_str()); @@ -1915,14 +1891,7 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO string::size_type pos1 = entry.find(" ", pos + 1); string directory = entry.substr(pos + 1, pos1 - pos); - if ( rootUser) - { - cmd = "mkdir " + directory; - } - else - { - cmd = "sudo mkdir " + directory; - } + cmd = "mkdir " + directory; system(cmd.c_str()); log.writeLog(__LINE__, "create directory: " + directory); @@ -3134,7 +3103,7 @@ int ProcessMonitor::updateLog(std::string action, std::string level) //if non-root, change file permissions so we can update it if ( !rootUser) { - string cmd = "sudo chmod 666 " + fileName + " > /dev/null"; + string cmd = "chmod 666 " + fileName + " > /dev/null"; system(cmd.c_str()); } @@ -5224,16 +5193,10 @@ int ProcessMonitor::changeMyCnf(std::string type) // set owner and permission string cmd = "chmod 664 " + mycnfFile + " >/dev/null 2>&1"; - if ( !rootUser) - cmd = "sudo chmod 644 " + mycnfFile + " >/dev/null 2>&1"; - system(cmd.c_str()); cmd = "chown mysql:mysql " + mycnfFile + " >/dev/null 2>&1"; - if ( !rootUser) - cmd = "sudo chown mysql:mysql " + mycnfFile + " >/dev/null 2>&1"; - system(cmd.c_str()); // restart mysql @@ -5987,10 +5950,7 @@ bool ProcessMonitor::amazonVolumeCheck(int dbrootID) { string cmd; - if ( rootUser) - cmd = "mount " + deviceName + " " + startup::StartUp::installDir() + "/mysql/db -t ext2 -o defaults > /tmp/um_mount.log"; - else - cmd = "sudo mount " + deviceName + " " + startup::StartUp::installDir() + "/mysql/db -t ext2 -o defaults > /tmp/um_mount.log"; + cmd = "mount " + deviceName + " " + startup::StartUp::installDir() + "/mysql/db -t ext2 -o defaults > /tmp/um_mount.log"; system(cmd.c_str()); log.writeLog(__LINE__, "mount cmd: " + cmd, LOG_TYPE_DEBUG); @@ -6399,7 +6359,7 @@ int ProcessMonitor::checkDataMount() if ( !rootUser) { - cmd = "sudo chown -R " + USER + ":" + USER + " " + dbroot + " > /dev/null"; + cmd = "chown -R " + USER + ":" + USER + " " + dbroot + " > /dev/null"; system(cmd.c_str()); } @@ -6573,16 +6533,8 @@ int ProcessMonitor::glusterAssign(std::string dbrootID) moduleIPAddr = sysConfig->getConfig("SystemModuleConfig", dataDupIPaddr); } - if ( rootUser) - { - command = "mount -tglusterfs -odirect-io-mode=enable " + moduleIPAddr + ":/dbroot" + + command = "mount -tglusterfs -odirect-io-mode=enable " + moduleIPAddr + ":/dbroot" + dbrootID + " " + startup::StartUp::installDir() + "/data" + dbrootID + " > /tmp/glusterAssign.txt 2>&1"; - } - else - { - command = "sudo mount -tglusterfs -odirect-io-mode=enable " + moduleIPAddr + ":/dbroot" + - dbrootID + " " + startup::StartUp::installDir() + "/data" + dbrootID + " > /tmp/glusterAssign.txt 2>&1"; - } int ret = system(command.c_str()); @@ -6624,14 +6576,7 @@ int ProcessMonitor::glusterUnassign(std::string dbrootID) log.writeLog(__LINE__, "glusterUnassign called: " + dbrootID, LOG_TYPE_DEBUG); - if ( rootUser) - { - command = "umount -f " + startup::StartUp::installDir() + "/data" + dbrootID + " > /tmp/glusterUnassign.txt 2>&1"; - } - else - { - command = "sudo umount -f " + startup::StartUp::installDir() + "/data" + dbrootID + " > /tmp/glusterUnassign.txt 2>&1"; - } + command = "umount -f " + startup::StartUp::installDir() + "/data" + dbrootID + " > /tmp/glusterUnassign.txt 2>&1"; int ret = system(command.c_str());