From ebd3b05c5d2c82419cf90c254df8044a958d3445 Mon Sep 17 00:00:00 2001 From: david hill Date: Mon, 10 Oct 2016 14:03:26 -0500 Subject: [PATCH] more changes --- oam/etc/Calpont.xml | 1 - oam/etc/Calpont.xml.singleserver | 1 - oam/etc/Columnstore.xml | 1 - oam/etc/Columnstore.xml.singleserver | 1 - oam/etc/ProcessConfig.xml | 79 ++---- oam/etc/ProcessConfig.xml.singleserver | 79 ++---- oam/install_scripts/post-install | 9 - oam/oamcpp/liboamcpp.cpp | 48 +--- oamapps/postConfigure/installer.cpp | 69 ----- oamapps/postConfigure/postConfigure.cpp | 193 ------------- procmgr/processmanager.cpp | 11 - procmon/processmonitor.cpp | 102 +------ snmpd/CMakeLists.txt | 1 - snmpd/snmpmanager/snmpglobal.h | 22 -- snmpd/snmpmanager/snmpmanager.cpp | 345 ------------------------ snmpd/snmpmanager/snmpmanager.h | 59 ---- tools/configMgt/autoConfigure.cpp | 9 +- 17 files changed, 49 insertions(+), 981 deletions(-) diff --git a/oam/etc/Calpont.xml b/oam/etc/Calpont.xml index 5350eafab..a63fe8127 100755 --- a/oam/etc/Calpont.xml +++ b/oam/etc/Calpont.xml @@ -449,7 +449,6 @@ unassigned unassigned autoassign - y unassigned unassigned unassigned diff --git a/oam/etc/Calpont.xml.singleserver b/oam/etc/Calpont.xml.singleserver index 5c9338fc5..eaed66037 100644 --- a/oam/etc/Calpont.xml.singleserver +++ b/oam/etc/Calpont.xml.singleserver @@ -438,7 +438,6 @@ unassigned unassigned rpm - y unassigned unassigned us-east-1 diff --git a/oam/etc/Columnstore.xml b/oam/etc/Columnstore.xml index b20dc0a6f..940e2ee77 100644 --- a/oam/etc/Columnstore.xml +++ b/oam/etc/Columnstore.xml @@ -449,7 +449,6 @@ unassigned unassigned autoassign - y unassigned unassigned unassigned diff --git a/oam/etc/Columnstore.xml.singleserver b/oam/etc/Columnstore.xml.singleserver index 3cc0832ca..5324cb892 100644 --- a/oam/etc/Columnstore.xml.singleserver +++ b/oam/etc/Columnstore.xml.singleserver @@ -438,7 +438,6 @@ unassigned unassigned rpm - y unassigned unassigned us-east-1 diff --git a/oam/etc/ProcessConfig.xml b/oam/etc/ProcessConfig.xml index 8b6a56f91..8a0c3618f 100644 --- a/oam/etc/ProcessConfig.xml +++ b/oam/etc/ProcessConfig.xml @@ -22,29 +22,6 @@ off - SNMPTrapDaemon - ParentOAMModule - $INSTALLDIR/sbin/snmptrapd - $INSTALLDIR/sbin/snmptrapd - -M - $INSTALLDIR/share/snmp/mibs - -m - $INSTALLDIR/share/snmp/mibs/CALPONT-MIB.txt - -c - $INSTALLDIR/etc/snmptrapd.conf - -C - -Lf - /var/log/mariadb/columnstore/snmptrapd.log - -p - /var/run/snmptrapd.pid - 1 - 3 - ProcessManager - @ - SIMPLEX - off - - DBRMControllerNode ParentOAMModule $INSTALLDIR/bin/controllernode @@ -56,26 +33,8 @@ @ SIMPLEX off - - - SNMPAgent - ChildOAMModule - $INSTALLDIR/sbin/snmpd - $INSTALLDIR/sbin/snmpd - -c - $INSTALLDIR/etc/snmpd.conf - -C - -Lf - /var/log/Calpont/snmpd.log - -p - /var/run/snmpd.pid - 0 - 0 - - LOADSHARE - off - - + + ServerMonitor ChildOAMModule $INSTALLDIR/bin/ServerMonitor @@ -85,8 +44,8 @@ LOADSHARE off - - + + DBRMWorkerNode ChildExtOAMModule $INSTALLDIR/bin/workernode @@ -98,8 +57,8 @@ LOADSHARE off - - + + DecomSvr pm /$INSTALLDIR/bin/DecomSvr @@ -108,8 +67,8 @@ LOADSHARE off - - + + PrimProc pm $INSTALLDIR/bin/PrimProc @@ -118,8 +77,8 @@ LOADSHARE off - - + + ExeMgr um $INSTALLDIR/bin/ExeMgr @@ -129,8 +88,8 @@ pm* LOADSHARE off - - + + WriteEngineServer pm $INSTALLDIR/bin/WriteEngineServer @@ -138,8 +97,8 @@ 40 LOADSHARE off - - + + DDLProc um $INSTALLDIR/bin/DDLProc @@ -153,8 +112,8 @@ * SIMPLEX off - - + + DMLProc um $INSTALLDIR/bin/DMLProc @@ -168,8 +127,8 @@ @ SIMPLEX off - - + + mysqld um $INSTALLDIR/mysql/libexec/mysqld @@ -178,5 +137,5 @@ LOADSHARE off - + diff --git a/oam/etc/ProcessConfig.xml.singleserver b/oam/etc/ProcessConfig.xml.singleserver index 82d622c53..b01ca5585 100644 --- a/oam/etc/ProcessConfig.xml.singleserver +++ b/oam/etc/ProcessConfig.xml.singleserver @@ -22,29 +22,6 @@ off - SNMPTrapDaemon - ParentOAMModule - /usr/local/mariadb/columnstore/sbin/snmptrapd - /usr/local/mariadb/columnstore/sbin/snmptrapd - -M - /usr/local/mariadb/columnstore/share/snmp/mibs - -m - /usr/local/mariadb/columnstore/share/snmp/mibs/CALPONT-MIB.txt - -c - /usr/local/mariadb/columnstore/etc/snmptrapd.conf - -C - -Lf - /usr/local/mariadb/columnstore/snmptrapd.log - -p - /var/run/snmptrapd.pid - 1 - 3 - ProcessManager - @ - SIMPLEX - off - - DBRMControllerNode ParentOAMModule /usr/local/mariadb/columnstore/bin/controllernode @@ -56,26 +33,8 @@ @ SIMPLEX off - - - SNMPAgent - ChildOAMModule - /usr/local/mariadb/columnstore/sbin/snmpd - /usr/local/mariadb/columnstore/sbin/snmpd - -c - /usr/local/mariadb/columnstore/etc/snmpd.conf - -C - -Lf - /usr/local/mariadb/columnstore/snmpd.log - -p - /var/run/snmpd.pid - 0 - 0 - - LOADSHARE - off - - + + ServerMonitor ChildOAMModule /usr/local/mariadb/columnstore/bin/ServerMonitor @@ -85,8 +44,8 @@ LOADSHARE off - - + + DBRMWorkerNode ChildExtOAMModule /usr/local/mariadb/columnstore/bin/workernode @@ -98,8 +57,8 @@ LOADSHARE off - - + + DecomSvr pm /usr/local/mariadb/columnstore/bin/DecomSvr @@ -108,8 +67,8 @@ LOADSHARE off - - + + PrimProc pm /usr/local/mariadb/columnstore/bin/PrimProc @@ -118,8 +77,8 @@ LOADSHARE off - - + + ExeMgr pm /usr/local/mariadb/columnstore/bin/ExeMgr @@ -129,8 +88,8 @@ pm* LOADSHARE off - - + + WriteEngineServer pm /usr/local/mariadb/columnstore/bin/WriteEngineServer @@ -138,8 +97,8 @@ 40 LOADSHARE off - - + + DDLProc um $INSTALLDIR/bin/DDLProc @@ -153,8 +112,8 @@ um* SIMPLEX off - - + + DMLProc um $INSTALLDIR/bin/DMLProc @@ -168,8 +127,8 @@ @ SIMPLEX off - - + + mysqld pm /usr/local/mariadb/columnstore/mysql/libexe/mysqld @@ -178,5 +137,5 @@ LOADSHARE off - + diff --git a/oam/install_scripts/post-install b/oam/install_scripts/post-install index ecb29c7bf..38ad26fe6 100755 --- a/oam/install_scripts/post-install +++ b/oam/install_scripts/post-install @@ -73,15 +73,6 @@ for lib in *.so.1.0.0; do done chown -h $user.$user *.so >/dev/null 2>&1 -if [ -f libnetsnmp.so.30.0.3 ]; then - for lib in *.so.30.0.3; do - blib=`basename $lib .30.0.3` - ln -sf $lib $blib - ln -sf $lib ${blib}.30 - done - chown -h $user.$user *.so *.so.30 >/dev/null 2>&1 -fi - if [ -f libstdc++.so.6.0.14 ]; then ln -sf libstdc++.so.6.0.14 libstdc++.so.6 chown -h $user.$user libstdc++.so.6 >/dev/null 2>&1 diff --git a/oam/oamcpp/liboamcpp.cpp b/oam/oamcpp/liboamcpp.cpp index 5fa07bbf0..9718b631c 100644 --- a/oam/oamcpp/liboamcpp.cpp +++ b/oam/oamcpp/liboamcpp.cpp @@ -250,18 +250,6 @@ namespace oam systemconfig.ParentOAMModule = sysConfig->getConfig(Section, "ParentOAMModuleName"); systemconfig.StandbyOAMModule = sysConfig->getConfig(Section, "StandbyOAMModuleName"); - // added by Zhixuan - try - { - SNMPManager sm; - sm.getNMSAddr (systemconfig.NMSIPAddr); - } - catch(...) - { - systemconfig.NMSIPAddr = UnassignedIpAddr; - } - // end - Section = "SessionManager"; systemconfig.MaxConcurrentTransactions = strtol(sysConfig->getConfig(Section, "MaxConcurrentTransactions").c_str(), 0, 0); @@ -857,24 +845,7 @@ namespace oam void Oam::getSystemConfig(const std::string&name, std::string& value) { - // added by Zhixuan - // special handle to NMSIPAddr, which is in snmpdx.conf file - if (name.compare("NMSIPAddr") == 0) - { - try - { - SNMPManager sm; - sm.getNMSAddr (value); - return; - } - catch(...) - { - // error with SM API - exceptionControl("getSystemConfig", API_FAILURE); - } - } - - + Config* sysConfig = Config::makeConfig(CalpontConfigFile.c_str()); // get string variables @@ -982,8 +953,6 @@ namespace oam void Oam::setSystemConfig(const std::string name, const std::string value) { - // added by Zhixuan - // special handle to SNMP config, which is in snmpdx.conf file string mem = "Mem"; string disk = "Disk"; string swap = "Swap"; @@ -992,21 +961,6 @@ namespace oam string major = "Major"; string minor = "Minor"; - if (name.find("NMSIPAddr") != string::npos) - { - try - { - SNMPManager sm; - sm.setNMSAddr (value); - return; - } - catch(...) - { - // error with SM API - exceptionControl("setSystemConfig", API_FAILURE); - } - } - Config* sysConfig = Config::makeConfig(CalpontConfigFile.c_str()); string returnValue; diff --git a/oamapps/postConfigure/installer.cpp b/oamapps/postConfigure/installer.cpp index 217e5d179..418830649 100644 --- a/oamapps/postConfigure/installer.cpp +++ b/oamapps/postConfigure/installer.cpp @@ -48,12 +48,10 @@ #include "liboamcpp.h" #include "configcpp.h" -#include "snmpmanager.h" using namespace std; using namespace oam; using namespace config; -using namespace snmpmanager; #include "helpers.h" using namespace installer; @@ -459,23 +457,6 @@ int main(int argc, char *argv[]) //create associated /local/etc directory for parentOAMModuleName cmd = "mkdir " + installDir + "/local/etc/" + parentOAMModuleName + " > /dev/null 2>&1"; system(cmd.c_str()); - - if (sysConfig->getConfig("Installation", "EnableSNMP") == "y") - { - //set SNMP Trap config file - string NMSIPAddress; - try { - NMSIPAddress = sysConfig->getConfig(SystemSection, "NMSIPAddress"); - - SNMPManager sm; - sm.setNMSAddr(NMSIPAddress); - } - catch(...) - { - cout << "ERROR: Problem getting NMSIPAddress from MariaDB Columnstore System Configuration file" << endl; - exit(1); - } - } } //Get list of configured system modules @@ -689,9 +670,6 @@ int main(int argc, char *argv[]) cmd = "chmod 755 -R " + installDir + "/data1/systemFiles/dbrm > /dev/null 2>&1"; system(cmd.c_str()); - - SNMPManager sm; - sm.updateSNMPD("parentOAMIPStub", parentOAMModuleIPAddr); } string idbstartcmd = installDir + "/bin/columnstore start"; @@ -959,53 +937,6 @@ bool setOSFiles(string parentOAMModuleName, int serverTypeInstall) return allfound; } -/* - * Updated snmpd.conf with parentOAMModuleIPAddr - */ -bool updateSNMPD(string parentOAMModuleIPAddr) -{ - string fileName = installDir + "/etc/snmpd.conf"; - - ifstream oldFile (fileName.c_str()); - if (!oldFile) return false; - - vector lines; - char line[200]; - string buf; - string newLine; - string newLine1; - while (oldFile.getline(line, 200)) - { - buf = line; - string::size_type pos = buf.find("parentOAMIPStub",0); - if (pos != string::npos) - { - newLine = buf.substr(0, pos); - newLine.append(parentOAMModuleIPAddr); - - newLine1 = buf.substr(pos+15, 200); - newLine.append(newLine1); - - buf = newLine; - } - //output to temp file - lines.push_back(buf); - } - - oldFile.close(); - unlink (fileName.c_str()); - ofstream newFile (fileName.c_str()); - - //create new file - int fd = open(fileName.c_str(), O_RDWR|O_CREAT, 0666); - - copy(lines.begin(), lines.end(), ostream_iterator(newFile, "\n")); - newFile.close(); - - close(fd); - return true; -} - /* * Create a module file */ diff --git a/oamapps/postConfigure/postConfigure.cpp b/oamapps/postConfigure/postConfigure.cpp index a35e85262..cc0cc7f42 100644 --- a/oamapps/postConfigure/postConfigure.cpp +++ b/oamapps/postConfigure/postConfigure.cpp @@ -21,8 +21,6 @@ * * * List of files being updated by post-install configure: -* mariadb/columnstore/etc/snmpd.conf -* mariadb/columnstore/etc/snmptrapd.conf * mariadb/columnstore/etc/Columnstore.xml * mariadb/columnstore/etc/ProcessConfig.xml * /etc/rc.local @@ -62,12 +60,10 @@ #include "liboamcpp.h" #include "configcpp.h" -#include "snmpmanager.h" using namespace std; using namespace oam; using namespace config; -using namespace snmpmanager; #include "helpers.h" using namespace installer; @@ -91,13 +87,11 @@ typedef struct Performance_Module_struct typedef std::vector PerformanceModuleList; -void snmpAppCheck(); void offLineAppCheck(); bool setOSFiles(string parentOAMModuleName, int serverTypeInstall); bool checkSaveConfigFile(); string getModuleName(); bool setModuleName(string moduleName); -bool updateSNMPD(string parentOAMModuleIPAddr); bool updateBash(); bool makeModuleFile(string moduleName, string parentOAMModuleName); bool updateProcessConfig(int serverTypeInstall); @@ -593,9 +587,6 @@ int main(int argc, char *argv[]) //check if dbrm data resides in older directory path and inform user if it does dbrmDirCheck(); - //check snmp Apps disable option - snmpAppCheck(); - if (startOfflinePrompt) offLineAppCheck(); @@ -2711,9 +2702,6 @@ int main(int argc, char *argv[]) exit(1); } - //check snmp Apps disable option - snmpAppCheck(); - //setup local OS Files if( !setOSFiles(parentOAMModuleName, IserverTypeInstall) ) { cout << "setOSFiles error" << endl; @@ -3806,53 +3794,6 @@ bool setOSFiles(string parentOAMModuleName, int serverTypeInstall) return allfound; } -/* - * Updated snmpdx.conf with parentOAMModuleIPAddr - */ -bool updateSNMPD(string parentOAMModuleIPAddr) -{ - string fileName = installDir + "/etc/snmpd.conf"; - - ifstream oldFile (fileName.c_str()); - if (!oldFile) return true; - - vector lines; - char line[200]; - string buf; - string newLine; - string newLine1; - while (oldFile.getline(line, 200)) - { - buf = line; - string::size_type pos = buf.find("parentOAMIPStub",0); - if (pos != string::npos) - { - newLine = buf.substr(0, pos); - newLine.append(parentOAMModuleIPAddr); - - newLine1 = buf.substr(pos+15, 200); - newLine.append(newLine1); - - buf = newLine; - } - //output to temp file - lines.push_back(buf); - } - - oldFile.close(); - unlink (fileName.c_str()); - ofstream newFile (fileName.c_str()); - - //create new file - int fd = open(fileName.c_str(), O_RDWR|O_CREAT, 0664); - - copy(lines.begin(), lines.end(), ostream_iterator(newFile, "\n")); - newFile.close(); - - close(fd); - return true; -} - /* * Update ProcessConfig.xml file for a single server configuration @@ -4992,140 +4933,6 @@ bool storageSetup(bool amazonInstall) return true; } -void snmpAppCheck() -{ - Oam oam; - - cout << endl << "===== MariaDB Columnstore SNMP-Trap Process Check =====" << endl << endl; - cout << "MariaDB Columnstore is packaged with an SNMP-Trap process." << endl; - cout << "If the system where MariaDB Columnstore is being installed already has an SNMP-Trap process" << endl; - cout << "running, then you have the option of disabling MariaDB Columnstore's SNMP-Trap process." << endl; - cout << "Not having the MariaDB Columnstore SNMP-Trap process will affect the" << endl; - cout << "generation of MariaDB Columnstore alarms and associated SNMP traps." << endl; - cout << "Please reference the MariaDB Columnstore Installation Guide for" << endl; - cout << "additional information." << endl << endl; - - string enableSNMP = "y"; - if (geteuid() == 0) - enableSNMP = sysConfig->getConfig(InstallSection, "EnableSNMP"); - else - enableSNMP = "n"; - - if (enableSNMP.empty()) - enableSNMP = "y"; - - while(true) - { - if ( enableSNMP == "y" ) { - string disable = "n"; - pcommand = callReadline("MariaDB Columnstore SNMP-Trap process is enabled, would you like to disable it [y,n] (n) > "); - if (pcommand) - { - if (strlen(pcommand) > 0) disable = pcommand; - callFree(pcommand); - } - - if ( disable == "y" ) { - enableSNMP = "n"; - break; - } - else if ( disable == "n" ) { - enableSNMP = "y"; - break; - } - - cout << "Invalid Entry, please retry" << endl; - if ( noPrompting ) - exit(1); - } - else - { - string enable = "n"; - pcommand = callReadline("MariaDB Columnstore SNMP-Trap process is disabled, would you like to enable it (y,n) [n] > "); - if (pcommand) - { - if (strlen(pcommand) > 0) enable = pcommand; - callFree(pcommand); - } - - if ( enable == "y" || enable == "n" ) { - enableSNMP = enable; - break; - } - - cout << "Invalid Entry, please retry" << endl; - if ( noPrompting ) - exit(1); - } - } - - sysConfig->setConfig(InstallSection, "EnableSNMP", enableSNMP); - - if (enableSNMP == "y") { - // - // Configure SNMP / NMS Addresses - // - try - { - oam.setProcessConfig("SNMPTrapDaemon", "ParentOAMModule", "BootLaunch", "1"); - oam.setProcessConfig("SNMPTrapDaemon", "ParentOAMModule", "LaunchID", "3"); - - cout << endl << "MariaDB Columnstore SNMP Process successfully enabled" << endl; - } - catch (exception& e) - { - cout << endl << "**** setProcessConfig Failed = " << e.what() << endl; - } - - //set OAM Parent IP Address in snmpd.conf - if( !updateSNMPD(parentOAMModuleIPAddr) ) - cout << "updateSNMPD error" << endl; - - //get and set NMS IP address - string currentNMSIPAddress; - string NMSIPAddress; - SNMPManager sm; - sm.getNMSAddr(currentNMSIPAddress); - - NMSIPAddress = currentNMSIPAddress; - - cout << endl << "===== Setup the Network Management System (NMS) Server Configuration =====" << endl << endl; - - cout << "This would be used to receive SNMP Traps from MariaDB Columnstore." << endl; - cout << "0.0.0.0 defaults to not sending off the system" << endl << endl; - prompt = "Enter IP Address(es) of where you want the SNMP Traps went (" + currentNMSIPAddress + ") > "; - pcommand = callReadline(prompt.c_str()); - if (pcommand) - { - if (strlen(pcommand) > 0) NMSIPAddress = pcommand; - callFree(pcommand); - } - - sm.setNMSAddr(NMSIPAddress); - } - else - { //disabled, update config file - try - { - oam.setProcessConfig("SNMPTrapDaemon", "ParentOAMModule", "BootLaunch", "0"); - oam.setProcessConfig("SNMPTrapDaemon", "ParentOAMModule", "LaunchID", "0"); - - cout << endl << "MariaDB Columnstore SNMP-Trap Process successfully disabled" << endl; - } - catch (exception& e) - { - cout << endl << "**** setProcessConfig Failed = " << e.what() << endl; - } - } - - if ( !writeConfig(sysConfig) ) { - cout << "ERROR: Failed trying to update MariaDB Columnstore System Configuration file" << endl; - exit(1); - } - - return; -} - void setSystemName() { diff --git a/procmgr/processmanager.cpp b/procmgr/processmanager.cpp index 9978bb051..3a16506b8 100644 --- a/procmgr/processmanager.cpp +++ b/procmgr/processmanager.cpp @@ -8575,17 +8575,6 @@ int ProcessManager::switchParentOAMModule(std::string newActiveModuleName) break; } - // stop local SNMPTrapDaemon - string EnableSNMP = "y"; - try { - oam.getSystemConfig("EnableSNMP", EnableSNMP); - } - catch(...) - {} - - if ( EnableSNMP == "y" ) - stopProcess(config.moduleName(), "SNMPTrapDaemon", oam::FORCEFUL, true); - // start processmanager on new active node startProcess(newActiveModuleName, "ProcessManager", oam::FORCEFUL); diff --git a/procmon/processmonitor.cpp b/procmon/processmonitor.cpp index f75fec17f..69719180e 100644 --- a/procmon/processmonitor.cpp +++ b/procmon/processmonitor.cpp @@ -1546,27 +1546,6 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO break; } - case UPDATESNMPD: - { - log.writeLog(__LINE__, "MSG RECEIVED: Update snmpd.conf file "); - - string oldIPAddr; - string newIPAddr; - - msg >> oldIPAddr; - msg >> newIPAddr; - - //update snmpd.conf - SNMPManager sm; - sm.updateSNMPD(oldIPAddr, newIPAddr); - - //reinit SNMPAgent - system("pkill -HUP snmpd"); - - log.writeLog(__LINE__, "UPDATESNMPD: ACK back to ProcMgr"); - - break; - } case RUNUPGRADE: { @@ -2252,16 +2231,6 @@ pid_t ProcessMonitor::startProcess(string processModuleType, string processName, }//end of FOR } - //Don't start certain processes if local module isn't Parent OAM PM - if ( processName == "SNMPTrapDaemon" || - processName == "DBRMControllerNode" ) { - if (!gOAMParentModuleFlag) { - log.writeLog(__LINE__, "Fail Restoral, not on Parent OAM module", LOG_TYPE_ERROR); - //local PM doesn't have the read/write mount - return oam::API_MINOR_FAILURE; - } - } - for (i=0; i < MAXARGUMENTS - 1; i++) { if (arg_list[i].length() == 0) @@ -2456,13 +2425,6 @@ pid_t ProcessMonitor::startProcess(string processModuleType, string processName, //sleep, give time for INIT state to be update, prevent race condition with ACTIVE sleep(1); - //delete any old pid file for snmp processes - if (processLocation.find("snmp") != string::npos) - { - string pidFileLocation = argList[numAugs-1]; - unlink (pidFileLocation.c_str()); - } - //check and setup for logfile time_t now; now = time(NULL); @@ -2521,60 +2483,15 @@ pid_t ProcessMonitor::startProcess(string processModuleType, string processName, updateProcessInfo(processName, oam::ACTIVE, newProcessID); } - if (processLocation.find("snmp") != string::npos) - { // snmp app is special........... - // wait for up to 30 seconds for the pid file to be created + //FYI - NEEDS TO STAY HERE TO HAVE newProcessID - //get snmp app pid which was stored when app was launched - //the location is the last augument - // open sometimes fail, so put in a retry loop + //record the process information into processList + config.buildList(processModuleType, processName, processLocation, arg_list, + launchID, newProcessID, initType, BootLaunch, RunType, + DepProcessName, DepModuleName, LogFile); - newProcessID = 0; - string pidFileLocation = argList[numAugs-1]; - - int i; - for (i=0; i < 30 ; i++) - { - sleep(1); - ifstream f(pidFileLocation.c_str(), ios::in); - - if (f.good()) - { - // store pid from PID file - f >> newProcessID; - //retry if pid is 0 - if (newProcessID == 0) - continue; - - break; - } - } - if (i == 30) { - log.writeLog(__LINE__, "FAILURE: no valid PID stored in " + pidFileLocation, LOG_TYPE_ERROR); - return oam::API_MINOR_FAILURE; - } - - //record the process information into processList - config.buildList(processModuleType, processName, processLocation, arg_list, - launchID, newProcessID, oam::ACTIVE, BootLaunch, RunType, - DepProcessName, DepModuleName, LogFile); - - //Update Process Status: Mark Process oam::ACTIVE state - updateProcessInfo(processName, oam::ACTIVE, newProcessID); - - } - else - { - //FYI - NEEDS TO STAY HERE TO HAVE newProcessID - - //record the process information into processList - config.buildList(processModuleType, processName, processLocation, arg_list, - launchID, newProcessID, initType, BootLaunch, RunType, - DepProcessName, DepModuleName, LogFile); - - //Update Process Status: Update PID - updateProcessInfo(processName, PID_UPDATE, newProcessID); - } + //Update Process Status: Update PID + updateProcessInfo(processName, PID_UPDATE, newProcessID); log.writeLog(__LINE__, processName + " PID is " + oam.itoa(newProcessID), LOG_TYPE_DEBUG); @@ -2619,8 +2536,7 @@ pid_t ProcessMonitor::startProcess(string processModuleType, string processName, } // open STDIN, STDOUT & STDERR for trapDaemon and DecomSvr - if (processName == "SNMPTrapDaemon" || - processName == "DecomSvr" ) + if (processName == "DecomSvr" ) { open("/dev/null", O_RDONLY); //Should be fd 0 open("/dev/null", O_WRONLY); //Should be fd 1 @@ -2690,7 +2606,7 @@ pid_t ProcessMonitor::startProcess(string processModuleType, string processName, /****************************************************************************************** * @brief reinitProcess * -* purpose: re-Init a process, an SNMP agent that will go re-read it's config file +* purpose: re-Init a process * ******************************************************************************************/ int ProcessMonitor::reinitProcess(pid_t processID, std::string processName, int actionIndicator) diff --git a/snmpd/CMakeLists.txt b/snmpd/CMakeLists.txt index 69eb31e08..f310533a5 100644 --- a/snmpd/CMakeLists.txt +++ b/snmpd/CMakeLists.txt @@ -1,4 +1,3 @@ -add_subdirectory(etc) add_subdirectory(snmpmanager) diff --git a/snmpd/snmpmanager/snmpglobal.h b/snmpd/snmpmanager/snmpglobal.h index 35dc300c9..7803001ba 100644 --- a/snmpd/snmpmanager/snmpglobal.h +++ b/snmpd/snmpmanager/snmpglobal.h @@ -26,20 +26,8 @@ #include #include -#ifndef SKIP_SNMP -#include -#include -#include -#else -typedef uint64_t oid; -#endif - namespace snmpmanager { -/** @brief oid type - *1, 3, 6, 1, 4, 1, 2021, 991 - */ -typedef oid CALPONT_OID; /** @brief constant define * @@ -51,16 +39,6 @@ const std::string ACTIVE_ALARM_FILE = "/var/log/mariadb/columnstore/activeAlarms const std::string ALARM_FILE = "/var/log/mariadb/columnstore/alarm.log"; const std::string ALARM_ARCHIVE_FILE = "/var/log/mariadb/columnstore/archive"; -const CALPONT_OID SNMPTRAP_OID [] = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 }; -const CALPONT_OID CALPONT_TRAP_OID [] = { 1, 3, 6, 1, 4, 1, 2021, 991 }; -const CALPONT_OID CALALARM_DATA_OID [] = { 1, 3, 6, 1, 4, 1, 2021, 991, 17 }; -const CALPONT_OID COMPONENT_ID_OID [] = { 1, 3, 6, 1, 4, 1, 2021, 991, 18 }; -const CALPONT_OID ALARM_ID_OID [] = { 1, 3, 6, 1, 4, 1, 2021, 991, 19 }; -const CALPONT_OID STATE_OID [] = { 1, 3, 6, 1, 4, 1, 2021, 991, 20 }; -const CALPONT_OID SNAME_OID [] = { 1, 3, 6, 1, 4, 1, 2021, 991, 21 }; -const CALPONT_OID PNAME_OID [] = { 1, 3, 6, 1, 4, 1, 2021, 991, 22 }; -const CALPONT_OID PID_OID [] = { 1, 3, 6, 1, 4, 1, 2021, 991, 23 }; -const CALPONT_OID TID_OID [] = { 1, 3, 6, 1, 4, 1, 2021, 991, 24 }; const bool CALPONT_SNMP_DEBUG = false; const uint16_t INVALID_ALARM_ID = 0; } diff --git a/snmpd/snmpmanager/snmpmanager.cpp b/snmpd/snmpmanager/snmpmanager.cpp index d17047cdb..06bdadc0e 100644 --- a/snmpd/snmpmanager/snmpmanager.cpp +++ b/snmpd/snmpmanager/snmpmanager.cpp @@ -644,351 +644,6 @@ void SNMPManager::getAlarm(std::string date, AlarmList& alarmList) const } } -/***************************************************************************************** -* @brief getNMSAddr API -* -* purpose: Get NMS IP Address from the snmptrapd config file -* -*****************************************************************************************/ -void SNMPManager::getNMSAddr (string& addr) -{ - getSNMPConfig (SNMPManager::parentOAMModuleName, TRAPD, "NMSADDR", addr); -} - -/***************************************************************************************** -* @brief setNMSAddr API -* -* purpose: Set NMS IP Address from the snmptrapd config file -* -*****************************************************************************************/ -void SNMPManager::setNMSAddr (const string addr) -{ - setSNMPConfig (SNMPManager::parentOAMModuleName, TRAPD, "NMSADDR", addr); -} - - -/***************************************************************************************** -* @brief setSNMPConfig API -* -* purpose: Set a SNMP monitoring threashold value in the snmpdx config file -* Set NMS IP Address in snmptrapd config file -* -* -*****************************************************************************************/ -void SNMPManager::setSNMPConfig (const string ModuleName, const std::string agentName, - const string paramName, const string value) -{ - string fileName; - makeFileName (agentName, fileName); - vector lines; - string calParamName = "CALPONT_" + paramName; - Oam oam; - - ifstream oldFile (fileName.c_str()); - if (!oldFile) throw runtime_error ("No configuration file found"); - - char line[200]; - string buf; - string changeValue; - string delimiters = " "; - while (oldFile.getline(line, 200)) - { - buf = line; - if (buf.find(calParamName) != string::npos) - { - lines.push_back(buf); - // change next line - oldFile.getline(line, 200); - buf = line; - - // if change NMS IP Addr to 0.0.0.0, then comment out forward line if not already - if ( paramName == "NMSADDR" && value == oam::UnassignedIpAddr ) { - string::size_type pos = buf.find("#", 0); - if ( string::npos == pos ) { - string templine = line; - buf = "#" + templine; - } - } - - // if change NMS IP Addr to NOT 0.0.0.0, then un-comment line if needed - if ( paramName == "NMSADDR" && value != oam::UnassignedIpAddr ) { - string::size_type pos = buf.find("#", 0); - if ( string::npos != pos ) - buf = buf.substr(1,200); - } - - string::size_type lastPos = buf.find_first_not_of(delimiters, 0); - string::size_type pos = buf.find_first_of(delimiters, lastPos); - - // find the last token, which is the value to be changed - while (string::npos != pos || string::npos != lastPos) - { - changeValue = buf.substr(lastPos, pos - lastPos); - lastPos = buf.find_first_not_of(delimiters, pos); - pos = buf.find_first_of(delimiters, lastPos); - } - pos = buf.find(changeValue); - buf.replace(pos, 20, value); - } - - // output to temp file - lines.push_back(buf); - } - - oldFile.close(); - unlink (fileName.c_str()); - ofstream newFile (fileName.c_str()); - - // create new file - int fd = open(fileName.c_str(),O_RDWR|O_CREAT, 0664); - - // Aquire an exclusive lock - if (flock(fd,LOCK_EX) == -1) { - throw runtime_error ("Lock SNMP configuration file error"); - } - - copy(lines.begin(), lines.end(), ostream_iterator(newFile, "\n")); - newFile.close(); - - // Release lock - if (flock(fd,LOCK_UN) == -1) - { - throw runtime_error ("Release lock SNMP configuration file error"); - } - close(fd); - - //re-init snmp processes - string processName; - makeProcessName (agentName, processName); - -/* try { - oam.reinitProcessType(processName); - } - catch(...) - {} -*/ -} - -/***************************************************************************************** -* @brief getSNMPConfig API -* -* purpose: Get a SNMP monitoring threashold value in the snmpdx config file -* -* paramName options: DISK_CRITICAL, DISK_MAJOR, DISK_MINOR -* MEM_CRITICAL, MEM_MAJOR, MEM_MINOR -* SWAP_CRITICAL, SWAP_MAJOR, SWAP_MINOR -* -*****************************************************************************************/ -void SNMPManager::getSNMPConfig (const string ModuleName, const std::string agentName, - const string paramName, string& value) -{ - string fileName; - makeFileName (agentName, fileName); - - ifstream configFile (fileName.c_str()); - char line[200]; - string buf; - string delimiters = " "; - string calParamName = "CALPONT_" + paramName; - - while (configFile.getline(line, 200)) - { - buf = line; - if (buf.find(calParamName) != string::npos) - { - configFile.getline(line, 200); - buf = line; - string::size_type lastPos = buf.find_first_not_of(delimiters, 0); - string::size_type pos = buf.find_first_of(delimiters, lastPos); - - // find the last token, which is the value to be read - while (string::npos != pos || string::npos != lastPos) - { - value = buf.substr(lastPos, pos - lastPos); - lastPos = buf.find_first_not_of(delimiters, pos); - pos = buf.find_first_of(delimiters, lastPos); - } - return; - } - } - throw runtime_error("Error processing snmptrapd configuration file"); -} - -/***************************************************************************************** -* @brief setSNMPModuleName API -* -* purpose: Set SNMP Module name in the snmpdx.conf file -* -*****************************************************************************************/ -void SNMPManager::setSNMPModuleName () -{ - // get current Module name - Oam oam; - string ModuleName; - oamModuleInfo_t st; - try { - st = oam.getModuleInfo(); - ModuleName = boost::get<0>(st); - } - catch (...) { - ModuleName = "Unknown Report Module"; - } - - string agentName = SUB_AGENT; - string fileName; - makeFileName (agentName, fileName); - vector lines; - - ifstream oldFile (fileName.c_str()); - if (!oldFile) throw runtime_error ("No configuration file found"); - - char line[200]; - string buf; - string newLine; - string newLine1; - string delimiters = " "; - while (oldFile.getline(line, 200)) - { - buf = line; - string::size_type pos = buf.find("ModuleNameStub",0); - if (pos != string::npos) - { - newLine = buf.substr(0, pos); - newLine.append(ModuleName); - - string::size_type pos1 = buf.find("|",pos); - if (pos1 != string::npos) - { - newLine1 = buf.substr(pos1, 200); - newLine.append(newLine1); - } - buf = newLine; - } - // output to temp file - lines.push_back(buf); - } - - oldFile.close(); - unlink (fileName.c_str()); - ofstream newFile (fileName.c_str()); - - // create new file - int fd = open(fileName.c_str(), O_RDWR|O_CREAT, 0664); - - // Aquire an exclusive lock - if (flock(fd,LOCK_EX) == -1) { - throw runtime_error ("Lock SNMP configuration file error"); - } - - copy(lines.begin(), lines.end(), ostream_iterator(newFile, "\n")); - newFile.close(); - - // Release lock - if (flock(fd,LOCK_UN) == -1) - { - throw runtime_error ("Release lock SNMP configuration file error"); - } - close(fd); -} - - -/** - * @brief Private functions definition - */ - -/***************************************************************************************** -* @brief makeFileName API -* -* purpose: returns path for associated snmp conf file -* -*****************************************************************************************/ -void SNMPManager::makeFileName (const std::string agentName, std::string& fileName) -{ - string defaultPath = startup::StartUp::installDir() + "/etc/"; - string localPath = startup::StartUp::installDir() + "/local/"; - if (agentName.compare (MASTER_AGENT) == 0) { - fileName = defaultPath; - fileName += "snmpd.conf"; - } - else if (agentName.compare (TRAPD) == 0) { - fileName = defaultPath; - fileName += "snmptrapd.conf"; - } - else { - fileName = localPath; - fileName += "snmpdx.conf"; - } -} - -/***************************************************************************************** -* @brief makeProcessName API -* -* purpose: returns process name for AGENT -* -*****************************************************************************************/ -void SNMPManager::makeProcessName (const std::string agentName, std::string& processName) -{ - if (agentName.compare (MASTER_AGENT) == 0) { - processName = "SNMPParentAgent"; - } - else if (agentName.compare (TRAPD) == 0) { - processName = "SNMPTrapDaemon"; - } - else { - processName = "SNMPSubagent"; - } -} - -/***************************************************************************************** -* @brief updateSNMPD API -* -* purpose: updates Parent OAm IP address in snmpd.conf file -* -*****************************************************************************************/ -void SNMPManager::updateSNMPD(std::string oldIPAddr, std::string parentOAMModuleIPAddr) -{ - string fileName = startup::StartUp::installDir() + "/etc/snmpd.conf"; - - ifstream oldFile (fileName.c_str()); - if (!oldFile) return; - - vector lines; - char line[200]; - string buf; - string newLine; - string newLine1; - while (oldFile.getline(line, 200)) - { - buf = line; - string::size_type pos = buf.find(oldIPAddr,0); - if (pos != string::npos) - { - newLine = buf.substr(0, pos); - newLine.append(parentOAMModuleIPAddr); - - newLine1 = buf.substr(pos + oldIPAddr.size(), 200); - newLine.append(newLine1); - - buf = newLine; - } - //output to temp file - lines.push_back(buf); - } - - oldFile.close(); - unlink (fileName.c_str()); - ofstream newFile (fileName.c_str()); - - //create new file - int fd = open(fileName.c_str(), O_RDWR|O_CREAT, 0664); - - copy(lines.begin(), lines.end(), ostream_iterator(newFile, "\n")); - newFile.close(); - - close(fd); - return; -} - } //namespace snmpmanager // vim:ts=4 sw=4: diff --git a/snmpd/snmpmanager/snmpmanager.h b/snmpd/snmpmanager/snmpmanager.h index 14e2fc30a..ba0b74c55 100644 --- a/snmpd/snmpmanager/snmpmanager.h +++ b/snmpd/snmpmanager/snmpmanager.h @@ -45,10 +45,6 @@ typedef std::multimap AlarmList; /** @brief constant define * */ -const std::string MASTER_AGENT = "MASTER"; -const std::string SUB_AGENT = "SUB"; -const std::string TRAPD = "TRAPD"; - /** @brief SNMPManager class interface * @@ -98,47 +94,6 @@ public: * * @param addr the reference to store addr */ - EXPORT void getNMSAddr (std::string& addr); - - /** @brief set NMS address for trapd - * - * @param addr the changed value - */ - EXPORT void setNMSAddr (const std::string addr); - - /** @brief get SNMP configuration in subagent config file - * - * @param ModuleName the Module the file resides on - * @param agentName the SNMP agent config file it resides in - * @param paramName the parameter to change - * @param value the reference to store value - */ - EXPORT void getSNMPConfig (const std::string ModuleName, - const std::string agentName, - const std::string paramName, - std::string& value); - - /** @brief set SNMP configuration in subagent config file - * - * @param ModuleName the Module the file resides on - * @param agentName the SNMP agent config file it resides in - * @param paramName the paramerter name to config - * @param value the changed value - */ - EXPORT void setSNMPConfig (const std::string ModuleName, - const std::string agentName, - const std::string paramName, - const std::string value); - - /** @brief set SNMP Module Name in subagent config file - * - */ - EXPORT void setSNMPModuleName (); - - /** @brief updates Parent OAm IP address in snmpd.conf file - * - */ - EXPORT void updateSNMPD(std::string oldIPAddr, std::string parentOAMModuleIPAddr); private: /** @brief copy ctor. keep private for now @@ -151,20 +106,6 @@ private: */ SNMPManager& operator=(const SNMPManager& rhs); - /** @brief make agent configuration file name - * - * @param agentName the snmp agent to change config - * @param fileName the reference to store the file name - */ - void makeFileName (const std::string agentName, std::string& fileName); - - /** @brief make agent configuration file name - * - * @param agentName the snmp agent to change config - * @param processName the process name for agent - */ - void makeProcessName (const std::string agentName, std::string& processName); - /** * this is to avoid running create_trap_session more than once. */ diff --git a/tools/configMgt/autoConfigure.cpp b/tools/configMgt/autoConfigure.cpp index 84976e4aa..bb02d6d43 100644 --- a/tools/configMgt/autoConfigure.cpp +++ b/tools/configMgt/autoConfigure.cpp @@ -432,20 +432,17 @@ int main(int argc, char *argv[]) catch(...) {} - //save EEPackageType and EnableSNMP + //save EEPackageType string EEPackageType = "rpm"; - string EnableSNMP = "y"; try { EEPackageType = sysConfigOld->getConfig(InstallSection, "EEPackageType"); - EnableSNMP = sysConfigOld->getConfig(InstallSection, "EnableSNMP"); } catch(...) { } try { sysConfigNew->setConfig(InstallSection, "EEPackageType", EEPackageType); - sysConfigNew->setConfig(InstallSection, "EnableSNMP", EnableSNMP); } catch(...) { } @@ -453,12 +450,8 @@ int main(int argc, char *argv[]) if ( EEPackageType.empty() ) EEPackageType = "rpm"; - if ( EnableSNMP.empty() ) - EnableSNMP = "y"; - try { sysConfigNew->setConfig(InstallSection, "EEPackageType", EEPackageType); - sysConfigNew->setConfig(InstallSection, "EnableSNMP", EnableSNMP); } catch(...) {}