1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-04-18 21:44:02 +03:00

MCOL-4193: Delete unused OAM and applications, ProcMon, ProcMgr, and no longer build all tools for packages

This commit is contained in:
benthompson15 2020-12-02 13:14:25 -06:00
parent d2cc656fdf
commit 846f7fb29b
138 changed files with 311 additions and 69494 deletions

View File

@ -202,7 +202,7 @@ ENDIF()
SET (ENGINE_LDFLAGS "-Wl,--no-as-needed -Wl,--add-needed")
SET (ENGINE_DT_LIB datatypes)
SET (ENGINE_COMMON_LIBS messageqcpp loggingcpp configcpp idbboot ${Boost_LIBRARIES} xml2 pthread rt libmysql_client ${ENGINE_DT_LIB})
SET (ENGINE_OAM_LIBS oamcpp alarmmanager)
SET (ENGINE_OAM_LIBS oamcpp)
SET (ENGINE_BRM_LIBS brm idbdatafile cacheutils rwlock ${ENGINE_OAM_LIBS} ${ENGINE_COMMON_LIBS})
SET (ENGINE_EXEC_LIBS joblist execplan windowfunction joiner rowgroup funcexp udfsdk regr dataconvert common compress querystats querytele thrift threadpool ${ENGINE_BRM_LIBS})
SET (ENGINE_WRITE_LIBS ddlpackageproc ddlpackage dmlpackageproc dmlpackage writeengine writeengineclient idbdatafile cacheutils ${ENGINE_EXEC_LIBS})
@ -261,7 +261,6 @@ SET (ENGINE_UTILS_COMMON_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/utils/common"
SET (ENGINE_UTILS_DATACONVERT_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/utils/dataconvert")
SET (ENGINE_UTILS_RWLOCK_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/utils/rwlock")
SET (ENGINE_UTILS_FUNCEXP_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/utils/funcexp")
SET (ENGINE_OAMAPPS_ALARMMANAGER_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/oamapps/alarmmanager")
SET (ENGINE_UTILS_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/utils")
SET (ENGINE_OAM_OAMCPP_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/oam/oamcpp")
SET (ENGINE_DBCON_DDLPKGPROC_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/dbcon/ddlpackageproc")

View File

@ -36,8 +36,6 @@
#include "we_messages.h"
#include "we_ddlcommandclient.h"
#include "oamcache.h"
#include "alarmglobal.h"
#include "alarmmanager.h"
#include "liboamcpp.h"
using namespace std;
using namespace WriteEngine;

View File

@ -61,8 +61,6 @@ using namespace config;
using namespace logging;
#include "liboamcpp.h"
#include "alarmmanager.h"
using namespace alarmmanager;
using namespace oam;
#include "jobstep.h"

View File

@ -290,7 +290,6 @@ extern "C"
long long rtn = 0;
Oam oam;
DBRM dbrm(true);
SystemStatus systemstatus;
try
{

View File

@ -213,40 +213,6 @@ int ServiceDDLProc::Child()
NotifyServiceStarted();
{
Oam oam;
try
{
oam.processInitComplete("DDLProc", ACTIVE);
}
catch (std::exception& ex)
{
cerr << ex.what() << endl;
LoggingID logid(23, 0, 0);
logging::Message::Args args1;
logging::Message msg(1);
args1.add("DDLProc init caught exception: ");
args1.add(ex.what());
msg.format( args1 );
logging::Logger logger(logid.fSubsysID);
logger.logMessage(LOG_TYPE_CRITICAL, msg, logid);
return 1;
}
catch (...)
{
cerr << "Caught unknown exception in init!" << endl;
LoggingID logid(23, 0, 0);
logging::Message::Args args1;
logging::Message msg(1);
args1.add("DDLProc init caught unknown exception");
msg.format( args1 );
logging::Logger logger(logid.fSubsysID);
logger.logMessage(LOG_TYPE_CRITICAL, msg, logid);
return 1;
}
}
try
{
ddlprocessor.process();

View File

@ -1,90 +1,52 @@
etc/columnstore/AlarmConfig.xml
etc/columnstore/Columnstore.xml
etc/columnstore/ConsoleCmds.xml
etc/columnstore/ErrorMessage.txt
etc/columnstore/MessageFile.txt
etc/columnstore/ProcessConfig.xml
etc/columnstore/storagemanager.cnf
etc/mysql/mariadb.conf.d/columnstore.cnf
usr/bin/DDLProc
usr/bin/DMLProc
usr/bin/ExeMgr
usr/bin/MCSInstanceCmds.sh
usr/bin/MCSVolumeCmds.sh
usr/bin/MCSgetCredentials.sh
usr/bin/PrimProc
usr/bin/ServerMonitor
usr/bin/StorageManager
usr/bin/WriteEngineServer
usr/bin/autoConfigure
usr/bin/bulklogReport.sh
usr/bin/clearShm
usr/bin/cleartablelock
usr/bin/columnstore
usr/bin/columnstore-post-install
usr/bin/columnstore-pre-uninstall
usr/bin/columnstoreClusterTester.sh
usr/bin/columnstoreDBWrite
usr/bin/columnstoreSupport
usr/bin/columnstoreSyslogSetup.sh
usr/bin/columnstore_installer
usr/bin/columnstore_module_installer.sh
usr/bin/columnstore_os_check.sh
usr/bin/columnstore_run.sh
usr/bin/colxml
usr/bin/configReport.sh
usr/bin/configxml.sh
usr/bin/controllernode
usr/bin/cpimport
usr/bin/cpimport.bin
usr/bin/cplogger
usr/bin/dbbuilder
usr/bin/dbmsReport.sh
usr/bin/dbrmctl
usr/bin/ddlcleanup
usr/bin/disable-rep-columnstore.sh
usr/bin/editem
usr/bin/getMySQLpw
usr/bin/hardwareReport.sh
usr/bin/idbmeminfo
usr/bin/load_brm
usr/bin/logReport.sh
usr/bin/mariadb-columnstore-start.sh
usr/bin/mariadb-columnstore-stop.sh
usr/bin/mariadb-command-line.sh
usr/bin/master-rep-columnstore.sh
usr/bin/mcs-savebrm.py
usr/bin/mcs-loadbrm.py
usr/bin/mcs-stop-controllernode.sh
usr/bin/mcsGetConfig
usr/bin/mcsSetConfig
usr/bin/mcs_module_installer.sh
usr/bin/mycnfUpgrade
usr/bin/os_detect.sh
usr/bin/post-mysql-install
usr/bin/post-mysqld-install
usr/bin/postConfigure
usr/bin/quick_installer_multi_server.sh
usr/bin/quick_installer_single_server.sh
usr/bin/remote_command.sh
usr/bin/remote_command_verify.sh
usr/bin/remote_scp_get.sh
usr/bin/remote_scp_put.sh
usr/bin/remotessh.exp
usr/bin/reset_locks
usr/bin/resourceReport.sh
usr/bin/rollback
usr/bin/rsync.sh
usr/bin/save_brm
usr/bin/slave-rep-columnstore.sh
usr/bin/smcat
usr/bin/smls
usr/bin/smput
usr/bin/smrm
usr/bin/startupTests.sh
usr/bin/testS3Connection
usr/bin/viewtablelock
usr/bin/workernode
usr/lib/*/libalarmmanager.so
usr/lib/*/libbatchloader.so
usr/lib/*/libbrm.so
usr/lib/*/libcacheutils.so
@ -134,7 +96,6 @@ usr/share/columnstore/columnstoreLogRotate
usr/share/columnstore/columnstoreSyslog
usr/share/columnstore/columnstoreSyslog-ng
usr/share/columnstore/columnstoreSyslog7
usr/share/columnstore/columnstore_functions
usr/share/columnstore/columnstore_info.sql
usr/share/columnstore/dumpcat_mysql.sql
usr/share/columnstore/gitversionEngine
@ -148,10 +109,6 @@ usr/share/columnstore/mcs-primproc.service
usr/share/columnstore/mcs-storagemanager.service
usr/share/columnstore/mcs-workernode.service
usr/share/columnstore/mcs-writeengineserver.service
usr/share/columnstore/mcstest-001.sh
usr/share/columnstore/mcstest-002.sh
usr/share/columnstore/mcstest-003.sh
usr/share/columnstore/mcstest-004.sh
usr/share/columnstore/myCnf-exclude-args.text
usr/share/columnstore/myCnf-include-args.text
usr/share/columnstore/releasenum

View File

@ -29,8 +29,6 @@
//#include "boost/filesystem/path.hpp"
using namespace std;
#include "alarmglobal.h"
#include "alarmmanager.h"
#include "liboamcpp.h"
#include <boost/scoped_ptr.hpp>
@ -216,14 +214,6 @@ void rollbackAll(DBRM* dbrm)
{
Oam oam;
try
{
alarmmanager::ALARMManager alarmMgr;
alarmMgr.sendAlarmReport("System", oam::ROLLBACK_FAILURE, alarmmanager::CLEAR);
}
catch (...)
{}
//Log a message in info.log
logging::Message::Args args;
logging::Message message(2);
@ -258,14 +248,6 @@ void rollbackAll(DBRM* dbrm)
throw std::runtime_error(IDBErrorInfo::instance()->errorMsg(ERR_HARD_FAILURE));
}
// If there are tables to rollback, set to ROLLBACK_INIT.
// This tells ProcMgr that we are rolling back and will be
// a while. A message to this effect should be printed.
if (tableLocks.size() > 0)
{
oam.processInitComplete("DMLProc", oam::ROLLBACK_INIT);
}
uint64_t uniqueId = dbrm->getUnique64();
RollbackTransactionProcessor rollbackProcessor(dbrm);
std::string errorMsg;
@ -368,15 +350,6 @@ void rollbackAll(DBRM* dbrm)
oss << " problem with rollback transaction " << tableLocks[i].ownerTxnID << "and DBRM is setting to readonly and table lock is not released: " << errorMsg;
rc = dbrm->setReadOnly(true);
//Raise an alarm
try
{
alarmmanager::ALARMManager alarmMgr;
alarmMgr.sendAlarmReport("System", oam::ROLLBACK_FAILURE, alarmmanager::SET);
}
catch (...)
{}
//Log to critical log
logging::Message::Args args6;
logging::Message message6(2);
@ -464,7 +437,6 @@ void rollbackAll(DBRM* dbrm)
if (txnList.size() > 0)
{
oam.processInitComplete("DMLProc", oam::ROLLBACK_INIT);
ostringstream oss;
oss << "DMLProc will rollback " << txnList.size() << " transactions.";
logging::Message::Args args2;
@ -509,15 +481,6 @@ void rollbackAll(DBRM* dbrm)
oss << " problem with rollback transaction " << txnId.id << "and DBRM is setting to readonly and table lock is not released: " << errorMsg;
rc = dbrm->setReadOnly(true);
//Raise an alarm
try
{
alarmmanager::ALARMManager alarmMgr;
alarmMgr.sendAlarmReport("System", oam::ROLLBACK_FAILURE, alarmmanager::SET);
}
catch (...)
{}
//Log to critical log
logging::Message::Args args6;
logging::Message message6(2);
@ -637,39 +600,6 @@ int ServiceDMLProc::Child()
idbdatafile::IDBPolicy::configIDBPolicy();
#endif
try
{
// At first we set to BUSY_INIT
oam.processInitComplete("DMLProc", oam::BUSY_INIT);
}
catch (std::exception& ex)
{
cerr << ex.what() << endl;
LoggingID logid(21, 0, 0);
logging::Message::Args args1;
logging::Message msg(1);
args1.add("DMLProc init caught exception: ");
args1.add(ex.what());
msg.format( args1 );
logging::Logger logger(logid.fSubsysID);
logger.logMessage(LOG_TYPE_CRITICAL, msg, logid);
NotifyServiceInitializationFailed();
return 1;
}
catch (...)
{
cerr << "Caught unknown exception in init!" << endl;
LoggingID logid(21, 0, 0);
logging::Message::Args args1;
logging::Message msg(1);
args1.add("DMLProc init caught unknown exception");
msg.format( args1 );
logging::Logger logger(logid.fSubsysID);
logger.logMessage(LOG_TYPE_CRITICAL, msg, logid);
NotifyServiceInitializationFailed();
return 1;
}
//@Bug 1627
try
{
@ -677,15 +607,6 @@ int ServiceDMLProc::Child()
}
catch ( std::exception& e )
{
//@Bug 2299 Set DMLProc process to fail and log a message
try
{
oam.processInitFailure();
}
catch (...)
{
}
logging::Message::Args args;
logging::Message message(2);
args.add("DMLProc failed to start due to :");
@ -760,37 +681,6 @@ int ServiceDMLProc::Child()
DMLServer::fDmlPackagepool.invoke(threadpool::ThreadPoolMonitor(&DMLServer::fDmlPackagepool));
}
//set ACTIVE state
try
{
oam.processInitComplete("DMLProc", ACTIVE);
}
catch (std::exception& ex)
{
cerr << ex.what() << endl;
LoggingID logid(21, 0, 0);
logging::Message::Args args1;
logging::Message msg(1);
args1.add("DMLProc init caught exception: ");
args1.add(ex.what());
msg.format( args1 );
logging::Logger logger(logid.fSubsysID);
logger.logMessage(LOG_TYPE_CRITICAL, msg, logid);
return 1;
}
catch (...)
{
cerr << "Caught unknown exception in init!" << endl;
LoggingID logid(21, 0, 0);
logging::Message::Args args1;
logging::Message msg(1);
args1.add("DMLProc init caught unknown exception");
msg.format( args1 );
logging::Logger logger(logid.fSubsysID);
logger.logMessage(LOG_TYPE_CRITICAL, msg, logid);
return 1;
}
Dec = DistributedEngineComm::instance(rm);
setupChildSignalHandlers();

View File

@ -1354,27 +1354,9 @@ void added_a_pm(int)
if (ec)
{
//set BUSY_INIT state while processing the add pm configuration change
oam::Oam oam;
try
{
oam.processInitComplete("ExeMgr", oam::BUSY_INIT);
}
catch (...)
{}
oam::OamCache* oamCache = oam::OamCache::makeOamCache();
oamCache->forceReload();
ec->Setup();
//set ACTIVE state
try
{
oam.processInitComplete("ExeMgr");
}
catch (...)
{}
}
}
@ -1514,19 +1496,6 @@ int ServiceExeMgr::Child()
gDebug= m_debug;
//set BUSY_INIT state
{
oam::Oam oam;
try
{
oam.processInitComplete("ExeMgr", oam::BUSY_INIT);
}
catch (...)
{
}
}
#ifdef _MSC_VER
//FIXME:
#else
@ -1576,14 +1545,6 @@ int ServiceExeMgr::Child()
ml.logCriticalMessage( message );
std::cerr << errMsg << std::endl;
try
{
oam.processInitFailure();
}
catch (...)
{
}
NotifyServiceInitializationFailed();
return 2;
}
@ -1686,19 +1647,6 @@ int ServiceExeMgr::Child()
", qs = " << rm->getEmExecQueueSize() << ", mx = " << maxPct << ", cf = " <<
rm->getConfig()->configFile() << std::endl;
//set ACTIVE state
{
oam::Oam oam;
try
{
oam.processInitComplete("ExeMgr");
}
catch (...)
{
}
}
{
BRM::DBRM *dbrm = new BRM::DBRM();
dbrm->setSystemQueryReady(true);

View File

@ -1,6 +1,4 @@
add_subdirectory(etc)
add_subdirectory(post)
add_subdirectory(install_scripts)
add_subdirectory(cloud)

View File

@ -1,4 +0,0 @@
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/MCSVolumeCmds.sh.in" "${CMAKE_CURRENT_SOURCE_DIR}/MCSVolumeCmds.sh" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/MCSInstanceCmds.sh.in" "${CMAKE_CURRENT_SOURCE_DIR}/MCSInstanceCmds.sh" @ONLY)
install(PROGRAMS MCSInstanceCmds.sh MCSVolumeCmds.sh MCSgetCredentials.sh DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine)

View File

@ -1,328 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: AlarmConfig.xml 3702 2013-08-06 22:29:48Z bpaul $ -->
<Columnstore Version="V1.0.0">
<AlarmConfig1>
<AlarmID>1</AlarmID>
<BriefDesc>CPU_USAGE_HIGH</BriefDesc>
<DetailedDesc>The usage on the indicated CPU has exceeded its high threshold</DetailedDesc>
<Severity>1</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig1>
<AlarmConfig2>
<AlarmID>2</AlarmID>
<BriefDesc>CPU_USAGE_MED</BriefDesc>
<DetailedDesc>The usage on the indicated CPU has exceeded its medium threshold</DetailedDesc>
<Severity>2</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig2>
<AlarmConfig3>
<AlarmID>3</AlarmID>
<BriefDesc>CPU_USAGE_LOW</BriefDesc>
<DetailedDesc>The usage on the indicated CPU has exceeded its low threshold</DetailedDesc>
<Severity>3</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig3>
<AlarmConfig4>
<AlarmID>4</AlarmID>
<BriefDesc>DISK_USAGE_HIGH</BriefDesc>
<DetailedDesc>The usage on the indicated Disk Drive has exceeded its high threshold</DetailedDesc>
<Severity>1</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig4>
<AlarmConfig5>
<AlarmID>5</AlarmID>
<BriefDesc>DISK_USAGE_MED</BriefDesc>
<DetailedDesc>The usage on the indicated DISK Drive has exceeded its medium threshold</DetailedDesc>
<Severity>2</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig5>
<AlarmConfig6>
<AlarmID>6</AlarmID>
<BriefDesc>DISK_USAGE_LOW</BriefDesc>
<DetailedDesc>The usage on the indicated Disk Drive has exceeded its low threshold</DetailedDesc>
<Severity>3</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig6>
<AlarmConfig7>
<AlarmID>7</AlarmID>
<BriefDesc>MEMORY_USAGE_HIGH</BriefDesc>
<DetailedDesc>The usage on the indicated Memory has exceeded its high threshold</DetailedDesc>
<Severity>1</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig7>
<AlarmConfig8>
<AlarmID>8</AlarmID>
<BriefDesc>MEMORY_USAGE_MED</BriefDesc>
<DetailedDesc>The usage on the indicated Memory has exceeded its medium threshold</DetailedDesc>
<Severity>2</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig8>
<AlarmConfig9>
<AlarmID>9</AlarmID>
<BriefDesc>MEMORY_USAGE_LOW</BriefDesc>
<DetailedDesc>The usage on the indicated Memory has exceeded its low threshold</DetailedDesc>
<Severity>3</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig9>
<AlarmConfig10>
<AlarmID>10</AlarmID>
<BriefDesc>SWAP_USAGE_HIGH</BriefDesc>
<DetailedDesc>The usage on the indicated Swap has exceeded its high threshold</DetailedDesc>
<Severity>1</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig10>
<AlarmConfig11>
<AlarmID>11</AlarmID>
<BriefDesc>SWAP_USAGE_MED</BriefDesc>
<DetailedDesc>The usage on the indicated Swap has exceeded its medium threshold</DetailedDesc>
<Severity>2</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig11>
<AlarmConfig12>
<AlarmID>12</AlarmID>
<BriefDesc>SWAP_USAGE_LOW</BriefDesc>
<DetailedDesc>The usage on the indicated Swap has exceeded its low threshold</DetailedDesc>
<Severity>3</Severity>
<EmailAddr>NONE</EmailAddr>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig12>
<AlarmConfig13>
<AlarmID>13</AlarmID>
<BriefDesc>PROCESS_DOWN_AUTO</BriefDesc>
<DetailedDesc>Process is auto out-of-service</DetailedDesc>
<Severity>2</Severity>
<EmailAddr>NONE</EmailAddr>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig13>
<AlarmConfig14>
<AlarmID>14</AlarmID>
<BriefDesc>MODULE_DOWN_AUTO</BriefDesc>
<DetailedDesc>Module is auto out-of-service</DetailedDesc>
<Severity>1</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig14>
<AlarmConfig15>
<AlarmID>15</AlarmID>
<BriefDesc>SYSTEM_DOWN_AUTO</BriefDesc>
<DetailedDesc>System is auto out-of-service</DetailedDesc>
<Severity>1</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig15>
<AlarmConfig16>
<AlarmID>16</AlarmID>
<BriefDesc>POWERON_TEST_SEVERE</BriefDesc>
<DetailedDesc>A Module Power-On Severe Warning error occurred. Test Failures indicate that the system is running in a degraded state</DetailedDesc>
<Severity>2</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig16>
<AlarmConfig17>
<AlarmID>17</AlarmID>
<BriefDesc>POWERON_TEST_WARNING</BriefDesc>
<DetailedDesc>A Module Power-On Warning error occurred. Test Failures indicate that the system is running with little or no degradation in performance</DetailedDesc>
<Severity>4</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig17>
<AlarmConfig18>
<AlarmID>18</AlarmID>
<BriefDesc>HARDWARE_HIGH</BriefDesc>
<DetailedDesc>A Hardware Device's resource has exceeded its high threshold</DetailedDesc>
<Severity>1</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig18>
<AlarmConfig19>
<AlarmID>19</AlarmID>
<BriefDesc>HARDWARE_MED</BriefDesc>
<DetailedDesc>A Hardware Device's resource has exceeded its medium threshold</DetailedDesc>
<Severity>2</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig19>
<AlarmConfig20>
<AlarmID>20</AlarmID>
<BriefDesc>HARDWARE_LOW</BriefDesc>
<DetailedDesc>A Hardware Device's resource has exceeded its low threshold</DetailedDesc>
<Severity>3</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig20>
<AlarmConfig21>
<AlarmID>21</AlarmID>
<BriefDesc>PROCESS_DOWN_MANUAL</BriefDesc>
<DetailedDesc>Process is manually out-of-service</DetailedDesc>
<Severity>3</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig21>
<AlarmConfig22>
<AlarmID>22</AlarmID>
<BriefDesc>MODULE_DOWN_MANUAL</BriefDesc>
<DetailedDesc>Module is manually out-of-service</DetailedDesc>
<Severity>2</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig22>
<AlarmConfig23>
<AlarmID>23</AlarmID>
<BriefDesc>SYSTEM_DOWN_MANUAL</BriefDesc>
<DetailedDesc>System is manually out-of-service</DetailedDesc>
<Severity>1</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig23>
<AlarmConfig24>
<AlarmID>24</AlarmID>
<BriefDesc>EXT_DEVICE_DOWN_AUTO</BriefDesc>
<DetailedDesc>External Device is auto out-of-service</DetailedDesc>
<Severity>2</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig24>
<AlarmConfig25>
<AlarmID>25</AlarmID>
<BriefDesc>PROCESS_INIT_FAILURE</BriefDesc>
<DetailedDesc>Process Initialzation failed or Timed-out</DetailedDesc>
<Severity>2</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig25>
<AlarmConfig26>
<AlarmID>26</AlarmID>
<BriefDesc>NIC_DOWN_AUTO</BriefDesc>
<DetailedDesc>NIC Interface is auto out-of-service</DetailedDesc>
<Severity>2</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig26>
<AlarmConfig27>
<AlarmID>27</AlarmID>
<BriefDesc>DBRM_LOAD_DATA_ERROR</BriefDesc>
<DetailedDesc>Error occurred loading DBRM data</DetailedDesc>
<Severity>1</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig27>
<AlarmConfig28>
<AlarmID>28</AlarmID>
<BriefDesc>INVALID_SW_VERSION</BriefDesc>
<DetailedDesc>Invalid Software Version found on a module. It doesn't match the version running on the Director Module</DetailedDesc>
<Severity>1</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig28>
<AlarmConfig29>
<AlarmID>29</AlarmID>
<BriefDesc>STARTUP_DIAGNOTICS_FAILURE</BriefDesc>
<DetailedDesc>A Failure occurred when the System Startup Diagnostics was executed on a Module. The log files can be viewed for details on the failure.</DetailedDesc>
<Severity>1</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig29>
<AlarmConfig30>
<AlarmID>30</AlarmID>
<BriefDesc>CONN_FAILURE</BriefDesc>
<DetailedDesc>A Connection Failure occurred that could affect the performance of the system processing.</DetailedDesc>
<Severity>1</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig30>
<AlarmConfig31>
<AlarmID>31</AlarmID>
<BriefDesc>DBRM_READ_ONLY</BriefDesc>
<DetailedDesc>The DBRM is now read-only and updates to the database are not possible.</DetailedDesc>
<Severity>1</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig31>
<AlarmConfig32>
<AlarmID>32</AlarmID>
<BriefDesc>Unassigned</BriefDesc>
<DetailedDesc>Unassigned</DetailedDesc>
<Severity>0</Severity>
<Threshold>0</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig32>
<AlarmConfig33>
<AlarmID>33</AlarmID>
<BriefDesc>MODULE_SWITCH_ACTIVE</BriefDesc>
<DetailedDesc>An outage of Parent OAM Module or the execution of the switchParentOAMModule command initiated a change of the Parent OAM Module.</DetailedDesc>
<Severity>1</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig33>
<AlarmConfig34>
<AlarmID>34</AlarmID>
<BriefDesc>ROLLBACK_FAILURE</BriefDesc>
<DetailedDesc>A Database Rollback Failure occurred, Contact MariaDB Customer Support.</DetailedDesc>
<Severity>1</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig34>
<AlarmConfig35>
<AlarmID>35</AlarmID>
<BriefDesc>GLUSTER_DISK_FAILURE</BriefDesc>
<DetailedDesc>An Error was reported on a Gluster disk copy.</DetailedDesc>
<Severity>1</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig35>
<AlarmConfig36>
<AlarmID>36</AlarmID>
<BriefDesc>INVALID_LOCALE</BriefDesc>
<DetailedDesc>An Error was reported on setting system locale.</DetailedDesc>
<Severity>1</Severity>
<Threshold>100</Threshold>
<Occurrences>0</Occurrences>
<LastIssueTime>0</LastIssueTime>
</AlarmConfig36>
</Columnstore>

View File

@ -1,7 +1,3 @@
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ProcessConfig.xml.in" "${CMAKE_CURRENT_SOURCE_DIR}/ProcessConfig.xml" @ONLY)
install(FILES AlarmConfig.xml
Columnstore.xml
ProcessConfig.xml
ConsoleCmds.xml
install(FILES Columnstore.xml
DESTINATION ${ENGINE_SYSCONFDIR}/columnstore COMPONENT columnstore-engine)

View File

@ -1,431 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: ConsoleCmds.xml 3331 2012-10-24 21:12:27Z dhill $ -->
<Columnstore Version="V1.0.0">
<Cmd0>
<Name>help</Name>
<Desc1>Get help on the Console Commands</Desc1>
<Arg1>No Argument or '-a' will display a list of Console commands</Arg1>
<Arg2>Optional: '-v' will display a list of Console commands with their descriptions</Arg2>
<Arg3>Optional: Command-name will display the command description</Arg3>
</Cmd0>
<Cmd1>
<Name>?</Name>
<Desc1>Get help on the Console Commands</Desc1>
<Arg1>No Argument, '-a', or '-all' will display a list of Console commands</Arg1>
<Arg2>Optional: '-v' or '-verbose' will display a list of Console commands with their descriptions</Arg2>
<Arg3>Optional: Command-name will display the command description</Arg3>
</Cmd1>
<Cmd2>
<Name>exit</Name>
<Desc1>Exit from the Console tool</Desc1>
<Arg1>None</Arg1>
</Cmd2>
<Cmd3>
<Name>quit</Name>
<Desc1>Exit from the Console tool</Desc1>
<Arg1>None</Arg1>
</Cmd3>
<Cmd4>
<Name>redistributeData</Name>
<Desc1>Redistribute table data accross all dbroots to balance disk usage</Desc1>
<Arg1>START to begin a redistribution</Arg1>
<Arg2>STOP to stop redistribution before completion</Arg2>
<Arg3>STATUS to to view statistics and progress</Arg3>
<Arg4>START REMOVE to redistribute and move data off the given dbroot to other dbroots</Arg4>
</Cmd4>
<Cmd5>
<Name>findObjectFile</Name>
<Desc1>Get the name of the directory containing the first file of the object</Desc1>
<Desc2>uses Object ID (OID) or Schema Table Column</Desc2>
<Arg1>Object ID (OID) of object</Arg1>
<Arg2>Schema</Arg2>
<Arg3>Table</Arg3>
<Arg4>Column</Arg4>
</Cmd5>
<Cmd6>
<Name>getModuleTypeConfig</Name>
<Desc1>Get Module Type Configuration Information</Desc1>
<Desc2>Can display all Module Type parameters, parameters for a single module type , or a single parameter for a specific module type</Desc2>
<Arg1>No Argument or 'all' will display all Module Type Configuration parameters</Arg1>
<Arg2>Optional: Module-type will display the Module Type Configuration parameters</Arg2>
<Arg3>Optional: Module-type and Parameter-name will display the Module Type Configuration parameter</Arg3>
</Cmd6>
<Cmd7>
<Name>setModuleTypeConfig</Name>
<Desc1>Set a Module Type Configuration parameter</Desc1>
<Arg1>Required: Module-type is the parameter to be updated</Arg1>
<Arg2>Required: Parameter-name is the parameter to be updated</Arg2>
<Arg3>Required: Parameter-value is the parameter value</Arg3>
</Cmd7>
<Cmd8>
<Name>getProcessConfig</Name>
<Desc1>Get Process Configuration Information</Desc1>
<Desc2>Can display all Process parameters, parameters for a single process, or a single parameter for a specific process</Desc2>
<Arg1>No Argument or 'all' enter will display all Process Configuration parameters</Arg1>
<Arg2>Optional: Process-name and Module-type will display the Process Configuration parameters</Arg2>
<Arg3>Optional: Process-name, Module-type, and Parameter-name will display the Process Configuration parameter</Arg3>
</Cmd8>
<Cmd9>
<Name>setProcessConfig</Name>
<Desc1>Set a Process Configuration parameter</Desc1>
<Arg1>Required: Process-name is the Process to be updated</Arg1>
<Arg2>Required: Module-type is the Module Type of the Process to be updated</Arg2>
<Arg3>Required: Parameter-name is the parameter to be updated</Arg3>
<Arg4>Required: Parameter-value is the parameter value</Arg4>
</Cmd9>
<Cmd10>
<Name>getAlarmConfig</Name>
<Desc1>Get Alarm Configuration Information</Desc1>
<Desc2>Can display all Alarms or a single Alarm</Desc2>
<Arg1>No Argument or 'all' enter will display all Alarms Configuration parameters</Arg1>
<Arg2>Optional: Alarm-ID will display the Alarm Configuration parameter </Arg2>
</Cmd10>
<Cmd11>
<Name>setAlarmConfig</Name>
<Desc1>Set an Alarm Configuration parameter</Desc1>
<Arg1>Required: Alarm-ID is the Alarm to be updated</Arg1>
<Arg2>Required: Parameter-name is the parameter to be updated</Arg2>
<Arg3>Required: Parameter-value is the parameter value</Arg3>
</Cmd11>
<Cmd12>
<Name>getActiveAlarms</Name>
<Desc1>Get Active Alarm list</Desc1>
<Desc2>Displays all the Alarms that are currently active</Desc2>
<Arg1>None</Arg1>
</Cmd12>
<Cmd13>
<Name>getStorageConfig</Name>
<Desc1>Get System Storage Configuration Information</Desc1>
<Desc2>Displays storage and dbroot assignment Information</Desc2>
<Arg1>None</Arg1>
</Cmd13>
<Cmd14>
<Name>addDbroot</Name>
<Desc1>Add DBRoot Disk storage to the MariaDB Columnstore System</Desc1>
<Arg1>Required: Number of DBRoots to be added</Arg1>
</Cmd14>
<Cmd15>
<Name>removeDbroot</Name>
<Desc1>Remove DBRoot Disk storage from the MariaDB Columnstore System</Desc1>
<Arg1>Required: List of Dbroot IDs to be removed</Arg1>
</Cmd15>
<Cmd16>
<Name>stopSystem</Name>
<Desc1>Stops the processing of the MariaDB Columnstore System</Desc1>
<Desc2>It will leave the Modules powered on and the Operating Systems enable </Desc2>
<Desc3>This command might be used for Software Maintenance reasons</Desc3>
<Arg1>Optional: GRACEFUL/FORCEFUL is the mode the process will be taken down. Default is FORCEFUL</Arg1>
<Arg2>Optional: ACK_YES/ACK_NO is Acknowledgment response or not. Default is ACK_YES</Arg2>
</Cmd16>
<Cmd17>
<Name>shutdownSystem</Name>
<Desc1>Shuts down the MariaDB Columnstore System</Desc1>
<Desc2>This command stops the processing of applications on all Modules within the MariaDB Columnstore System</Desc2>
<Desc3>It should be using when performing an upgrade</Desc3>
<Arg1>Optional: GRACEFUL/FORCEFUL is the mode the process will be taken down. Default is FORCEFUL</Arg1>
<Arg2>Optional: ACK_YES/ACK_NO is Acknowledgment response or not. Default is ACK_YES</Arg2>
</Cmd17>
<Cmd18>
<Name>startSystem</Name>
<Desc1>Starts a stopped or shutdown MariaDB Columnstore System</Desc1>
<Desc2>If system is shutdown, then a server root password should be entered if a ssh key is not defined</Desc2>
<Arg1>Optional: Server-root-password</Arg1>
</Cmd18>
<Cmd19>
<Name>restartSystem</Name>
<Desc1>Restarts a stopped or shutdown MariaDB Columnstore System</Desc1>
<Desc2>If system is shutdown, then a server root password should be entered if a ssh key is not defined</Desc2>
<Arg1>Optional: GRACEFUL/FORCEFUL is the mode the process will be taken down. Default is FORCEFUL</Arg1>
<Arg2>Optional: ACK_YES/ACK_NO is Acknowledgment response or not. Default is ACK_YES</Arg2>
<Arg3>Optional: Server-root-password</Arg3>
</Cmd19>
<Cmd20>
<Name>getSystemStatus</Name>
<Desc1>Get System and Modules Status</Desc1>
<Desc2>Get Status of the MariaDB Columnstore System and the modules within the MariaDB Columnstore System</Desc2>
<Arg1>None</Arg1>
</Cmd20>
<Cmd21>
<Name>getProcessStatus</Name>
<Desc1>Get MariaDB Columnstore Process Statuses</Desc1>
<Desc2>Get Status of the MariaDB Columnstore Processes witin the MariaDB Columnstore System</Desc2>
<Arg1>None</Arg1>
</Cmd21>
<Cmd22>
<Name>system</Name>
<Desc1>Execute a system shell command</Desc1>
<Arg1>Required: UNIX command</Arg1>
</Cmd22>
<Cmd23>
<Name>getAlarmHistory</Name>
<Desc1>Get system alarms</Desc1>
<Desc2>Get all set and clear alarms reported on the system on a daily basis</Desc2>
<Arg1>Required: Date to Display in format of MM/DD/YY</Arg1>
</Cmd23>
<Cmd24>
<Name>monitorAlarms</Name>
<Desc1>Monitor alarms in realtime mode</Desc1>
<Desc2>Enter "control-C" to exit monitorAlarms command</Desc2>
</Cmd24>
<Cmd25>
<Name>resetAlarm</Name>
<Desc1>Resets an Active Alarm</Desc1>
<Desc2>Resetting the Alarm will remove it from the Active Alarm Log file</Desc2>
<Arg1>Required: AlarmID or ALL to reset all active alarms</Arg1>
<Arg2>Required: Reporting Module or ALL to reset all active AlarmID alarms</Arg2>
<Arg3>Required: Reported Device or ALL to reset all active AlarmID/Reporting Module Alarms</Arg3>
</Cmd25>
<Cmd26>
<Name>enableLog</Name>
<Desc1>Enable the levels of process and debug logging</Desc1>
<Arg1>Required: 'system' or Module-name where logging is being enabled</Arg1>
<Arg2>Required: 'all' or the specific level to enable</Arg2>
<Arg3> Levels: critical, error, warning, info, and debug</Arg3>
</Cmd26>
<Cmd27>
<Name>disableLog</Name>
<Desc1>Disable the levels of process and debug logging</Desc1>
<Arg1>Required: 'system' or Module-name where logging is being disabled</Arg1>
<Arg2>Required: 'all' or the specific level to disable</Arg2>
<Arg3> Levels: critical, error, warning, info, and debug</Arg3>
</Cmd27>
<Cmd28>
<Name>switchParentOAMModule</Name>
<Desc1>Switches the Active Parent OAM Module to another Performance Module</Desc1>
<Desc2>A System stop and start is performed as part of the process</Desc2>
<Desc3>Command is recommended to be done while the system is idle</Desc3>
<Arg1>Optional: Performance-Module-name to switch to, default to Standby Parent OAM Module</Arg1>
</Cmd28>
<Cmd29>
<Name>getStorageStatus</Name>
<Desc1>Get System Storage Status</Desc1>
<Desc2>Get Status of the MariaDB Columnstore DBRoot Storages within the MariaDB Columnstore System</Desc2>
<Desc2>Only Valid for External Configured disk</Desc2>
<Arg1>None</Arg1>
</Cmd29>
<Cmd30>
<Name>getLogConfig</Name>
<Desc1>Get the System log file configuration</Desc1>
<Desc2>Get the process and debug log file configuration on each Module</Desc2>
</Cmd30>
<Cmd31>
<Name>movePmDbrootConfig</Name>
<Desc1>Move DBroots from one Performance Module to another</Desc1>
<Desc2>This command would be used before a Performance Module is removed or added</Desc2>
<Arg1>Required: Performance Module Name where the Dbroot are being moved from</Arg1>
<Arg2>Required: List of Dbroot IDs to be moved</Arg2>
<Arg3>Required: Performance Module Name where the Dbroot are being moved to</Arg3>
</Cmd31>
<Cmd32>
<Name>suspendDatabaseWrites</Name>
<Desc1>Suspend performing writes to the MariaDB Columnstore Database</Desc1>
<Arg1>None</Arg1>
</Cmd32>
<Cmd33>
<Name>resumeDatabaseWrites</Name>
<Desc1>Resume performing writes to the MariaDB Columnstore Database</Desc1>
<Arg1>None</Arg1>
</Cmd33>
<Cmd34>
<Name>unassignDbrootPmConfig</Name>
<Desc1>Unassign DBroots from a Performance Module</Desc1>
<Desc2>This command could be used before a DBRoot is removed</Desc2>
<Arg1>Required: List of Dbroot IDs to be unassigned</Arg1>
<Arg2>Required: Performance Module Name</Arg2>
</Cmd34>
<Cmd35>
<Name>assignDbrootPmConfig</Name>
<Desc1>Assign unassigned DBroots to Performance Module</Desc1>
<Desc2>This command could be used after a Performance Module and/or DBRoot is added</Desc2>
<Arg1>Required: List of Dbroot IDs to be assigned</Arg1>
<Arg2>Required: Performance Module Name</Arg2>
</Cmd35>
<Cmd36>
<Name>getAlarmSummary</Name>
<Desc1>Get Summary counts of Active Alarm</Desc1>
<Arg1>None</Arg1>
</Cmd36>
<Cmd37>
<Name>getSystemInfo</Name>
<Desc1>Get the Over-all System Statuses</Desc1>
<Desc2>Get the System, Module, Process, and Active Alarm Statuses</Desc2>
<Arg1>None</Arg1>
</Cmd37>
<Cmd38>
<Name>getModuleConfig</Name>
<Desc1>Get Module Name Configuration Information</Desc1>
<Desc2>Can display all Module Name parameters, parameters for a single module name, or a single parameter for a specific module name</Desc2>
<Arg1>No Argument or 'all' will display all Module Name Configuration parameters</Arg1>
<Arg2>Optional: Module-name will display the Module Name Configuration parameters</Arg2>
<Arg3>Optional: Module-name and Parameter-name will display the Module Name Configuration parameter</Arg3>
</Cmd38>
<Cmd39>
<Name>getSystemDirectories</Name>
<Desc1>Get System Installation and Temporary Logging Directories</Desc1>
</Cmd39>
<Cmd40>
<Name>AVAILABLE</Name>
</Cmd40>
<Cmd41>
<Name>AVAILABLE</Name>
</Cmd41>
<Cmd42>
<Name>AVAILABLE</Name>
</Cmd42>
<Cmd43>
<Name>assignElasticIPAddress</Name>
<Desc1>Assign Amazon Elastic IP Address to a module (deprecated)</Desc1>
<Arg1>Required: Amazon Elastic IP Address</Arg1>
<Arg2>Required: Module Name</Arg2>
</Cmd43>
<Cmd44>
<Name>unassignElasticIPAddress</Name>
<Desc1>Unassign Amazon Elastic IP Address (deprecated)</Desc1>
<Arg1>Required: Amazon Elastic IP Address</Arg1>
</Cmd44>
<Cmd45>
<Name>getSystemNetworkConfig</Name>
<Desc1>Get System Network Configuration Information</Desc1>
<Desc2>Displays the Network Host Names and IP Addresses for all Modules, Switches,</Desc2>
<Desc3>and Storage Units that make up the system</Desc3>
<Arg1>None</Arg1>
</Cmd45>
<Cmd46>
<Name>enableMySQLReplication</Name>
<Desc1>Enable MySQL Replication functionality on the system</Desc1>
<Arg1>Required: User Password, 'root' or 'non-root'. Or 'ssh' is ssh-keys are configured</Arg1>
<Arg2>Required: MySQL Password or 'none' if not configured</Arg2>
</Cmd46>
<Cmd47>
<Name>getSoftwareInfo</Name>
<Desc1>Get the MariaDB Columnstore Package information</Desc1>
<Arg1>None</Arg1>
</Cmd47>
<Cmd48>
<Name>addModule</Name>
<Desc1>Add a Module within the MariaDB Columnstore System</Desc1>
<Desc2>This command is used to configure a Module to the Configuration</Desc2>
<Desc3>Database within the MariaDB Columnstore System. It will also install the </Desc3>
<Desc4>MariaDB Columnstore Packages and setup the module to make it ready to be restored</Desc4>
<Arg1>Required: Module-type or Module-name being added</Arg1>
<Arg2>Required: Number-of-Modules being added when Module-type is specified</Arg2>
<Arg3>Required: Store hostnames in the configuration instead of IP addresses (y/n)</Arg3>
<Arg4>If not Amazon, then Required: hostnames separated by commas</Arg4>
<Arg5>If Amazon, then Optional: Amazon-Instance-Names separated by commas</Arg5>
<Arg6>Optional: Server-user-password</Arg6>
</Cmd48>
<Cmd49>
<Name>removeModule</Name>
<Desc1>Remove a Module within the MariaDB Columnstore System</Desc1>
<Desc2>This command is used to unconfigure a Module from the Configuration</Desc2>
<Desc3>Database within the MariaDB Columnstore System</Desc3>
<Arg1>Required: Module-type or Module-name being removed</Arg1>
<Arg2>Required: Number-of-Modules being remove when Module-type is specified</Arg2>
</Cmd49>
<Cmd50>
<Name>getModuleHostNames</Name>
<Desc1>Get a list of Module host names (NIC 1 only)</Desc1>
<Arg1>Optional: um or pm</Arg1>
</Cmd50>
<Cmd51>
<Name>disableMySQLReplication</Name>
<Desc1>Disable MySQL Replication functionality on the system</Desc1>
<Arg1>Required: MySQL Password or 'none' if not configured</Arg1>
</Cmd51>
<Cmd52>
<Name>getModuleCpuUsers</Name>
<Desc1>Get a Module Top Processes utilizing CPU</Desc1>
<Desc2>The top number of processes using more than 0% will be displayed</Desc2>
<Arg1>Required: Module-name being monitored</Arg1>
<Arg2>Optional: Top number of Process to Display (1-10, default is 5)</Arg2>
</Cmd52>
<Cmd53>
<Name>getSystemCpuUsers</Name>
<Desc1>Get System Top Processes utilizing CPU</Desc1>
<Desc2>The top number of processes using more than 0% will be displayed</Desc2>
<Arg1>Optional: Top number of Process to Display (1-10, default is 5)</Arg1>
</Cmd53>
<Cmd54>
<Name>getModuleCpu</Name>
<Desc1>Get a Module CPU usage</Desc1>
<Desc2>The Modules CPU Usage percentage will be displayed</Desc2>
<Arg1>Required: Module-name being monitored</Arg1>
</Cmd54>
<Cmd55>
<Name>getSystemCpu</Name>
<Desc1>Get System CPU usage on all modules</Desc1>
<Desc2>The System Modules CPU Usage percentage will be displayed</Desc2>
</Cmd55>
<Cmd56>
<Name>getModuleMemoryUsers</Name>
<Desc1>Get a Module Top Processes utilizing Memory</Desc1>
<Desc2>The top number of processes using more than 0% will be displayed</Desc2>
<Arg1>Required: Module-name being monitored</Arg1>
<Arg2>Optional: Top number of Process to Display (1-10, default is 5)</Arg2>
</Cmd56>
<Cmd57>
<Name>getSystemMemoryUsers</Name>
<Desc1>Get System Top Processes utilizing Memory</Desc1>
<Desc2>The top number of processes using more than 0% will be displayed</Desc2>
<Arg1>Optional: Top number of Process to Display (1-10, default is 5)</Arg1>
</Cmd57>
<Cmd58>
<Name>getModuleMemory</Name>
<Desc1>Get a Module Memory usage</Desc1>
<Desc2>The Modules Memory Usage percentage will be displayed</Desc2>
<Arg1>Required: Module-name being monitored</Arg1>
</Cmd58>
<Cmd59>
<Name>getSystemMemory</Name>
<Desc1>Get System Memory usage on all modules</Desc1>
<Desc2>The System Modules Memory Usage percentage will be displayed</Desc2>
</Cmd59>
<Cmd60>
<Name>getModuleDisk</Name>
<Desc1>Get a Module Disk usage</Desc1>
<Desc2>The Modules Disk Usage will be displayed</Desc2>
<Arg1>Required: Module-name being monitored</Arg1>
</Cmd60>
<Cmd61>
<Name>getSystemDisk</Name>
<Desc1>Get System Disk usage on all modules</Desc1>
<Desc2>The System Modules Disk Usage will be displayed</Desc2>
</Cmd61>
<Cmd62>
<Name>getModuleResourceUsage</Name>
<Desc1>Get a Module Resource usage</Desc1>
<Desc2>The Modules Resource Usage will be displayed</Desc2>
<Desc3>Resources consist of CPU, Memory, and Disk usage</Desc3>
<Arg1>Required: Module-name being monitored</Arg1>
</Cmd62>
<Cmd63>
<Name>getSystemResourceUsage</Name>
<Desc1>Get System Resource usage on all modules</Desc1>
<Desc2>The System Modules Resource Usage will be displayed</Desc2>
<Desc3>Resources consist of CPU, Memory, and Disk usage</Desc3>
</Cmd63>
<Cmd64>
<Name>getActiveSQLStatements</Name>
<Desc1>Get List Active SQL Statements within the System</Desc1>
</Cmd64>
<Cmd65>
<Name>alterSystem-disableModule</Name>
<Desc1>Disable a Module and Alter the MariaDB Columnstore System</Desc1>
<Desc2>This command is used to place a Module in an disable state</Desc2>
<Desc3>and restart the associated processes the MariaDB Columnstore System. </Desc3>
<Arg1>Required: Module-name(s) being placed disable</Arg1>
</Cmd65>
<Cmd66>
<Name>alterSystem-enableModule</Name>
<Desc1>Enable a Module and Alter the MariaDB Columnstore System</Desc1>
<Desc2>This command is used to place a Module in an enable state</Desc2>
<Desc3>and restart the associated processes the MariaDB Columnstore System. </Desc3>
<Arg1>Required: Module-name(s) being placed enable</Arg1>
</Cmd66>
<Cmd67>
<Name>stopModule</Name>
<Desc1>Stop a module</Desc1>
<Desc2>Used by columnstore stop script to stop individual modules.</Desc2>
<Arg1>Required: Module-name being stopped</Arg1>
</Cmd67>
</Columnstore>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: LocalServer-CEC1.xml 375 2007-02-09 20:26:01Z rdempsey $ -->
<Calpont Version="V1.0.0">
<LocalServerConfig>
<ServerName>ec1</ServerName>
<OAMMasterServer>1</OAMMasterServer>
<RTLinuxServer>1</RTLinuxServer>
</LocalServerConfig>
</Calpont>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: LocalServer-CFE1.xml 375 2007-02-09 20:26:01Z rdempsey $ -->
<Calpont Version="V1.0.0">
<LocalServerConfig>
<ServerName>fep1</ServerName>
<OAMMasterServer>0</OAMMasterServer>
<RTLinuxServer>0</RTLinuxServer>
</LocalServerConfig>
</Calpont>

View File

@ -1,142 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: ProcessConfig.xml 3651 2013-06-18 17:55:27Z dhill $ -->
<Columnstore Version="V1.0.0">
<PROCESSCONFIG1>
<ProcessName>ProcessMonitor</ProcessName>
<ModuleType>ChildExtOAMModule</ModuleType>
<ProcessLocation>@ENGINE_BINDIR@/ProcMon</ProcessLocation>
<BootLaunch>0</BootLaunch>
<LaunchID>1</LaunchID>
<DepProcessName/>
<RunType>LOADSHARE</RunType>
<LogFile>off</LogFile>
</PROCESSCONFIG1>
<PROCESSCONFIG2>
<ProcessName>ProcessManager</ProcessName>
<ModuleType>ParentOAMModule</ModuleType>
<ProcessLocation>@ENGINE_BINDIR@/ProcMgr</ProcessLocation>
<BootLaunch>1</BootLaunch>
<LaunchID>2</LaunchID>
<DepProcessName/>
<RunType>ACTIVE_STANDBY</RunType>
<LogFile>off</LogFile>
</PROCESSCONFIG2>
<PROCESSCONFIG3>
<ProcessName>StorageManager</ProcessName>
<ModuleType>ChildExtOAMModule</ModuleType>
<ProcessLocation>@ENGINE_BINDIR@/StorageManager</ProcessLocation>
<BootLaunch>2</BootLaunch>
<LaunchID>3</LaunchID>
<DepProcessName/>
<DepModuleName1>@</DepModuleName1>
<RunType>LOADSHARE</RunType>
<LogFile>off</LogFile>
</PROCESSCONFIG3>
<PROCESSCONFIG4>
<ProcessName>DBRMControllerNode</ProcessName>
<ModuleType>ParentOAMModule</ModuleType>
<ProcessLocation>@ENGINE_BINDIR@/controllernode</ProcessLocation>
<ProcessArg1>@ENGINE_BINDIR@/controllernode</ProcessArg1>
<ProcessArg2>fg</ProcessArg2>
<BootLaunch>2</BootLaunch>
<LaunchID>4</LaunchID>
<DepProcessName1>ProcessManager</DepProcessName1>
<DepModuleName1>@</DepModuleName1>
<RunType>SIMPLEX</RunType>
<LogFile>off</LogFile>
</PROCESSCONFIG4>
<PROCESSCONFIG5>
<ProcessName>ServerMonitor</ProcessName>
<ModuleType>ChildOAMModule</ModuleType>
<ProcessLocation>@ENGINE_BINDIR@/ServerMonitor</ProcessLocation>
<ProcessArg1>@ENGINE_BINDIR@/ServerMonitor</ProcessArg1>
<BootLaunch>2</BootLaunch>
<LaunchID>6</LaunchID>
<DepProcessName/>
<RunType>LOADSHARE</RunType>
<LogFile>off</LogFile>
</PROCESSCONFIG5>
<PROCESSCONFIG6>
<ProcessName>DBRMWorkerNode</ProcessName>
<ModuleType>ChildExtOAMModule</ModuleType>
<ProcessLocation>@ENGINE_BINDIR@/workernode</ProcessLocation>
<ProcessArg1>@ENGINE_BINDIR@/workernode</ProcessArg1>
<ProcessArg2>DBRM_Worker</ProcessArg2>
<ProcessArg3>fg</ProcessArg3>
<BootLaunch>2</BootLaunch>
<LaunchID>7</LaunchID>
<DepProcessName/>
<RunType>LOADSHARE</RunType>
<LogFile>off</LogFile>
</PROCESSCONFIG6>
<PROCESSCONFIG7>
<ProcessName>PrimProc</ProcessName>
<ModuleType>pm</ModuleType>
<ProcessLocation>@ENGINE_BINDIR@/PrimProc</ProcessLocation>
<BootLaunch>2</BootLaunch>
<LaunchID>20</LaunchID>
<DepProcessName/>
<RunType>LOADSHARE</RunType>
<LogFile>off</LogFile>
</PROCESSCONFIG7>
<PROCESSCONFIG8>
<ProcessName>ExeMgr</ProcessName>
<ModuleType>um</ModuleType>
<ProcessLocation>@ENGINE_BINDIR@/ExeMgr</ProcessLocation>
<BootLaunch>2</BootLaunch>
<LaunchID>30</LaunchID>
<DepProcessName1>PrimProc</DepProcessName1>
<DepModuleName1>pm*</DepModuleName1>
<RunType>LOADSHARE</RunType>
<LogFile>off</LogFile>
</PROCESSCONFIG8>
<PROCESSCONFIG9>
<ProcessName>WriteEngineServer</ProcessName>
<ModuleType>pm</ModuleType>
<ProcessLocation>@ENGINE_BINDIR@/WriteEngineServer</ProcessLocation>
<BootLaunch>2</BootLaunch>
<LaunchID>40</LaunchID>
<RunType>LOADSHARE</RunType>
<LogFile>off</LogFile>
</PROCESSCONFIG9>
<PROCESSCONFIG10>
<ProcessName>DDLProc</ProcessName>
<ModuleType>um</ModuleType>
<ProcessLocation>@ENGINE_BINDIR@/DDLProc</ProcessLocation>
<BootLaunch>2</BootLaunch>
<LaunchID>50</LaunchID>
<DepProcessName1>WriteEngineServer</DepProcessName1>
<DepModuleName1>pm*</DepModuleName1>
<DepProcessName2>DBRMWorkerNode</DepProcessName2>
<DepModuleName2>@</DepModuleName2>
<DepProcessName3>ExeMgr</DepProcessName3>
<DepModuleName3>*</DepModuleName3>
<RunType>SIMPLEX</RunType>
<LogFile>off</LogFile>
</PROCESSCONFIG10>
<PROCESSCONFIG11>
<ProcessName>DMLProc</ProcessName>
<ModuleType>um</ModuleType>
<ProcessLocation>@ENGINE_BINDIR@/DMLProc</ProcessLocation>
<BootLaunch>2</BootLaunch>
<LaunchID>51</LaunchID>
<DepProcessName1>WriteEngineServer</DepProcessName1>
<DepModuleName1>pm*</DepModuleName1>
<DepProcessName2>DBRMWorkerNode</DepProcessName2>
<DepModuleName2>@</DepModuleName2>
<DepProcessName3>DDLProc</DepProcessName3>
<DepModuleName3>@</DepModuleName3>
<RunType>SIMPLEX</RunType>
<LogFile>off</LogFile>
</PROCESSCONFIG11>
<PROCESSCONFIG12>
<ProcessName>mysqld</ProcessName>
<ModuleType>um</ModuleType>
<ProcessLocation>/usr/bin/mysqld</ProcessLocation>
<BootLaunch>0</BootLaunch>
<LaunchID>100</LaunchID>
<DepProcessName/>
<RunType>LOADSHARE</RunType>
<LogFile>off</LogFile>
</PROCESSCONFIG12>
</Columnstore>

View File

@ -6,16 +6,8 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/columnstore-post-install.in" "${CMAK
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/columnstore.in" "${CMAKE_CURRENT_SOURCE_DIR}/columnstore" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/columnstore-pre-uninstall.in" "${CMAKE_CURRENT_SOURCE_DIR}/columnstore-pre-uninstall" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/columnstoreLogRotate.in" "${CMAKE_CURRENT_SOURCE_DIR}/columnstoreLogRotate" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/postInstall.sh.in" "${CMAKE_CURRENT_SOURCE_DIR}/postInstall.sh" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/startupTests.sh.in" "${CMAKE_CURRENT_SOURCE_DIR}/startupTests.sh" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mariadb-columnstore.service.in" "${CMAKE_CURRENT_SOURCE_DIR}/mariadb-columnstore.service" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mariadb-columnstore-start.sh.in" "${CMAKE_CURRENT_SOURCE_DIR}/mariadb-columnstore-start.sh" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/columnstore_module_installer.sh.in" "${CMAKE_CURRENT_SOURCE_DIR}/columnstore_module_installer.sh" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/master-rep-columnstore.sh.in" "${CMAKE_CURRENT_SOURCE_DIR}/master-rep-columnstore.sh" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/disable-rep-columnstore.sh.in" "${CMAKE_CURRENT_SOURCE_DIR}/disable-rep-columnstore.sh" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mariadb-command-line.sh.in" "${CMAKE_CURRENT_SOURCE_DIR}/mariadb-command-line.sh" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/slave-rep-columnstore.sh.in" "${CMAKE_CURRENT_SOURCE_DIR}/slave-rep-columnstore.sh" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mcs_module_installer.sh.in" "${CMAKE_CURRENT_SOURCE_DIR}/mcs_module_installer.sh" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mcs-workernode.service.in" "${CMAKE_CURRENT_SOURCE_DIR}/mcs-workernode.service" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mcs-controllernode.service.in" "${CMAKE_CURRENT_SOURCE_DIR}/mcs-controllernode.service" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mcs-primproc.service.in" "${CMAKE_CURRENT_SOURCE_DIR}/mcs-primproc.service" @ONLY)
@ -32,25 +24,11 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/columnstoreSyslog.in" "${CMAKE_CURRE
install(PROGRAMS columnstore-post-install
columnstore-pre-uninstall
remote_command.sh
columnstore_module_installer.sh
startupTests.sh
remote_scp_get.sh
columnstore_run.sh
post-mysql-install
post-mysqld-install
columnstore_os_check.sh
columnstore
columnstoreSyslogSetup.sh
remote_scp_put.sh
remotessh.exp
rsync.sh
remote_command_verify.sh
master-rep-columnstore.sh
slave-rep-columnstore.sh
disable-rep-columnstore.sh
mariadb-command-line.sh
mcs_module_installer.sh
mcs-stop-controllernode.sh
mcs-loadbrm.py
mcs-savebrm.py

View File

@ -1,153 +0,0 @@
#!/bin/bash
#
# $Id: module_installer.sh 421 2007-04-05 15:46:55Z dhill $
#
# Setup the Custom OS files during a System install on a module
#
#
# append columnstore OS files to Linux OS file
#
#
rpmmode=install
user=`whoami 2>/dev/null`
quiet=0
shiftcnt=0
password=" "
for arg in "$@"; do
if [ $(expr -- "$arg" : '--rpmmode=') -eq 10 ]; then
rpmmode="$(echo $arg | awk -F= '{print $2}')"
((shiftcnt++))
elif [ $(expr -- "$arg" : '--user=') -eq 7 ]; then
user="$(echo $arg | awk -F= '{print $2}')"
((shiftcnt++))
elif [ $(expr -- "$arg" : '--quiet') -eq 7 ]; then
quiet=1
((shiftcnt++))
elif [ $(expr -- "$arg" : '--port') -eq 6 ]; then
mysqlPort="$(echo $arg | awk -F= '{print $2}')"
((shiftcnt++))
elif [ $(expr -- "$arg" : '--module') -eq 8 ]; then
module="$(echo $arg | awk -F= '{print $2}')"
((shiftcnt++))
elif [ $(expr -- "$arg" : '--password') -eq 10 ]; then
password="$(echo $arg | awk -F= '{print $2}')"
((shiftcnt++))
fi
done
shift $shiftcnt
PMwithUM=`mcsGetConfig Installation PMwithUM`
ServerTypeInstall=`mcsGetConfig Installation ServerTypeInstall`
#get temp directory
tmpDir=`mcsGetConfig SystemConfig SystemTempFileDir`
cloud=`mcsGetConfig Installation Cloud`
if [ $cloud = "amazon-ec2" ] || [ $cloud = "amazon-vpc" ]; then
echo "Amazon setup on Module"
cp /var/lib/columnstore/local/etc/credentials $HOME/.aws/. > /dev/null 2>&1
if [ $module = "pm" ]; then
if test -f /var/lib/columnstore/local/etc/pm1/fstab ; then
echo "Setup fstab on Module"
SUDO=""
if [ $user != "root" ]; then
SUDO="sudo "
fi
touch /etc/fstab
$SUDO chmod 666 /etc/fstab
rm -f /etc/fstab.columnstoreSave
cp /etc/fstab /etc/fstab.columnstoreSave
cat /var/lib/columnstore/local/etc/pm1/fstab >> /etc/fstab
fi
fi
fi
. @ENGINE_SUPPORTDIR@/columnstore_functions
mid=`module_id`
#if um, cloud, separate system type, external um storage, then setup mount
if [ $cloud = "amazon-ec2" ] || [ $cloud = "amazon-vpc" ]; then
if [ $module = "um" ]; then
systemtype=`mcsGetConfig Installation ServerTypeInstall`
if [ $systemtype = "1" ]; then
umstoragetype=`mcsGetConfig Installation UMStorageType`
fi
fi
#setup rc.local for amazon
RCFILE=/etc/rc.d/rc.local
if [ $user != "root" ]; then
echo "uncomment runuser in rc.local, amazon AMI"
sudo sed -i -e 's/#runuser/runuser/g' /etc/rc.d/rc.local >/dev/null 2>&1
fi
fi
#if pm, create dbroot directories
if [ $module = "pm" ]; then
numdbroots=`mcsGetConfig SystemConfig DBRootCount`
for (( id=1; id<$numdbroots+1; id++ )); do
mkdir -p /var/lib/columnstore/data$id > /dev/null 2>&1
chmod 755 /var/lib/columnstore/data$id
done
fi
# if mysqlrep is on and module has a my.cnf file, upgrade it
MySQLRep=`mcsGetConfig Installation MySQLRep`
if [ $MySQLRep = "y" ]; then
if test -f @MARIADB_MYCNFDIR@/columnstore.cnf ; then
echo "Run Upgrade on my.cnf on Module"
mycnfUpgrade > ${tmpDir}/mycnfUpgrade.log 2>&1
fi
fi
if test -f @MARIADB_MYCNFDIR@/columnstore.cnf ; then
mysqlPort=`mcsGetConfig Installation MySQLPort`
echo "Run Mysql Port update on my.cnf on Module"
mycnfUpgrade $mysqlPort > ${tmpDir}/mycnfUpgrade_port.log 2>&1
fi
# if um, run mysql install scripts
if [ $module = "um" ] || ( [ $module = "pm" ] && [ $PMwithUM = "y" ] ) || [ $ServerTypeInstall = "2" ]; then
mysqlPassword=" "
if [[ $password != " " ]]; then
mysqlPassword="--password="$password
fi
echo "Run post-mysqld-install"
post-mysqld-install $mysqlPassword --tmpdir=${tmpDir} > ${tmpDir}/post-mysqld-install.log 2>&1
if [ $? -ne 0 ]; then
echo "ERROR: post-mysqld-install failed: check ${tmpDir}/post-mysqld-install.log"
exit 1
fi
echo "Run post-mysql-install"
post-mysql-install --tmpdir=${tmpDir} > ${tmpDir}/post-mysql-install.log 2>&1
if [ $? -ne 0 ]; then
echo "ERROR: post-mysql-install failed: check ${tmpDir}/post-mysql-install.log"
exit 1
fi
fi
if [ $user == "root" ]; then
columnstoreSyslogSetup.sh check > ${tmpDir}/syslogSetup-check.log 2>&1
if [ $? -ne 0 ]; then
# try setup again
columnstoreSyslogSetup.sh install > ${tmpDir}/syslogSetup-install.log 2>&1
if [ $? -ne 0 ]; then
echo "WARNING: columnstoreSyslogSetup.sh check failed: check ${tmpDir}/syslogSetup-check.log"
exit 2
fi
fi
fi
echo "!!!Module Installation Successfully Completed!!!"
exit 0

View File

@ -1,44 +0,0 @@
#!/bin/bash
#
# Determine the Linux distribution and version that is being run.
#
# Check for GNU/Linux distributions
if [ -f /etc/SuSE-release ]; then
DISTRIBUTION="suse"
elif [ -f /etc/UnitedLinux-release ]; then
DISTRIBUTION="united"
elif [ -f /etc/debian_version ]; then
DISTRIBUTION="debian"
elif [ -f /etc/lsb_version ]; then
DISTRIBUTION="ubuntu"
elif [ -f /etc/redhat-release ]; then
a=`grep -i 'red.*hat.*enterprise.*linux' /etc/redhat-release`
if test $? = 0; then
DISTRIBUTION=rhel
else
a=`grep -i 'red.*hat.*linux' /etc/redhat-release`
if test $? = 0; then
DISTRIBUTION=rh
else
a=`grep -i 'Fedora' /etc/redhat-release`
if test $? = 0; then
DISTRIBUTION=fedora
else
a=`grep -i 'cern.*e.*linux' /etc/redhat-release`
if test $? = 0; then
DISTRIBUTION=cel
else
a=`grep -i 'scientific linux cern' /etc/redhat-release`
if test $? = 0; then
DISTRIBUTION=slc
else
DISTRIBUTION="unknown"
fi
fi
fi
fi
fi
else
DISTRIBUTION="unknown"
fi
echo ${DISTRIBUTION}

View File

@ -1,66 +0,0 @@
#!/bin/bash
#
# $Id$
#
# generic MariaDB Columnstore Disable Replication script.
#
# Notes: This script gets run by ProcMon:
# check log for error
checkForError() {
grep ERROR ${tmpdir}/disable-rep-status.log > ${tmpdir}/error.check
if [ `cat ${tmpdir}/error.check | wc -c` -ne 0 ]; then
echo "ERROR: check log file:${tmpdir}/disable-rep-status.log"
rm -f ${tmpdir}/error.check
exit 1
fi
rm -f ${tmpdir}/error.check
}
pwprompt=
for arg in "$@"; do
if [ `expr -- "$arg" : '--password='` -eq 11 ]; then
password="`echo $arg | awk -F= '{print $2}'`"
pwprompt="--password=$password"
elif [ $(expr -- "$arg" : '--tmpdir=') -eq 9 ]; then
tmpdir="$(echo $arg | awk -F= '{print $2}')"
fi
done
. @ENGINE_SUPPORTDIR@/columnstore_functions
>${tmpdir}/disable-rep-status.log
#
# Run stop slave command
#
echo "Run stop slave command" >>${tmpdir}/disable-rep-status.log
cat >${tmpdir}/idb_disable-rep.sql <<EOD
stop slave;
EOD
cat ${tmpdir}/idb_disable-rep.sql >>${tmpdir}/disable-rep-status.log
mysql \
--user=root $pwprompt \
calpontsys <${tmpdir}/idb_disable-rep.sql >>${tmpdir}/disable-rep-status.log 2>&1
checkForError
#
# Run reset slave command
#
echo "Run reset slave command" >>${tmpdir}/disable-rep-status.log
cat >${tmpdir}/idb_disable-rep.sql <<EOD
reset slave;
EOD
cat ${tmpdir}/idb_disable-rep.sql >>${tmpdir}/disable-rep-status.log
mysql \
--user=root $pwprompt \
calpontsys <${tmpdir}/idb_disable-rep.sql >>${tmpdir}/disable-rep-status.log 2>&1
checkForError
#alls good, 'OK' for success
echo "OK"
exit 0

View File

@ -1,13 +0,0 @@
#!/bin/bash
#
# $Id: install-infinidb.sh 421 2007-04-05 15:46:55Z dhill $
#
# install-infinidb.sh dummy EE version
echo " " 1>&2
echo " This install-infinidb.sh script is only used to install the Community Edition." 1>&2
echo " Please use the 'postConfigure' for installing the Enterprise Edition." 1>&2
echo " Check the Calpont InfiniDB Installation Document for further details." 1>&2
exit 1

View File

@ -1,62 +0,0 @@
#!/bin/bash
#
# $Id$
#
# generic MariaDB Columnstore Command Line script.
#
# Notes: This script gets run by ProcMon during installs and upgrades:
# check log for error
checkForError() {
grep "ERROR 1045" ${tmpdir}/mariadb-command-line.log > ${tmpdir}/error.check
if [ `cat ${tmpdir}/error.check | wc -c` -ne 0 ]; then
echo "ERROR - PASSWORD: check log file: ${tmpdir}/mariadb-command-line.log"
rm -f ${tmpdir}/error.check
exit 2
fi
grep ERROR ${tmpdir}/mariadb-command-line.log > ${tmpdir}/error.check
if [ `cat ${tmpdir}/error.check | wc -c` -ne 0 ]; then
echo "ERROR: check log file: ${tmpdir}/mariadb-command-line.log"
rm -f ${tmpdir}/error.check
exit 1
fi
rm -f ${tmpdir}/error.check
}
pwprompt=
for arg in "$@"; do
if [ `expr -- "$arg" : '--command='` -eq 10 ]; then
command1="`echo $arg | awk -F= '{print $2}'`"
command2="`echo $arg | awk -F= '{print $3}'`"
command=$command1"="$command2
elif [ `expr -- "$arg" : '--port='` -eq 7 ]; then
port="`echo $arg | awk -F= '{print $2}'`"
elif [ $(expr -- "$arg" : '--tmpdir=') -eq 9 ]; then
tmpdir="$(echo $arg | awk -F= '{print $2}')"
fi
done
. @ENGINE_SUPPORTDIR@/columnstore_functions
>${tmpdir}/mariadb-command-line.log
#
# Run command
#
echo "Run command" >>${tmpdir}/mariadb-command-line.log
cat >${tmpdir}/mariadb-command-line.sql <<EOD
$command;
EOD
cat ${tmpdir}/mariadb-command-line.sql >> ${tmpdir}/mariadb-command-line.log
mysql \
--user=root \
calpontsys < ${tmpdir}/mariadb-command-line.sql >> ${tmpdir}/mariadb-command-line.log 2>&1
checkForError
#alls good, 'OK' for success
echo "OK"
exit 0

View File

@ -1,99 +0,0 @@
#!/bin/bash
#
# $Id$
#
# generic MariaDB Columnstore Master Replication script.
#
# Notes: This script gets run by ProcMon during installs and upgrades:
# check log for error
checkForError() {
grep ERROR ${tmpdir}/master-rep-status-$hostipaddr.log > ${tmpdir}/error.check
if [ `cat ${tmpdir}/error.check | wc -c` -ne 0 ]; then
echo "ERROR: check log file: ${tmpdir}/master-rep-status-$hostipaddr.log"
rm -f ${tmpdir}/error.check
exit 1
fi
rm -f ${tmpdir}/error.check
}
pwprompt=
for arg in "$@"; do
if [ `expr -- "$arg" : '--hostIP='` -eq 9 ]; then
hostipaddr="`echo $arg | awk -F= '{print $2}'`"
elif [ $(expr -- "$arg" : '--tmpdir=') -eq 9 ]; then
tmpdir="$(echo $arg | awk -F= '{print $2}')"
fi
done
. @ENGINE_SUPPORTDIR@/columnstore_functions
repUser="idbrep"
password="C0lumnStore!"
>${tmpdir}/master-rep-status-$hostipaddr.log
#
# Create Replication User
#
echo "Create Replication User $repUser for node $hostipaddr" >>${tmpdir}/master-rep-status-$hostipaddr.log
cat >${tmpdir}/idb_master-rep.sql <<EOD
CREATE USER IF NOT EXISTS '$repUser'@'$hostipaddr' IDENTIFIED BY '$password';
GRANT REPLICATION SLAVE ON *.* TO '$repUser'@'$hostipaddr';
EOD
cat ${tmpdir}/idb_master-rep.sql >>${tmpdir}/master-rep-status-$hostipaddr.log
mysql \
--user=root \
calpontsys <${tmpdir}/idb_master-rep.sql >>${tmpdir}/master-rep-status-$hostipaddr.log 2>&1
checkForError
#
# Grant table access for created user
#
echo "Grant table access for $repUser for node $hostipaddr" >>${tmpdir}/master-rep-status-$hostipaddr.log
cat >${tmpdir}/idb_master-rep.sql <<EOD
use mysql
grant all on *.* to '$repUser'@'$hostipaddr' identified by 'C0lumnStore!';
grant REPLICATION SLAVE on *.* to '$repUser'@'$hostipaddr' identified by 'C0lumnStore!';
EOD
cat ${tmpdir}/idb_master-rep.sql >>${tmpdir}/master-rep-status-$hostipaddr.log
mysql \
--user=root \
calpontsys <${tmpdir}/idb_master-rep.sql >>${tmpdir}/master-rep-status-$hostipaddr.log 2>&1
checkForError
#
# Run SHOW MASTER STATUS
#
echo "Run SHOW MASTER STATUS to node log" >>${tmpdir}/master-rep-status-$hostipaddr.log
cat >${tmpdir}/idb_master-rep.sql <<EOD
SHOW MASTER STATUS
EOD
cat ${tmpdir}/idb_master-rep.sql >>${tmpdir}/master-rep-status-$hostipaddr.log
mysql \
--user=root \
calpontsys <${tmpdir}/idb_master-rep.sql >>${tmpdir}/master-rep-status-$hostipaddr.log 2>&1
checkForError
echo "Run SHOW MASTER STATUS to master status log ${tmpdir}/show-master-status.log" >>${tmpdir}/master-rep-status-$hostipaddr.log
cat >${tmpdir}/idb_master-rep.sql <<EOD
SHOW MASTER STATUS
EOD
cat ${tmpdir}/idb_master-rep.sql >${tmpdir}/show-master-status.log
mysql \
--user=root \
calpontsys <${tmpdir}/idb_master-rep.sql >>${tmpdir}/show-master-status.log
#alls good, 'OK' for success
echo "OK"
exit 0

View File

@ -1,138 +0,0 @@
#!/usr/bin/expect
#
# Install custom OS files on system
# Argument 0 - Remote Module Name
# Argument 1 - Remote Server Host Name or IP address
# Argument 2 - Root Password of remote server
# Argument 3 - Debug flag 1 for on, 0 for off
# Argument 4 - Username on remote server (root default)
set timeout 30
set USERNAME root
set MODULE [lindex $argv 0]
set SERVER [lindex $argv 1]
set PASSWORD [lindex $argv 2]
set DEBUG [lindex $argv 3]
set USERNAME "root"
set UNM [lindex $argv 4]
if { $UNM != "" } {
set USERNAME $UNM
}
set HOME "$env(HOME)"
log_user $DEBUG
spawn -noecho /bin/bash
#
#check and see if remote server has ssh keys setup, set PASSWORD if so
send_user " "
send "ssh -v $USERNAME@$SERVER 'time'\n"
set timeout 60
expect {
"authenticity" { send "yes\n"
exp_continue
}
"word: " { send "$PASSWORD\n"
exp_continue
}
"passphrase" { send "$PASSWORD\n"
exp_continue
}
"Exit status 0" { send_user "DONE"}
"Exit status 1" { send_user "FAILED: Login Failure\n" ; exit 1 }
"Host key verification failed" { send_user "FAILED: Host key verification failed\n" ; exit 1 }
"service not known" { send_user "FAILED: Invalid Host\n" ; exit 1 }
"Permission denied, please try again" { send_user "ERROR: Invalid password\n" ; exit 1 }
"Connection refused" { send_user "ERROR: Connection refused\n" ; exit 1 }
"Connection closed" { send_user "ERROR: Connection closed\n" ; exit 1 }
"No route to host" { send_user "ERROR: No route to host\n" ; exit 1 }
timeout { send_user "ERROR: Timeout to host\n" ; exit 2 }
}
send_user "\n"
send_user "Stop ColumnStore service "
send "ssh -v $USERNAME@$SERVER 'pkill ProcMon; pkill ProcMgr'\n"
set timeout 60
# check return
expect {
"word: " { send "$PASSWORD\n"
exp_continue
}
"passphrase" { send "$PASSWORD\n"
exp_continue
}
# "No such file or directory" { send_user "DONE" }
"Exit status 127" { send_user "DONE" }
"Exit status 0" { send_user "DONE" }
"Read-only file system" { send_user "ERROR: local disk - Read-only file system\n" ; exit 1}
timeout { send_user "DONE" }
}
send_user "\n"
#
# copy over custom OS tmp files
#
send_user "Copy Custom OS files to Module "
send_user " \n"
send "scp -rv @ENGINE_DATADIR@/local/etc $USERNAME@$SERVER:@ENGINE_DATADIR@/local\n"
set timeout 120
expect {
"word: " { send "$PASSWORD\n"
exp_continue
}
"passphrase" { send "$PASSWORD\n"
exp_continue
}
"Exit status 0" { send_user "DONE" }
"scp :" { send_user "ERROR\n" ;
send_user "\n*** Installation ERROR\n" ;
exit 1 }
"Read-only file system" { send_user "ERROR: local disk - Read-only file system\n" ; exit 1}
timeout { send_user "ERROR: Timeout\n" ; exit 2 }
}
send_user "\n"
#
# copy over MariaDB Columnstore Module file
#
send_user "Copy MariaDB Columnstore Module file to Module "
send "scp -v @ENGINE_DATADIR@/local/etc/$MODULE/* $USERNAME@$SERVER:@ENGINE_DATADIR@/local/.\n"
set timeout 120
expect {
"word: " { send "$PASSWORD\n"
exp_continue
}
"passphrase" { send "$PASSWORD\n"
exp_continue
}
"scp :" { send_user "ERROR\n" ;
send_user "\n*** Installation ERROR\n" ;
exit 1 }
"Exit status 0" { send_user "DONE" }
"Exit status 1" { send_user "ERROR: scp failed" ; exit 1 }
timeout { send_user "ERROR: Timeout to host\n" ; exit 2 }
}
send_user "\n"
send_user "Start ColumnStore service "
send_user " \n"
send "ssh -v $USERNAME@$SERVER 'columnstore start'\n"
set timeout 60
# check return
expect {
"word: " { send "$PASSWORD\n"
exp_continue
}
"passphrase" { send "$PASSWORD\n"
exp_continue
}
"Exit status 0" { send_user "DONE" }
"Exit status 127" { send_user "ERROR: columnstore Not Found\n" ; exit 1 }
timeout { send_user "ERROR: Timeout to host\n" ; exit 2 }
}
send_user "\n"
send_user "\nInstallation Successfully Completed on '$MODULE'\n"
exit 0

View File

@ -1,69 +0,0 @@
#!/usr/bin/expect
#
# $Id: patch_installer.sh 421 2007-04-05 15:46:55Z dhill $
#
# Install Software Patch on Module
# Argument 1 - Remote Module Name
# Argument 2 - Remote Server Host Name or IP address
# Argument 3 - Root Password of remote server
# Argument 4 - Patch Directory Location
# Argument 5 - Install Directory Location
# Argument 6 - Software File being installed
# Argument 7 - Debug flag 1 for on, 0 for off
set timeout 20
set MODULE [lindex $argv 0]
set SERVER [lindex $argv 1]
set PASSWORD [lindex $argv 2]
set PATCHLOCATION [lindex $argv 3]
set INSTALLLOCATION [lindex $argv 4]
set FILE [lindex $argv 5]
set DEBUG [lindex $argv 6]
set USERNAME "root"
set UNM [lindex $argv 7]
if { $UNM != "" } {
set USERNAME $UNM
}
log_user $DEBUG
spawn -noecho /bin/bash
#
# mv file being install
#
send_user "Backup Current File on Module"
expect -re "# "
send "ssh $USERNAME@$SERVER 'mv $INSTALLLOCATION$FILE $INSTALLLOCATION$FILE'.patchSave''\n"
# accept the remote host fingerprint (assuming never logged in before)
expect -re "service not known" { send_user " FAILED: Invalid Host\n" ; exit }
expect -re "authenticity" { send "yes\n" }
expect -re "word: "
# password for ssh
send "$PASSWORD\n"
# check return
expect {
-re "# " { send_user " DONE" }
-re "Permission denied" { send_user " FAILED: Invalid password\n" } exit;
-re "mv" { send_user " FAILED: copy filed\n" ; exit}
}
send_user "\n"
#
# send Patch File
#
send_user "Copy New Calpont Software File to Module"
expect -re "# "
send "scp $PATCHLOCATION$FILE $USERNAME@$SERVER:$INSTALLLOCATION$FILE\n"
expect -re "word: "
# send the password
send "$PASSWORD\n"
# check return
expect {
-re "100%" { send_user " DONE" }
-re "scp" { send_user " FAILED\n" ;
send_user "\n*** Installation Failed\n" ;
exit }
-re "Permission denied" { send_user " FAILED: Invalid password\n" ; exit }
-re "No such file or directory" { send_user " FAILED: Invalid package\n" ; exit }
}
send_user "\n"
send_user "\n!!!Patch Installation Successfully Completed!!!\n"
exit

View File

@ -1,129 +0,0 @@
#!/usr/bin/expect
#
# $Id$
#
# Install RPM on system
# Argument 1 - Package name being installed
# Argument 2 - Root Password of remote server
# Argument 3 - Root Password of External Mode
set timeout 10
set RPMPACKAGE " "
set PASSWORD " "
set CONFIGFILE " "
set DEBUG 0
set USERNAME "root"
spawn -noecho /bin/bash
for {set i 0} {$i<[llength $argv]} {incr i} {
set arg($i) [lindex $argv $i]
}
set i 0
while true {
if { $i == [llength $argv] } { break }
if { $arg($i) == "-h" } {
send_user "\n"
send_user "'postInstaller.sh' performs a system install of a Calpont RPM\n"
send_user "on a system with Calpont already installed or on a new system\n"
send_user "when the -c option is used.\n"
send_user "\n"
send_user "Usage: postInstaller.sh -r 'calpont-rpm' -p 'password' -c 'config-file' -d\n"
send_user " calpont-rpm - Calpont RPM with directory locatation, i.e. /root/calpont.x.x.x.x\n"
send_user " password - root password on the servers being installed'\n"
send_user " config-file - Optional: Columnstore.xml config file with directory location, i.e. /root/Columnstore.xml\n"
send_user " -d - Debug flag\n"
exit
} elseif { $arg($i) == "-r" } {
incr i
set RPMPACKAGE $arg($i)
} elseif { $arg($i) == "-p" } {
incr i
set PASSWORD $arg($i)
} elseif { $arg($i) == "-c" } {
incr i
set CONFIGFILE $arg($i)
} elseif { $arg($i) == "-d" } {
set DEBUG 1
} elseif { $arg($i) == "-u" } {
incr i
set USERNAME $arg($i)
}
incr i
}
log_user $DEBUG
if { $RPMPACKAGE == " " || $PASSWORD == " "} {puts "please enter both RPM and password, enter ./postInstaller.sh -h for additional info"; exit -1}
if { $CONFIGFILE == " " } {
set CONFIGFILE @ENGINE_SYSCONFDIR@/columnstore/Columnstore.xml.rpmsave
}
if { [catch { open $CONFIGFILE "r"} handle ] } {
puts "Calpont Config file not found: $CONFIGFILE"; exit -1
}
send_user "\nPerforming Calpont RPM System Install\n\n"
#
# stopSystem
#
send_user "Stop Calpont System "
expect -re "# "
send "mcsadmin stopSystem INSTALL y\n"
expect {
-re "# " { send_user "DONE" }
-re "**** stopSystem Failed" { send_user "INFO: System not running" }
}
send_user "\n"
#
# erase package
#
send_user "Erase Calpont Package on Module "
expect -re "# "
send "rpm -e --nodeps calpont\n"
expect {
-re "# " { send_user "DONE" }
-re "uninstall completed" { send_user "DONE" }
-re "ERROR dependencies" { send_user "ERROR: ERROR dependencies\n" ; exit -1 }
-re "not installed" { send_user "INFO: Package not installed" }
}
send_user "\n"
set timeout 60
#
# install package
#
send_user "Install Calpont Package on Module "
send "rpm -ivh $RPMPACKAGE\n"
expect {
-re "completed" { send_user "DONE" }
-re "ERROR dependencies" { send_user "ERROR: ERROR dependencies\n" ;
send_user "\n*** Installation ERROR\n" ;
exit -1 }
-re "error" { send_user "ERROR\n" ;
send_user "\n*** Installation ERROR\n" ;
exit -1 }
}
expect -re "# "
log_user 0
exec mv -f @ENGINE_SYSCONFDIR@/columnstore/Columnstore.xml @ENGINE_SYSCONFDIR@/columnstore/Columnstore.xml.new > /dev/null 2>&1
exec mv -f $CONFIGFILE @ENGINE_SYSCONFDIR@/columnstore/Columnstore.xml > /dev/null 2>&1
send_user "\n"
set timeout 380
#
# Run installer
#
send_user "Run System Installer "
send "columnstore_installer $RPMPACKAGE initial $PASSWORD n 0\n"
expect {
-re "reboot request successful" { }
-re "error" { send_user "FAILED" ; exit -1 }
}
send_user "\nCalpont RPM System Install Completed, System now rebooting\n\n"
exit 0

View File

@ -1,90 +0,0 @@
#!/usr/bin/expect
#
# $Id: remote_command.sh 3495 2012-12-17 22:51:40Z dhill $
#
# Remote command execution script to another server
# Argument 1 - Remote Server Host Name or IP address
# Argument 2 - Remote Server password
# Argument 3 - Command
# Argument 4 - debug flag
# Argument 5 - Remote user name (optional)
# Argument 6 - Force a tty to be allocated (optional)
set stty_init {cols 512 -opost};
set timeout 30
set SERVER [lindex $argv 0]
set PASSWORD [lindex $argv 1]
set COMMAND [lindex $argv 2]
set DEBUG [lindex $argv 3]
exec whoami >whoami.tmp
set USERNAME [exec cat whoami.tmp]
exec rm -f whoami.tmp
set UNM [lindex $argv 4]
if { $UNM != "" && $UNM != "-" } {
set USERNAME "$UNM"
}
set TTY ""
set TTYOPT [lindex $argv 5]
if { $TTYOPT != "" } {
set TTY "-t"
}
log_user $DEBUG
spawn -noecho /bin/bash
#expect -re {[$#] }
if { $PASSWORD == "ssh" } {
set PASSWORD ""
}
#
# send command
#
send "ssh -v $TTY $USERNAME@$SERVER '$COMMAND'\n"
expect {
"cannot access" { exit 1}
"Host key verification failed" { send_user "FAILED: Host key verification failed\n" ; exit 1}
"service not known" { send_user " FAILED: Invalid Host\n" ; exit 1}
"ssh: connect to host" { send_user " FAILED: Invalid Host\n" ; exit 1 }
"Connection refused" { send_user "ERROR: Connection refused\n" ; exit 1 }
"Connection closed" { send_user "ERROR: Connection closed\n" ; exit 1 }
"authenticity" { send "yes\n"
expect {
"word: " { send "$PASSWORD\n" }
"passphrase" { send "$PASSWORD\n" }
}
}
"word: " { send "$PASSWORD\n" }
"passphrase" { send "$PASSWORD\n" }
"command not found" { exit 3 }
# -re {[$#] } { exit 0 }
"Exit status 0" { exit 0 }
"Exit status 1" { exit 1 }
"Exit status 3" { exit 1 }
"Exit status 4" { exit 1 }
timeout { exit 2 }
"Permission denied, please try again" { send_user "FAILED: Invalid password\n" ; exit 1 }
}
expect {
"command not found" { exit 3 }
# -re {[$#] } { exit 0 }
"Exit status 0" { exit 0 }
"Exit status 1" { exit 1 }
"Exit status 3" { exit 1 }
"Exit status 4" { exit 1 }
timeout { exit 2 }
"cannot access" { exit 1}
"Permission denied, please try again" { send_user "FAILED: Invalid password\n" ; exit 1 }
"(y or n)" { send "y\n"
"command not found" { exit 3 }
# expect -re {[$#] } { exit 0 }
"Exit status 0" { exit 0 }
"Exit status 1" { exit 1 }
"Exit status 3" { exit 1 }
"Exit status 4" { exit 1 }
timeout { exit 2 }
}
}
exit 0

View File

@ -1,53 +0,0 @@
#!/usr/bin/expect
#
# $Id: remote_commend.sh 421 2007-04-05 15:46:55Z dhill $
#
# Remote command execution script to another server
# Argument 1 - Remote Server Host Name or IP address
# Argument 2 - Remote Server root password
# Argument 3 - Command
# Argument 4 - Good Response
# Argument 5 - Bad Response
# Argument 6 - timeout
# Argument 7 - Debug flag
set timeout 30
set SERVER [lindex $argv 0]
set USERNAME [lindex $argv 1]
set PASSWORD [lindex $argv 2]
set COMMAND [lindex $argv 3]
set GOOD_RESPONSE [lindex $argv 4]
set BAD_RESPONSE [lindex $argv 5]
set timeout [lindex $argv 6]
set DEBUG [lindex $argv 7]
log_user $DEBUG
spawn -noecho /bin/bash
expect -re {[$#] }
#
# send command
#
send "ssh $USERNAME@$SERVER '$COMMAND'\n"
expect {
-re "authenticity" { send "yes\n"
expect {
timeout { send_user "TIMEOUT\n" ; exit 2 }
-re "word: " { send "$PASSWORD\n" } abort
}
}
timeout { send_user "TIMEOUT\n" ; exit 2 }
-re "service not known" { send_user "FAILED: Invalid Host\n" ; exit 1 }
-re "Permission denied" { send_user "FAILED: Invalid Password\n" ; exit 1 }
-re "word: " { send "$PASSWORD\n" } abort
-re $GOOD_RESPONSE { send_user " " ; exit 0 }
-re $BAD_RESPONSE { send_user "FAILED\n" ; exit 1 }
-re "parser error" { send_user "FAILED: System Columnstore.xml parse error\n" ; exit 1 }
}
expect {
timeout { send_user "FAILED-TIMEOUT\n" ; exit 1 }
-re $GOOD_RESPONSE { send_user " " ; exit 0 }
-re $BAD_RESPONSE { send_user "FAILED\n" ; exit 1 }
-re "No such file" { send_user "FAILED\n" ; exit 1 }
-re "parser error" { send_user "FAILED: System Columnstore.xml parse error\n" ; exit 1 }
}
exit 1

View File

@ -1,60 +0,0 @@
#!/usr/bin/expect
#
# $Id: remote_commend.sh 421 2007-04-05 15:46:55Z dhill $
#
# Remote command execution script to another server
# Argument 1 - Remote Server Host Name or IP address
# Argument 2 - Remote Server root password
# Argument 3 - Command
set timeout 10
exec whoami > whoami.tmp
set USERNAME [exec cat whoami.tmp]
exec rm -f whoami.tmp
set SERVER [lindex $argv 0]
set PASSWORD [lindex $argv 1]
set FILE [lindex $argv 2]
set DEBUG [lindex $argv 3]
log_user $DEBUG
spawn -noecho /bin/bash
if { $PASSWORD == "ssh" } {
set PASSWORD ""
}
#
# send command
#
#expect -re {[$#] }
send "scp -v $USERNAME@$SERVER:$FILE .\n"
expect {
"Exit status 0" { exit 0 }
"Exit status 1" { exit 1 }
"100%" { send_user "DONE\n" ; exit 0 }
"authenticity" { send "yes\n"
expect {
"word: " { send "$PASSWORD\n" }
"passphrase" { send "$PASSWORD\n" }
}
}
"service not known" { send_user "FAILED: Invalid Host\n" ; exit 1 }
"Connection refused" { send_user "ERROR: Connection refused\n" ; exit 1 }
"Connection timed out" { send_user "FAILED: Connection timed out\n" ; exit 1 }
"lost connection" { send_user "FAILED: Connection refused\n" ; exit 1 }
"Connection closed" { send_user "ERROR: Connection closed\n" ; exit 1 }
"word: " { send "$PASSWORD\n" }
"passphrase" { send "$PASSWORD\n" }
"scp:" { send_user "FAILED\n" ; exit 1 }
"Permission denied, please try again" { send_user "FAILED: Invalid password\n" ; exit 1 }
}
expect {
"Exit status 0" { exit 0 }
"Exit status 1" { exit 1 }
"100%" { send_user "DONE\n" ; exit 0 }
"scp:" { send_user "FAILED\n" ; exit 1 }
"Permission denied, please try again" { send_user "FAILED: Invalid password\n" ; exit 1 }
"No such file or directory" { send_user "FAILED: No such file or directory\n" ; exit 1 }
"Connection refused" { send_user "ERROR: Connection refused\n" ; exit 1 }
"Connection closed" { send_user "ERROR: Connection closed\n" ; exit 1 }
}
exit 0

View File

@ -1,59 +0,0 @@
#!/usr/bin/expect
#
# $Id: remote_commend.sh 421 2007-04-05 15:46:55Z dhill $
#
# Remote command execution script to another server
# Argument 1 - Remote Server Host Name or IP address
# Argument 2 - Remote Server root password
# Argument 3 - Command
set timeout 30
exec whoami >whoami.tmp
set USERNAME [exec cat whoami.tmp]
exec rm -f whoami.tmp
set SERVER [lindex $argv 0]
set PASSWORD [lindex $argv 1]
set FILE [lindex $argv 2]
set DEBUG [lindex $argv 3]
log_user $DEBUG
spawn -noecho /bin/bash
if { $PASSWORD == "ssh" } {
set PASSWORD ""
}
#
# send command
#
send "scp -v $FILE $USERNAME@$SERVER:$FILE\n"
expect {
"Exit status 0" { exit 0 }
"Exit status 1" { exit 1 }
-re "100%" { send_user "DONE\n" ; sleep 2; exit 0 }
-re "authenticity" { send "yes\n"
expect {
-re "word: " { send "$PASSWORD\n" }
-re "passphrase" { send "$PASSWORD\n" }
}
}
-re "service not known" { send_user "FAILED: Invalid Host\n" ; exit 1 }
-re "Connection refused" { send_user "FAILED: Connection refused\n" ; exit 1 }
-re "Connection timed out" { send_user "FAILED: Connection timed out\n" ; exit 1 }
-re "lost connection" { send_user "FAILED: Connection refused\n" ; exit 1 }
-re "Connection closed" { send_user "ERROR: Connection closed\n" ; exit 1 }
-re "word: " { send "$PASSWORD\n" }
-re "passphrase" { send "$PASSWORD\n" }
-re "WARNING:" { send "rm -f /root/.ssh/known_hosts" ; exit 1 }
-re "Permission denied, please try again" { send_user "FAILED: Invalid password\n" ; exit 1 }
}
expect {
"Exit status 0" { exit 0 }
"Exit status 1" { exit 1 }
-re "100%" { send_user "DONE\n" ; sleep 2 ; exit 0 }
-re "scp:" { send_user "FAILED\n" ; exit 1 }
-re "Permission denied, please try again" { send_user "FAILED: Invalid password\n" ; exit 1 }
-re "No such file or directory" { send_user "FAILED: Invalid file\n" ; exit 1 }
-re "Connection refused" { send_user "FAILED: Connection refused\n" ; exit 1 }
-re "Connection closed" { send_user "ERROR: Connection closed\n" ; exit 1 }
}
exit 0

View File

@ -1,89 +0,0 @@
set PROMPT "(\\$|#) "
proc auto_ssh_command { username password server commandstr } {
global PROMPT
#
# send command
#
send "ssh -t $username@$server $commandstr\n"
expect {
-re "Host key verification failed" { send_user "FAILED: Host key verification failed\n" ; exit 1}
-re "service not known" { send_user " FAILED: Invalid Host\n" ; exit 1}
-re "ssh: connect to host" { send_user " FAILED: Invalid Host\n" ; exit 1 }
-re "Connection refused" { send_user "ERROR: Connection refused\n" ; exit 1 }
-re "Connection closed" { send_user "ERROR: Connection closed\n" ; exit 1 }
-re "authenticity" { send "yes\n"
expect {
-re "word: " { send "$password\n" } abort
-re "passphrase" { send "$password\n" } abort
}
}
-re "word: " { send "$password\n" } abort
-re "passphrase" { send "$password\n" } abort
}
set needsudopwd 0
expect {
-re $PROMPT { exit 0 }
-re "Permission denied, please try again" { send_user " FAILED: Invalid password\n" ; exit 1 }
-re ": Permission denied" { send_user " FAILED: Privilege error\n" ; exit 1 }
-re "(y or n)" { send "y\n"
expect -re $PROMPT { exit 0 }
}
-re "sudo\\] password for $username: " {
send "$password\n";
set needsudopwd 1
} abort
}
if {$needsudopwd} {
expect {
-re $PROMPT { exit 0 }
-re "try again" { send_user " FAILED: Invalid sudo password\n" ; exit 1 }
}
}
}
proc auto_scp_command { username password server srcpath destpath } {
global PROMPT
send "scp $srcpath $username@$server:$destpath\n"
expect {
-re "Host key verification failed" { send_user "FAILED: Host key verification failed\n" ; exit 1}
-re "service not known" { send_user " FAILED: Invalid Host\n" ; exit 1}
-re "ssh: connect to host" { send_user " FAILED: Invalid Host\n" ; exit 1 }
-re "Connection refused" { send_user "ERROR: Connection refused\n" ; exit 1 }
-re "Connection closed" { send_user "ERROR: Connection closed\n" ; exit 1 }
-re "authenticity" { send "yes\n"
expect {
-re "word: " { send "$password\n" } abort
-re "passphrase" { send "$password\n" } abort
}
}
-re "word: " { send "$password\n" } abort
-re "passphrase" { send "$password\n" } abort
}
expect {
-re $PROMPT { exit 0 }
-re "Permission denied, please try again" { send_user " FAILED: Invalid password\n" ; exit 1 }
-re ": Permission denied" { send_user " FAILED: Privilege error\n" ; exit 1 }
-re "(y or n)" { send "y\n"
expect -re $PROMPT { exit 0 }
}
}
set timeout 30
expect {
-re "100%" { send_user "DONE" } abort
-re "directory" { send_user "ERROR\n" ;
send_user "\n*** Installation ERROR\n" ;
exit 1 }
-re "Permission denied, please try again" { send_user "ERROR: Invalid password\n" ; exit 1 }
-re "No such file or directory" { send_user "ERROR: Invalid package\n" ; exit 1 }
}
send_user "\n"
# sleep to make sure it's finished
sleep 5
}

View File

@ -1,83 +0,0 @@
#!/usr/bin/expect
#
# $Id: rsync.sh 2915 2012-05-23 16:01:34Z dhill $
#
# Remote Install RPM and custom OS files from postConfigure script
# Argument 1 - Remote Server Host Name or IP address
# Argument 2 - Root Password of remote server
# Argument 3 - Debug flag 1 for on, 0 for off
set SERVER [lindex $argv 0]
set PASSWORD [lindex $argv 1]
set DEBUG 0
set DEBUG [lindex $argv 3]
log_user $DEBUG
spawn -noecho /bin/bash
if {[info exists env(USER)]} {
set USERNAME $env(USER)
} else {
set USERNAME "root"
}
if { $PASSWORD == "ssh" } {
set PASSWORD ""
}
# LinuxJedi: Not sure what this is expecting to be copying, but it probably shouldn't be doing it
# set COMMAND "rsync -vopgr -e ssh --exclude=mysql/ --exclude=test/ --exclude=infinidb_vtable/ --exclude=infinidb_querystats/ --exclude=calpontsys/ --include=*/ --include=*/* --exclude=* $INSTALLDIR/mysql/db/ $USERNAME@$SERVER:$INSTALLDIR/mysql/db/"
#
# run command
#
set timeout 20
send "$COMMAND\n"
expect {
-re "Host key verification failed" { send_user "FAILED: Host key verification failed\n" ; exit -1}
-re "service not known" { send_user " FAILED: Invalid Host\n" ; exit -1}
-re "ssh: connect to host" { send_user " FAILED: Invalid Host\n" ; exit -1 }
-re "authenticity" { send "yes\n"
expect {
-re "word: " { send "$PASSWORD\n" }
-re "passphrase" { send "$PASSWORD\n" }
}
}
-re "word: " { send "$PASSWORD\n" }
-re "passphrase" { send "$PASSWORD\n" }
-re "failed" { send_user " FAILED: Failure, check tmp log\n" ; exit 1 }
-re "Permission denied" { send_user " FAILED: Invalid password\n" ; exit 1 }
-re "total size" {} abort
}
expect {
-re "failed" { send_user " FAILED: Failure, check tmp log\n" ; exit 1 }
-re "Permission denied" { send_user " FAILED: Invalid password\n" ; exit 1 }
-re "total size" {} abort
}
set HOME "$env(HOME)"
if {[file exist $HOME/.my.cnf]} {
set COMMAND "rsync -vopgr -e ssh $HOME/.my.cnf $USERNAME@$SERVER:$HOME/"
#
# run command
#
set timeout 10
send "$COMMAND\n"
expect {
-re "word: " { send "$PASSWORD\n" }
-re "passphrase" { send "$PASSWORD\n" }
-re "total size" {} abort
-re "failed" { exit 0 }
timeout { exit 0 }
}
expect {
-re "total size" {} abort
-re "failed" { exit 0 }
timeout { exit 0 }
}
}
exit 0

View File

@ -1,111 +0,0 @@
#!/bin/bash
#
# $Id$
#
# generic MariaDB Columnstore Slave Replication script.
#
# Notes: This script gets run by ProcMon during installs and upgrades:
# check log for error
checkForError() {
grep ERROR ${tmpdir}/slave-rep-status.log > ${tmpdir}/error.check
if [ `cat ${tmpdir}/error.check | wc -c` -ne 0 ]; then
echo "ERROR: check log file: ${tmpdir}/slave-rep-status.log"
rm -f ${tmpdir}/error.check
exit 1
fi
rm -f ${tmpdir}/error.check
}
pwprompt=
for arg in "$@"; do
if [ `expr -- "$arg" : '--masteripaddr='` -eq 15 ]; then
masteripaddr="`echo $arg | awk -F= '{print $2}'`"
elif [ `expr -- "$arg" : '--masterlogfile='` -eq 16 ]; then
masterlogfile="`echo $arg | awk -F= '{print $2}'`"
elif [ `expr -- "$arg" : '--masterlogpos='` -eq 15 ]; then
masterlogpos="`echo $arg | awk -F= '{print $2}'`"
elif [ `expr -- "$arg" : '--port='` -eq 7 ]; then
port="`echo $arg | awk -F= '{print $2}'`"
elif [ $(expr -- "$arg" : '--tmpdir=') -eq 9 ]; then
tmpdir="$(echo $arg | awk -F= '{print $2}')"
fi
done
. @ENGINE_SUPPORTDIR@/columnstore_functions
repUser="idbrep"
password="C0lumnStore!"
>${tmpdir}/slave-rep-status.log
#
# Run stop slave command
#
echo "Run stop slave command" >>${tmpdir}/slave-rep-status.log
cat >${tmpdir}/idb_slave-rep.sql <<EOD
stop slave;
EOD
cat ${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log
mysql \
--user=root \
calpontsys <${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log 2>&1
checkForError
#
# Run Change Master Command
#
echo "Run Change Master Command" >>${tmpdir}/slave-rep-status.log
cat >${tmpdir}/idb_slave-rep.sql <<EOD
CHANGE MASTER TO
MASTER_HOST='$masteripaddr',
MASTER_USER='$repUser',
MASTER_PASSWORD='$password',
MASTER_PORT=$port,
MASTER_LOG_FILE='$masterlogfile',
MASTER_LOG_POS=$masterlogpos;
EOD
cat ${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log
mysql \
--user=root \
calpontsys <${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log 2>&1
checkForError
#
# Run start slave command
#
echo "Run start slave command" >>${tmpdir}/slave-rep-status.log
cat >${tmpdir}/idb_slave-rep.sql <<EOD
start slave;
EOD
cat ${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log
mysql \
--user=root \
calpontsys <${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log 2>&1
checkForError
#
# Run SHOW SLAVE STATUS
#
echo "Run SHOW SLAVE STATUS to node log" >>${tmpdir}/slave-rep-status.log
cat >${tmpdir}/idb_slave-rep.sql <<EOD
SHOW SLAVE STATUS\G
EOD
cat ${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log
mysql \
--user=root \
calpontsys <${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log 2>&1
checkForError
#alls good, 'OK' for success
echo "OK"
exit 0

View File

@ -1,31 +0,0 @@
#!/bin/bash
#
# $Id: startupTests.sh 2937 2012-05-30 18:17:09Z rdempsey $
#
# startupTests - perform sanity testing on system DB at system startup time
# called by Process-Monitor
# Source function library.
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
fi
. @ENGINE_SUPPORTDIR@/columnstore_functions
for testScript in @ENGINE_SUPPORTDIR@/mcstest*.sh; do
if [ -x $testScript ]; then
eval $testScript
rc=$?
if [ $rc -ne 0 ]; then
cplogger -c 51 $testScript
echo "FAILED, check Critical log for additional info"
exit $rc
fi
fi
done
echo "OK"
cplogger -i 54
exit 0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -111,86 +111,9 @@ void OamCache::checkReload()
// Restore for Windows when we support multiple PMs
while (it != uniquePids.end())
{
// Disable legacy-OAM.
/*
if (getenv("SKIP_OAM_INIT") == NULL)
{
try
{
int state = oam::MAN_INIT;
bool degraded;
char num[80];
int retry = 0;
// MCOL-259 retry for 5 seconds if the PM is in some INIT mode.
while (( state == oam::BUSY_INIT
|| state == oam::MAN_INIT
|| state == oam::PID_UPDATE)
&& retry < 5)
{
snprintf(num, 80, "%d", *it);
try
{
oam.getModuleStatus(string("pm") + num, state, degraded);
}
catch (std::exception& e)
{
ostringstream os;
os << "OamCache::checkReload exception while getModuleStatus pm" << num << " " << e.what();
oam.writeLog(os.str(), logging::LOG_TYPE_ERROR);
break;
}
catch (...)
{
ostringstream os;
os << "OamCache::checkReload exception while getModuleStatus pm" << num;
oam.writeLog(os.str(), logging::LOG_TYPE_ERROR);
break;
}
if (state == oam::ACTIVE || state == oam::DEGRADED)
{
pmToConnectionMap[*it] = i++;
moduleIds.push_back(*it);
break;
}
sleep(1);
++retry;
//cout << "pm " << *it << " -> connection " << (i-1) << endl;
}
if (state != oam::ACTIVE)
{
ostringstream os;
os << "OamCache::checkReload shows state for pm" << num << " as " << oamState[state];
oam.writeLog(os.str(), logging::LOG_TYPE_ERROR);
}
}
catch (std::exception& e)
{
ostringstream os;
os << "OamCache::checkReload final exception while getModuleStatus " << e.what();
oam.writeLog(os.str(), logging::LOG_TYPE_ERROR);
break;
}
catch (...)
{
ostringstream os;
os << "OamCache::checkReload final exception while getModuleStatus";
oam.writeLog(os.str(), logging::LOG_TYPE_ERROR);
break;
}
}
else
*/
{
pmToConnectionMap[*it] = i++;
moduleIds.push_back(*it);
}
pmToConnectionMap[*it] = i++;
moduleIds.push_back(*it);
it++;
}
#endif

View File

@ -1,703 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***************************************************************************
* dhill@srvengcm1.calpont.com
*
* Purpose: OAM C++ API tester
*
***************************************************************************/
#include <string>
#include <stdexcept>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <limits.h>
#include <sstream>
#include <exception>
using namespace std;
#include <boost/scoped_ptr.hpp>
using namespace boost;
#include <cppunit/extensions/HelperMacros.h>
#include "liboamcpp.h"
using namespace oam;
using namespace alarmmanager;
class getModuleInfoTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( getModuleInfoTest );
CPPUNIT_TEST( test1 );
CPPUNIT_TEST_SUITE_END();
private:
string Svalue;
int Ivalue;
bool Bvalue;
public:
void setUp()
{
setenv("CALPONT_HOME", "/home/buildslave/Buildbot/nightly/export/etc/", 1);
// setenv("CALPONT_HOME", "/home/dhill/genii/export/etc/", 1);
}
void tearDown()
{
}
void test1()
{
Oam oamapi;
Svalue = oamapi.getCurrentTime();
cout << "Current time is " << Svalue;
CPPUNIT_ASSERT(!Svalue.empty());
Bvalue = oamapi.isValidIP("111.222.333.444");
CPPUNIT_ASSERT(Bvalue == true);
Bvalue = oamapi.isValidIP("111.222.333");
CPPUNIT_ASSERT(Bvalue == false);
Bvalue = oamapi.isValidIP("1.2.3.4");
CPPUNIT_ASSERT(Bvalue == true);
Bvalue = oamapi.isValidIP("1.2.3.4444");
CPPUNIT_ASSERT(Bvalue == false);
Bvalue = oamapi.isValidIP("1111.222.333.444");
CPPUNIT_ASSERT(Bvalue == false);
// can test on deve machine
// oamModuleInfo_t t;
// t = oamapi.getModuleInfo();
// Svalue = get<0>(t);
// CPPUNIT_ASSERT(Svalue == "dm1");
// Svalue = get<1>(t);
// CPPUNIT_ASSERT(Svalue == "dm1");
// Ivalue = get<2>(t);
// CPPUNIT_ASSERT(Ivalue == MASTER_YES);
};
};
class getSystemConfigTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( getSystemConfigTest );
CPPUNIT_TEST( test1 );
CPPUNIT_TEST( test2 );
//CPPUNIT_TEST( test3 );
//CPPUNIT_TEST( test4 );
//CPPUNIT_TEST( test5 );
CPPUNIT_TEST_EXCEPTION( test6, std::runtime_error );
//CPPUNIT_TEST_EXCEPTION( test7, std::runtime_error );
CPPUNIT_TEST( test8 );
CPPUNIT_TEST_EXCEPTION( test9, std::runtime_error );
CPPUNIT_TEST( test10 );
CPPUNIT_TEST_SUITE_END();
private:
string Svalue;
int Ivalue;
public:
void setUp()
{
setenv("CALPONT_HOME", "/home/buildslave/Buildbot/nightly/export/etc/", 1);
// setenv("CALPONT_HOME", "/home/dhill/genii/export/etc/", 1);
}
void tearDown()
{
}
void test1()
{
SystemConfig systemconfig;
Oam oamapi;
oamapi.getSystemConfig(systemconfig);
Ivalue = systemconfig.ModuleHeartbeatPeriod;
CPPUNIT_ASSERT(Ivalue != -1);
Ivalue = systemconfig.ModuleHeartbeatCount;
CPPUNIT_ASSERT(Ivalue != -1);
// Ivalue = systemconfig.ProcessHeartbeatPeriod;
// CPPUNIT_ASSERT(Ivalue != -2);
Svalue = systemconfig.NMSIPAddr;
CPPUNIT_ASSERT(!Svalue.empty());
};
void test2()
{
SystemModuleTypeConfig systemmoduletypeconfig;
Oam oamapi;
oamapi.getSystemConfig(systemmoduletypeconfig);
for ( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++)
{
if ( systemmoduletypeconfig.moduletypeconfig[i].ModuleType.empty() )
// end of list
break;
Svalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleType;
CPPUNIT_ASSERT(!Svalue.empty());
Svalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleDesc;
CPPUNIT_ASSERT(!Svalue.empty());
Ivalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleCount;
CPPUNIT_ASSERT(Ivalue != -1);
Ivalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleCPUCriticalThreshold;
CPPUNIT_ASSERT(Ivalue != -1);
Ivalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleCPUMajorThreshold;
CPPUNIT_ASSERT(Ivalue != -1);
Ivalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleCPUMinorThreshold;
CPPUNIT_ASSERT(Ivalue != -1);
Ivalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleCPUMinorClearThreshold;
CPPUNIT_ASSERT(Ivalue != -1);
}
};
/* void test3() {
ModuleConfig moduleconfig;
const string Modulename = "dm1";
Oam oamapi;
oamapi.getSystemConfig(Modulename, moduleconfig);
Svalue = moduleconfig.ModuleName;
CPPUNIT_ASSERT(!Svalue.empty());
};
*/
void test4()
{
ModuleConfig moduleconfig;
Oam oamapi;
oamapi.getSystemConfig(moduleconfig);
Svalue = moduleconfig.ModuleName;
CPPUNIT_ASSERT(!Svalue.empty());
};
void test5()
{
Oam oamapi;
oamapi.setSystemConfig("SystemVersion", "V2.0.2.3");
oamapi.getSystemConfig("SystemVersion", Svalue);
CPPUNIT_ASSERT(Svalue == "V2.0.2.3");
};
void test6()
{
Oam oamapi;
oamapi.getSystemConfig("SystemVersionBad", Svalue);
CPPUNIT_ASSERT(Svalue.size() == 0);
};
void test7()
{
Oam oamapi;
oamapi.setSystemConfig("SystemVersionBad", "V2.0.2.3");
};
void test8()
{
Oam oamapi;
oamapi.setSystemConfig("ModuleHeartbeatPeriod", 5);
oamapi.getSystemConfig("ModuleHeartbeatPeriod", Ivalue);
CPPUNIT_ASSERT(Ivalue == 5);
};
void test9()
{
Oam oamapi;
oamapi.getSystemConfig("ModuleHeartbeatPeriodBad", Ivalue);
CPPUNIT_ASSERT(Ivalue == 0);
};
void test10()
{
Oam oamapi;
oamapi.setSystemConfig("ModuleCPUMajorThreshold1", 7500);
oamapi.getSystemConfig("ModuleCPUMajorThreshold1", Ivalue);
CPPUNIT_ASSERT(Ivalue == 7500);
};
};
/*
class getSystemStatusTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE( getSystemStatusTest );
CPPUNIT_TEST( test1 );
CPPUNIT_TEST( test2 );
CPPUNIT_TEST( test3 );
CPPUNIT_TEST( test4 );
CPPUNIT_TEST_SUITE_END();
private:
Oam oamapi;
string Svalue;
int Ivalue;
public:
void setUp() {
}
void tearDown() {
}
void test1() {
SystemStatus systemstatus;
oamapi.getSystemStatus(systemstatus);
Svalue = systemstatus.SystemOpState;
CPPUNIT_ASSERT(!Svalue.empty());
for( unsigned int i = 0 ; i < systemstatus.systemModulestatus.Modulestatus.size(); i++)
{
if( systemstatus.systemModulestatus.Modulestatus[i].Module.empty() )
// end of list
break;
Svalue = systemstatus.systemModulestatus.Modulestatus[i].Module;
CPPUNIT_ASSERT(!Svalue.empty());
Svalue = systemstatus.systemModulestatus.Modulestatus[i].ModuleOpState;
CPPUNIT_ASSERT(!Svalue.empty());
}
};
void test2() {
oamapi.getModuleStatus("dm1", Svalue);
CPPUNIT_ASSERT(!Svalue.empty());
};
void test3() {
oamapi.setSystemStatus("ACTIVE");
SystemStatus systemstatus;
oamapi.getSystemStatus(systemstatus);
Svalue = systemstatus.SystemOpState;
CPPUNIT_ASSERT(Svalue == "ACTIVE");
oamapi.setSystemStatus("AUTO_OFFLINE");
};
void test4() {
oamapi.setModuleStatus("dm1", "ACTIVE");
oamapi.getModuleStatus("dm1", Svalue);
CPPUNIT_ASSERT(Svalue == "ACTIVE");
oamapi.setModuleStatus("dm1", "AUTO_OFFLINE");
};
};
*/
class getProcessConfigTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( getProcessConfigTest );
CPPUNIT_TEST( test1 );
CPPUNIT_TEST( test2 );
CPPUNIT_TEST_EXCEPTION( test3, std::runtime_error );
CPPUNIT_TEST( test4 );
CPPUNIT_TEST_EXCEPTION( test5, std::runtime_error );
CPPUNIT_TEST_SUITE_END();
private:
string Svalue;
int Ivalue;
public:
void setUp()
{
setenv("CALPONT_HOME", "/home/buildslave/Buildbot/nightly/export/etc/", 1);
// setenv("CALPONT_HOME", "/home/dhill/genii/export/etc/", 1);
}
void tearDown()
{
}
void test1()
{
SystemProcessConfig systemprocessconfig;
Oam oamapi;
oamapi.getProcessConfig(systemprocessconfig);
for ( unsigned int i = 0 ; i < systemprocessconfig.processconfig.size(); i++)
{
Svalue = systemprocessconfig.processconfig[i].ProcessName;
CPPUNIT_ASSERT(!Svalue.empty());
Svalue = systemprocessconfig.processconfig[i].ModuleType;
CPPUNIT_ASSERT(!Svalue.empty());
Svalue = systemprocessconfig.processconfig[i].ProcessLocation;
CPPUNIT_ASSERT(!Svalue.empty());
for ( int j = 0 ; j < oam::MAX_ARGUMENTS; j++)
{
if (systemprocessconfig.processconfig[i].ProcessArgs[j].empty())
break;
Svalue = systemprocessconfig.processconfig[i].ProcessArgs[j];
CPPUNIT_ASSERT(!Svalue.empty());
}
Ivalue = systemprocessconfig.processconfig[i].BootLaunch;
CPPUNIT_ASSERT(Ivalue != -1);
Ivalue = systemprocessconfig.processconfig[i].LaunchID;
CPPUNIT_ASSERT(Ivalue != -1);
for ( int j = 0 ; j < MAX_DEPENDANCY; j++)
{
if (systemprocessconfig.processconfig[i].DepProcessName[j].empty())
break;
Svalue = systemprocessconfig.processconfig[i].DepProcessName[j];
CPPUNIT_ASSERT(!Svalue.empty());
Svalue = systemprocessconfig.processconfig[i].DepModuleName[j];
CPPUNIT_ASSERT(!Svalue.empty());
}
}
};
void test2()
{
ProcessConfig processconfig;
Oam oamapi;
oamapi.getProcessConfig("ProcessManager", "dm1", processconfig);
Svalue = processconfig.ProcessName;
CPPUNIT_ASSERT(!Svalue.empty());
Svalue = processconfig.ModuleType;
CPPUNIT_ASSERT(!Svalue.empty());
Svalue = processconfig.ProcessLocation;
CPPUNIT_ASSERT(!Svalue.empty());
for ( int j = 0 ; j < oam::MAX_ARGUMENTS; j++)
{
if (processconfig.ProcessArgs[j].empty())
break;
Svalue = processconfig.ProcessArgs[j];
CPPUNIT_ASSERT(!Svalue.empty());
}
Ivalue = processconfig.BootLaunch;
CPPUNIT_ASSERT(Ivalue != -1);
Ivalue = processconfig.LaunchID;
CPPUNIT_ASSERT(Ivalue != -1);
for ( int j = 0 ; j < MAX_DEPENDANCY; j++)
{
if (processconfig.DepProcessName[j].empty())
break;
Svalue = processconfig.DepProcessName[j];
CPPUNIT_ASSERT(!Svalue.empty());
Svalue = processconfig.DepModuleName[j];
CPPUNIT_ASSERT(!Svalue.empty());
}
};
void test3()
{
ProcessConfig processconfig;
Oam oamapi;
oamapi.getProcessConfig("SNMPTrapDaemonBAD", "dm1", processconfig);
CPPUNIT_ASSERT(Svalue.size() == 0);
};
void test4()
{
Oam oamapi;
oamapi.setProcessConfig("ProcessManager", "dm1", "BootLaunch", 10);
oamapi.getProcessConfig("ProcessManager", "dm1", "BootLaunch", Ivalue);
CPPUNIT_ASSERT(Ivalue == 10);
};
void test5()
{
ProcessConfig processconfig;
Oam oamapi;
oamapi.getProcessConfig("ProcessManager", "dm1", "ModuleTypeBAD", Svalue);
CPPUNIT_ASSERT(Svalue.size() == 0);
};
};
/*
class getProcessStatusTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE( getProcessConfigTest );
CPPUNIT_TEST( test1 );
CPPUNIT_TEST( test2 );
CPPUNIT_TEST_EXCEPTION( test3, std::runtime_error );
//CPPUNIT_TEST( test4 );
CPPUNIT_TEST_EXCEPTION( test5, std::runtime_error );
CPPUNIT_TEST_SUITE_END();
private:
Oam oamapi;
string Svalue;
int Ivalue;
public:
void setUp() {
}
void tearDown() {
}
void test1() {
SystemProcessStatus systemprocessstatus;
oamapi.getProcessStatus(systemprocessstatus);
for( unsigned int i = 0 ; i < systemprocessstatus.processstatus.size(); i++)
{
Svalue = systemprocessstatus.processstatus[i].ProcessName;
CPPUNIT_ASSERT(!Svalue.empty());
Svalue = systemprocessstatus.processstatus[i].Module;
CPPUNIT_ASSERT(!Svalue.empty());
Ivalue = systemprocessstatus.processstatus[i].ProcessID;
CPPUNIT_ASSERT(Ivalue != -1);
Svalue = systemprocessstatus.processstatus[i].StateChangeDate;
CPPUNIT_ASSERT(!Svalue.empty());
Svalue = systemprocessstatus.processstatus[i].ProcessOpState;
CPPUNIT_ASSERT(!Svalue.empty());
}
};
void test2() {
ProcessStatus processstatus;
oamapi.getProcessStatus("ProcessManager", "dm1", processstatus);
Svalue = processstatus.ProcessName;
CPPUNIT_ASSERT(!Svalue.empty());
Svalue = processstatus.Module;
CPPUNIT_ASSERT(!Svalue.empty());
Ivalue = processstatus.ProcessID;
CPPUNIT_ASSERT(Ivalue != -1);
Svalue = processstatus.StateChangeDate;
CPPUNIT_ASSERT(!Svalue.empty());
Svalue = processstatus.ProcessOpState;
CPPUNIT_ASSERT(!Svalue.empty());
};
void test3() {
ProcessStatus processstatus;
oamapi.getProcessStatus("SNMPTrapDaemonBAD", "dm1", processstatus);
CPPUNIT_ASSERT(Svalue.size() == 0);
};
void test4() {
oamapi.setProcessStatus("ProcessManager", "dm1", "StateChangeDate", "1234567");
oamapi.getProcessStatus("ProcessManager", "dm1", "StateChangeDate", Svalue);
CPPUNIT_ASSERT(Svalue == "1234567");
};
void test5() {
oamapi.getProcessStatus("ProcessManager", "dm1", "StateChangeDateBAD", Svalue);
CPPUNIT_ASSERT(Svalue.size() == 0);
};
void test6() {
oamapi.setProcessStatus("ProcessManager", "dm1", "ProcessID", 10);
oamapi.getProcessStatus("ProcessManager", "dm1", "ProcessID", Ivalue);
CPPUNIT_ASSERT(Ivalue == 10);
};
};
*/
class getAlarmConfigTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( getAlarmConfigTest );
CPPUNIT_TEST( test1 );
CPPUNIT_TEST( test2 );
CPPUNIT_TEST_EXCEPTION( test3, std::runtime_error );
//CPPUNIT_TEST( test4 );
CPPUNIT_TEST_SUITE_END();
private:
string Svalue;
int Ivalue;
public:
void setUp()
{
setenv("CALPONT_HOME", "/home/buildslave/Buildbot/nightly/export/etc/", 1);
// setenv("CALPONT_HOME", "/home/dhill/genii/export/etc/", 1);
}
void tearDown()
{
}
void test1()
{
AlarmConfig alarmconfig;
Oam oamapi;
for ( int alarmID = 1 ; alarmID < MAX_ALARM_ID; alarmID++)
{
oamapi.getAlarmConfig(alarmID, alarmconfig);
Svalue = alarmconfig.BriefDesc;
CPPUNIT_ASSERT(!Svalue.empty());
Svalue = alarmconfig.DetailedDesc;
CPPUNIT_ASSERT(!Svalue.empty());
Svalue = alarmconfig.Severity;
CPPUNIT_ASSERT(!Svalue.empty());
Ivalue = alarmconfig.Threshold;
CPPUNIT_ASSERT(Ivalue != -1);
Ivalue = alarmconfig.Occurrences;
CPPUNIT_ASSERT(Ivalue != -1);
Svalue = alarmconfig.LastIssueTime;
CPPUNIT_ASSERT(!Svalue.empty());
}
};
void test2()
{
Oam oamapi;
oamapi.setAlarmConfig(CPU_USAGE_MED, "Threshold", 20);
oamapi.getAlarmConfig(CPU_USAGE_MED, "Threshold", Ivalue);
CPPUNIT_ASSERT(Ivalue == 20);
};
void test3()
{
Oam oamapi;
oamapi.getAlarmConfig(CPU_USAGE_MED, "ThresholdBAD", Ivalue);
CPPUNIT_ASSERT(Ivalue == 0);
};
/* void test4() {
// test getActiveAlarm API
AlarmList activeAlarm;
#if 1
Oam oamapi;
oamapi.getActiveAlarms (activeAlarm);
#endif
};
*/
};
CPPUNIT_TEST_SUITE_REGISTRATION( getModuleInfoTest );
CPPUNIT_TEST_SUITE_REGISTRATION( getSystemConfigTest );
//CPPUNIT_TEST_SUITE_REGISTRATION( getSystemStatusTest );
//CPPUNIT_TEST_SUITE_REGISTRATION( getProcessStatusTest );
CPPUNIT_TEST_SUITE_REGISTRATION( getProcessConfigTest );
CPPUNIT_TEST_SUITE_REGISTRATION( getAlarmConfigTest );
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
int main( int argc, char** argv)
{
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest( registry.makeTest() );
bool wasSuccessful = runner.run( "", false );
return (wasSuccessful ? 0 : 1);
}

View File

@ -1,7 +0,0 @@
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mcstest-001.sh.in" "${CMAKE_CURRENT_SOURCE_DIR}/mcstest-001.sh" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mcstest-002.sh.in" "${CMAKE_CURRENT_SOURCE_DIR}/mcstest-002.sh" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mcstest-003.sh.in" "${CMAKE_CURRENT_SOURCE_DIR}/mcstest-003.sh" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mcstest-004.sh.in" "${CMAKE_CURRENT_SOURCE_DIR}/mcstest-004.sh" @ONLY)
install(PROGRAMS columnstore_functions mcstest-001.sh mcstest-002.sh mcstest-003.sh mcstest-004.sh DESTINATION ${ENGINE_SUPPORTDIR} COMPONENT columnstore-engine)

View File

@ -1,42 +0,0 @@
#
# $Id: functions 2937 2012-05-30 18:17:09Z rdempsey $
#
# Source function library.
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
fi
module_type()
{
(
sed -r 's/[0-9]+$//' /var/lib/columnstore/local/module
) 2>/dev/null
}
firstboot()
{
dbrmroot="`mcsGetConfig SystemConfig DBRMRoot`"
dbrmdir="`dirname $dbrmroot`"
test ! -f $dbrmdir/BRM_saves_current
}
oidbitmapfile()
{
oidfile="`mcsGetConfig OIDManager OIDBitmapFile`"
test ! -f $oidfile
}
module_name()
{
(
cat /var/lib/columnstore/local/module
) 2>/dev/null
}
module_id()
{
(
sed -r 's/[a-zA-Z]//g' /var/lib/columnstore/local/module
) 2>/dev/null
}

View File

@ -1,63 +0,0 @@
#!/bin/bash
#
# $Id: test-001.sh 3704 2013-08-07 03:33:20Z bwilkinson $
USER=`whoami 2>/dev/null`
# Source function library.
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
fi
. @ENGINE_SUPPORTDIR@/functions
scrname=`basename $0`
tname="check-syscat-oids"
mt=`module_type`
#These tests only for PM
if [ "$mt" != "pm" ]; then
exit 0
fi
#check for dbrm and data1, don't run if missing both
if firstboot; then
if [ -d /var/lib/columnstore/data1/000.dir ]; then
cplogger -c 50 $scrname "$tname" "missing dbrm data with existing 000.dir"
exit 1
else
exit 0
fi
else
#check for oidbitmap file
if oidbitmapfile; then
cplogger -c 50 $scrname "$tname" "missing oidbitmapfile with existing current file"
exit 1
fi
fi
#check for both current file and OIDBITMAP file
#Make sure all syscat OIDs are present (N.B. only works for shared-everything)
cplogger -i 48 $scrname "$tname"
catoids=
catoids="$catoids 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010"
catoids="$catoids 2001 2004"
catoids="$catoids 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040"
catoids="$catoids 2061 2064 2067 2070 2073 2076"
# TODO-this doesn't work with HDFS file system
#for oid in $catoids; do
# if [ ! -s `oid2file $oid` ]; then
# cplogger -c 50 $scrname "$tname" "could not find file for OID $oid"
# exit 1
# fi
#done
cplogger -i 52 $scrname "$tname"
exit 0

View File

@ -1,41 +0,0 @@
#!/bin/bash
#
# $Id: test-002.sh 2937 2012-05-30 18:17:09Z rdempsey $
USER=`whoami 2>/dev/null`
# Source function library.
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
fi
. @ENGINE_SUPPORTDIR@/functions
scrname=`basename $0`
tname="check-brm"
#Don't run on first boot
if firstboot; then
exit 0
fi
#Make sure BRM is read-write
cplogger -i 48 $scrname "$tname"
#turn this test off for now...it doesn't if the DBRM isn't started, and these tests run too early
# we need a way to run some tests at different stages of system startup...
#dbrmctl status 2>&1 | egrep -qsi '^ok'
/bin/true
rc=$?
if [ $rc -ne 0 ]; then
cplogger -c 50 $scrname "$tname" "the BRM is read only"
exit 1
fi
cplogger -i 52 $scrname "$tname"
exit 0

View File

@ -1,42 +0,0 @@
#!/bin/bash
#
# $Id: test-003.sh 2937 2012-05-30 18:17:09Z rdempsey $
USER=`whoami 2>/dev/null`
# Source function library.
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
fi
. @ENGINE_SUPPORTDIR@/functions
scrname=`basename $0`
tname="check-oid-bitmap"
#Don't run on first boot
if firstboot; then
exit 0
fi
#Make sure there is an oid bitmap file if there are any EM entries
cplogger -i 48 $scrname "$tname"
obmfile=$(getConfig OIDManager OIDBitmapFile)
emcnt=$(editem -o 2001 | wc -l)
rc=1
if [ -f $obmfile -o $emcnt -eq 0 ]; then
rc=0
fi
if [ $rc -ne 0 ]; then
cplogger -c 50 $scrname "$tname" "there is no OID bitmap file but there are Extent Map entires"
exit 1
fi
cplogger -i 52 $scrname "$tname"
exit 0

View File

@ -1,45 +0,0 @@
#!/bin/bash
#
# $Id: test-004.sh 1538 2009-07-22 18:57:04Z dhill $
#
# Validates that FilesPerColumnPartition setting is not set lower than existing extents.
#
USER=`whoami 2>/dev/null`
# Source function library.
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
fi
. @ENGINE_SUPPORTDIR@/functions
scrname=`basename $0`
tname="validate-partition-size"
#Don't run on first boot
if firstboot; then
exit 0
fi
exit 0
cplogger -i 48 $scrname "$tname"
# Get the FilesPerColumnPartition setting from Columnstore.xml.
filesPer=$(getConfig ExtentMap FilesPerColumnPartition)
# Get the maximum segment number for all column files.
maxSeg=$(editem -i | awk -F '|' -v max=0 '{if($7>max)max=$7}END{print max+1}')
# Error and out if the maximum existing segment number is higher than the FilesPerColumnPartition setting.
if [ $maxSeg -gt $filesPer ]; then
cplogger -c 50 $scrname "$tname" "One or more tables were populated with FilesPerColumnPartition higher than the current setting."
exit 1
fi
cplogger -i 52 $scrname "$tname"
exit 0

View File

@ -1,7 +1,2 @@
add_subdirectory(alarmmanager)
add_subdirectory(columnstoreDB)
add_subdirectory(postConfigure)
add_subdirectory(serverMonitor)
add_subdirectory(columnstoreSupport)

View File

@ -1,17 +0,0 @@
include_directories( ${ENGINE_COMMON_INCLUDES} )
########### next target ###############
set(alarmmanager_LIB_SRCS alarmmanager.cpp alarm.cpp)
add_library(alarmmanager SHARED ${alarmmanager_LIB_SRCS})
add_dependencies(alarmmanager loggingcpp)
target_compile_options(alarmmanager PRIVATE -Wno-unused-result)
install(TARGETS alarmmanager DESTINATION ${ENGINE_LIBDIR} COMPONENT columnstore-engine)

View File

@ -1,229 +0,0 @@
/* Copyright (C) 2016 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/******************************************************************************************
* Author: Zhixuan Zhu
******************************************************************************************/
#include <cstring>
#include "alarm.h"
#include "liboamcpp.h"
using namespace std;
using namespace oam;
namespace alarmmanager
{
Alarm::Alarm()
{
// alarm receive time
Oam oam;
setTimestamp (oam.getCurrentTime());
time_t cal;
time (&cal);
setTimestampSeconds (cal);
}
Alarm::~Alarm()
{
}
void Alarm::setAlarmID (const uint16_t id)
{
alarmID = id;
}
void Alarm::setDesc (const string& d)
{
desc = d;
}
void Alarm::setComponentID (const string& id)
{
componentID = id;
}
void Alarm::setSeverity (const uint16_t s)
{
severity = s;
}
void Alarm::setState (const bool s)
{
state = s;
}
void Alarm::setCtnThreshold (const uint16_t ctn)
{
ctnThreshold = ctn;
}
void Alarm::setOccurrence (const uint16_t o)
{
occurrence = o;
}
void Alarm::setLastIssueTime (const uint32_t time)
{
lastIssueTime = time;
}
void Alarm::setPid (const uint16_t p)
{
pid = p;
}
void Alarm::setTid (const uint16_t t)
{
tid = t;
}
void Alarm::setTimestamp (const string& t)
{
timestamp = t;
}
void Alarm::setTimestampSeconds (const time_t& t)
{
timestampseconds = t;
}
void Alarm::setSname (const string& s)
{
sname = s;
}
void Alarm::setPname (const string& p)
{
pname = p;
}
istream& operator >>(istream& input, Alarm& alarm)
{
char buf[100] = {0};
alarm.setAlarmID (INVALID_ALARM_ID);
while (!input.eof() && strcmp (buf, "") == 0)
{
input.getline (buf, 100);
}
if (input.eof())
return input;
// Alarm ID
alarm.setAlarmID (atoi (buf));
// Severity
input.getline (buf, 100);
if (strstr (buf, "CRITICAL") != 0)
alarm.setSeverity (CRITICAL);
else if (strstr (buf, "MAJOR") != 0)
alarm.setSeverity (MAJOR);
else if (strstr (buf, "MINOR") != 0)
alarm.setSeverity (MINOR);
else if (strstr (buf, "WARNING") != 0)
alarm.setSeverity (WARNING);
else if (strstr (buf, "INFORMATIONAL") != 0)
alarm.setSeverity (INFORMATIONAL);
else
alarm.setSeverity (NO_SEVERITY);
// state
if (strstr (buf, "CLEARED") != 0)
alarm.setState (0);
else
alarm.setState (1);
// Desc
input.getline (buf, 100);
alarm.setDesc (buf);
// Timestamp
input.getline (buf, 100);
alarm.setTimestamp (buf);
// Timestamp Seconds
input.getline (buf, 100);
Oam oam;
alarm.setTimestampSeconds (atoi(buf));
// Reporting server name
input.getline (buf, 100);
alarm.setSname (buf);
// Reporting process name
input.getline (buf, 100);
alarm.setPname (buf);
// fault device name
input.getline (buf, 100);
alarm.setComponentID (buf);
input.ignore (100, '\n');
return input;
}
ostream& operator<< (ostream& output, const Alarm& alarm)
{
output << alarm.getAlarmID() << endl;
if (alarm.getState() == 0)
output << "CLEARED ";
switch (alarm.getSeverity())
{
case CRITICAL:
output << "CRITICAL ALARM" << endl;
break;
case MAJOR:
output << "MAJOR ALARM" << endl;
break;
case MINOR:
output << "MINOR ALARM" << endl;
break;
case WARNING:
output << "WARNING ALARM" << endl;
break;
case INFORMATIONAL:
output << "INFORMATIONAL ALARM" << endl;
break;
case NO_SEVERITY:
output << "NO_SEVERITY ALARM" << endl;
break;
}
output << alarm.getDesc() << endl;
output << alarm.getTimestamp() << endl;
output << alarm.getTimestampSeconds() << endl;
output << alarm.getSname() << endl;
output << alarm.getPname() << endl;
output << alarm.getComponentID() << endl;
output << endl;
return output;
}
} //namespace alarmmanager

View File

@ -1,172 +0,0 @@
/* Copyright (C) 2016 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/******************************************************************************************
* $Id: alarm.h 781 2013-01-21 14:12:44Z rdempsey $
*
* Author: Zhixuan Zhu
******************************************************************************************/
/**
* @file
*/
#ifndef CAL_ALARM_H
#define CAL_ALARM_H
#include <string>
#include <stdint.h>
#include "alarmglobal.h"
namespace alarmmanager
{
/** @brief Alarm class interface
*
*/
class Alarm
{
public:
/*
* @brief overloaded stream operator
*/
friend std::ostream& operator<< ( std::ostream&, const Alarm& );
friend std::istream& operator>> ( std::istream&, Alarm& );
/*
* @brief default ctor
*/
Alarm();
/*
* @brief dtor
*/
virtual ~Alarm();
/*
* @brief access methods
*/
inline uint16_t getAlarmID() const
{
return alarmID;
}
void setAlarmID (const uint16_t);
inline const std::string getDesc() const
{
return desc;
}
void setDesc (const std::string&);
inline const std::string getComponentID() const
{
return componentID;
}
void setComponentID (const std::string&);
inline uint16_t getSeverity() const
{
return severity;
}
void setSeverity (const uint16_t);
inline bool getState () const
{
return state;
}
void setState (const bool);
inline uint16_t getCtnThreshold() const
{
return ctnThreshold;
}
void setCtnThreshold (const uint16_t);
inline uint16_t getOccurrence() const
{
return occurrence;
}
void setOccurrence (const uint16_t);
inline const time_t& getReceiveTime () const
{
return receiveTime;
}
void setReceiveTime (const time_t);
inline uint32_t getLastIssueTime() const
{
return lastIssueTime;
}
void setLastIssueTime (const uint32_t);
inline uint16_t getPid () const
{
return pid;
}
void setPid (const uint16_t);
inline uint16_t getTid () const
{
return tid;
}
void setTid (const uint16_t);
inline const std::string getTimestamp () const
{
return timestamp;
}
void setTimestamp (const std::string&);
inline time_t getTimestampSeconds () const
{
return timestampseconds;
}
void setTimestampSeconds (const time_t&);
inline const std::string getSname () const
{
return sname;
}
void setSname (const std::string&);
inline const std::string getPname () const
{
return pname;
}
void setPname (const std::string&);
private:
uint16_t alarmID;
std::string desc;
std::string componentID;
uint16_t severity;
bool state; // true: set; false: clear
uint16_t ctnThreshold;
uint16_t occurrence;
time_t receiveTime;
uint32_t lastIssueTime;
uint16_t pid; // report process id
uint16_t tid; // report thread id
std::string sname; // report server name
std::string pname; // report process name
std::string timestamp; // receive time in date/time format
time_t timestampseconds; // receive time in seconds format
};
}
#endif

View File

@ -1,46 +0,0 @@
/* Copyright (C) 2016 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
#ifndef ALARMGLOBAL_H
#define ALARMGLOBAL_H
#ifdef __linux__
#include <sys/file.h>
#include <linux/unistd.h>
#endif
#include <string>
#include <stdint.h>
namespace alarmmanager
{
/** @brief constant define
*
*/
const int SET = 1;
const int CLEAR = 0;
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 bool ALARM_DEBUG = false;
const uint16_t INVALID_ALARM_ID = 0;
}
#endif

View File

@ -1,726 +0,0 @@
/* Copyright (C) 2016 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/******************************************************************************************
* Author: Zhixuan Zhu
******************************************************************************************/
#define ALARMMANAGER_DLLEXPORT
#include "alarmmanager.h"
#undef ALARMMANAGER_DLLEXPORT
#include <unistd.h>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iterator>
#include "alarmglobal.h"
#include "liboamcpp.h"
#include "installdir.h"
#include "messagequeue.h"
using namespace std;
using namespace oam;
using namespace messageqcpp;
using namespace logging;
const unsigned int CTN_INTERVAL = 30 * 60;
namespace alarmmanager
{
#ifdef __linux__
inline pid_t gettid(void)
{
return syscall(__NR_gettid);
}
#else
inline pid_t gettid(void)
{
return getpid();
}
#endif
/*****************************************************************************************
* @brief Constructor
*
* purpose:
*
*****************************************************************************************/
ALARMManager::ALARMManager()
{
Oam oam;
// Get Parent OAM Module Name
try
{
oam.getSystemConfig("ParentOAMModuleName", ALARMManager::parentOAMModuleName);
}
catch (...)
{
//Log event
LoggingID lid(11);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Failed to read Parent OAM Module Name");
msg.format(args);
ml.logErrorMessage(msg);
throw runtime_error ("Failed to read Parent OAM Module Name");
}
}
/*****************************************************************************************
* @brief Destructor
*
* purpose:
*
*****************************************************************************************/
ALARMManager::~ALARMManager()
{
}
/*****************************************************************************************
* @brief rewriteActiveLog
*
* purpose: Update Active Alarm file, called to remove Cleared alarm
*
*****************************************************************************************/
void rewriteActiveLog (const AlarmList& alarmList)
{
if (ALARM_DEBUG)
{
LoggingID lid(11);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("rewriteAlarmLog Called");
msg.format(args);
ml.logDebugMessage(msg);
}
// delete the old file
unlink (ACTIVE_ALARM_FILE.c_str());
// create new file
int fd = open(ACTIVE_ALARM_FILE.c_str(), O_RDWR | O_CREAT, 0664);
// Aquire an exclusive lock
if (flock(fd, LOCK_EX) == -1)
{
throw runtime_error ("Lock active alarm log file error");
}
ofstream activeAlarmFile (ACTIVE_ALARM_FILE.c_str());
AlarmList::const_iterator i;
for (i = alarmList.begin(); i != alarmList.end(); ++i)
{
activeAlarmFile << i->second;
}
activeAlarmFile.close();
// Release lock
if (flock(fd, LOCK_UN) == -1)
{
throw runtime_error ("Release lock active alarm log file error");
}
close(fd);
}
/*****************************************************************************************
* @brief logAlarm
*
* purpose: Log Alarm in Active Alarm or Historical Alarm file
*
*****************************************************************************************/
void logAlarm (const Alarm& calAlarm, const string& fileName)
{
if (ALARM_DEBUG)
{
LoggingID lid(11);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("logAlarm Called");
msg.format(args);
ml.logDebugMessage(msg);
}
int fd = open(fileName.c_str(), O_RDWR | O_CREAT, 0664);
ofstream AlarmFile (fileName.c_str(), ios::app);
// Aquire an exclusive lock
if (flock(fd, LOCK_EX) == -1)
{
throw runtime_error ("Lock file error: " + fileName);
}
AlarmFile << calAlarm;
AlarmFile.close();
// Release lock
if (flock(fd, LOCK_UN) == -1)
{
throw runtime_error ("Release lock file error: " + fileName);
}
close(fd);
}
/*****************************************************************************************
* @brief processAlarm
*
* purpose: Process Alarm by updating Active Alarm and Historical Alarm files
*
*****************************************************************************************/
void processAlarm(const Alarm& calAlarm)
{
bool logActiveFlag = (calAlarm.getState() == CLEAR ? false : true);
bool logHistFlag = true;
if (calAlarm.getState() == CLEAR )
logHistFlag = false;
// get active alarms
AlarmList alarmList;
ALARMManager sm;
sm.getActiveAlarm (alarmList);
if (ALARM_DEBUG)
{
LoggingID lid(11);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("processAlarm Called");
msg.format(args);
ml.logDebugMessage(msg);
}
AlarmList::iterator i;
for (i = alarmList.begin(); i != alarmList.end(); ++i)
{
// check if matching ID
if (calAlarm.getAlarmID() != (i->second).getAlarmID() )
{
continue;
}
// check if the same fault component on same server
if (calAlarm.getComponentID().compare((i->second).getComponentID()) == 0 &&
calAlarm.getSname().compare((i->second).getSname()) == 0)
{
// for set alarm, don't log
if (calAlarm.getState() == SET )
{
logActiveFlag = false;
logHistFlag = false;
break;
}
// for clear alarm, remove the set by rewritting the file
else if (calAlarm.getState() == CLEAR )
{
logActiveFlag = false;
logHistFlag = true;
//cout << "size before: " << alarmList.size();
alarmList.erase (i);
//cout << " size after: " << alarmList.size() << endl;
try
{
rewriteActiveLog (alarmList);
}
catch (runtime_error& e)
{
LoggingID lid(11);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("rewriteActiveLog error:");
args.add(e.what());
msg.format(args);
ml.logErrorMessage(msg);
}
break;
}
}
} // end of for loop
if (logActiveFlag)
{
try
{
logAlarm (calAlarm, ACTIVE_ALARM_FILE);
}
catch (runtime_error& e)
{
LoggingID lid(11);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("logAlarm error:");
args.add(e.what());
msg.format(args);
ml.logErrorMessage(msg);
}
}
if (logHistFlag)
{
// log historical alarm
try
{
logAlarm (calAlarm, ALARM_FILE);
}
catch (runtime_error& e)
{
LoggingID lid(11);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("logAlarm error:");
args.add(e.what());
msg.format(args);
ml.logErrorMessage(msg);
}
}
}
/*****************************************************************************************
* @brief configAlarm
*
* purpose: Get Config Data for Incoming alarm
*
*****************************************************************************************/
void configAlarm (Alarm& calAlarm)
{
int alarmID = calAlarm.getAlarmID();
Oam oam;
AlarmConfig alarmConfig;
if (ALARM_DEBUG)
{
LoggingID lid(11);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("configAlarm Called");
msg.format(args);
ml.logDebugMessage(msg);
}
try
{
oam.getAlarmConfig (alarmID, alarmConfig);
calAlarm.setDesc (alarmConfig.BriefDesc);
calAlarm.setSeverity (alarmConfig.Severity);
calAlarm.setCtnThreshold (alarmConfig.Threshold);
calAlarm.setOccurrence (alarmConfig.Occurrences);
calAlarm.setLastIssueTime (alarmConfig.LastIssueTime);
// check lastIssueTime to see if it's time to clear the counter
time_t now;
time (&now);
if ((now - calAlarm.getLastIssueTime()) >= CTN_INTERVAL)
{
// reset counter and set lastIssueTime
oam.setAlarmConfig (alarmID, "LastIssueTime", now);
oam.setAlarmConfig (alarmID, "Occurrences", 1);
}
else
{
// increment counter and check the ctnThreshold
calAlarm.setOccurrence (alarmConfig.Occurrences + 1);
oam.setAlarmConfig (alarmID, "Occurrences", calAlarm.getOccurrence());
// if counter over threshold and set alarm, stop processing.
if (calAlarm.getCtnThreshold() > 0
&& calAlarm.getOccurrence() >= calAlarm.getCtnThreshold()
&& calAlarm.getState() == SET)
{
if (ALARM_DEBUG)
{
LoggingID lid(11);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("counter over threshold and set alarm, stop processing.");
args.add("threshold:");
args.add(calAlarm.getCtnThreshold());
args.add("occurances:");
args.add(calAlarm.getOccurrence());
msg.format(args);
ml.logDebugMessage(msg);
}
return;
}
}
}
catch (runtime_error& e)
{
if (ALARM_DEBUG)
{
LoggingID lid(11);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("runtime error:");
args.add(e.what());
msg.format(args);
ml.logDebugMessage(msg);
}
throw;
}
// process alarm
processAlarm (calAlarm);
}
/*****************************************************************************************
* @brief sendAlarmReport API
*
* purpose: Send Alarm Report
*
*****************************************************************************************/
void ALARMManager::sendAlarmReport (const char* componentID, int alarmID, int state,
std::string repModuleName, std::string repProcessName)
{
#ifdef SKIP_ALARM
return;
#else
LoggingID lid(11);
MessageLog ml(lid);
Message msg;
Message::Args args;
//Log receiving of Alarm report
if (ALARM_DEBUG)
{
args.add("sendAlarmReport: alarm #");
args.add(alarmID);
args.add(", state: ");
args.add(state);
args.add(", component: ");
args.add(componentID);
msg.format(args);
ml.logDebugMessage(msg);
}
Oam oam;
// get current Module name
string ModuleName;
if ( repModuleName.empty())
{
oamModuleInfo_t st;
try
{
st = oam.getModuleInfo();
ModuleName = boost::get<0>(st);
}
catch (...)
{
ModuleName = "Unknown Reporting Module";
}
}
else
ModuleName = repModuleName;
// get pid, tid info
int pid = getpid();
int tid = gettid();
// get reporting Process Name
string processName;
if ( repProcessName.empty())
{
// get current process name
myProcessStatus_t t;
try
{
t = oam.getMyProcessStatus();
processName = boost::get<1>(t);
}
catch (...)
{
processName = "Unknown-Reporting-Process";
}
}
else
processName = repProcessName;
ByteStream msg1;
// setup message
msg1 << (ByteStream::byte) alarmID;
msg1 << (std::string) componentID;
msg1 << (ByteStream::byte) state;
msg1 << (std::string) ModuleName;
msg1 << (std::string) processName;
msg1 << (ByteStream::byte) pid;
msg1 << (ByteStream::byte) tid;
try
{
//send the msg to Process Manager
MessageQueueClient procmgr("ProcMgr_Alarm");
procmgr.write(msg1);
// shutdown connection
procmgr.shutdown();
}
catch (...)
{}
return;
#endif //SKIP_ALARM
}
/*****************************************************************************************
* @brief processAlarmReport API
*
* purpose: Process Alarm Report
*
*****************************************************************************************/
void ALARMManager::processAlarmReport (Alarm& calAlarm)
{
// Get alarm configuration
try
{
configAlarm (calAlarm);
}
catch (runtime_error& e)
{
LoggingID lid(11);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("configAlarm error:");
args.add(e.what());
msg.format(args);
ml.logErrorMessage(msg);
}
return;
}
/*****************************************************************************************
* @brief getActiveAlarm API
*
* purpose: Get List of Active Alarm from activealarm file
*
*****************************************************************************************/
void ALARMManager::getActiveAlarm(AlarmList& alarmList) const
{
//add-on to fileName with mount name if on non Parent Module
Oam oam;
string fileName = ACTIVE_ALARM_FILE;
int fd = open(fileName.c_str(), O_RDONLY);
if (fd == -1)
{
// file may being deleted temporarily by trapHandler
sleep (1);
fd = open(fileName.c_str(), O_RDONLY);
if (fd == -1)
{
// no active alarms, return
return;
}
}
ifstream activeAlarm (fileName.c_str(), ios::in);
// acquire read lock
if (flock(fd, LOCK_SH) == -1)
{
throw runtime_error ("Lock active alarm log file error");
}
Alarm alarm;
while (!activeAlarm.eof())
{
activeAlarm >> alarm;
if (alarm.getAlarmID() != INVALID_ALARM_ID)
//don't sort
// alarmList.insert (AlarmList::value_type(alarm.getAlarmID(), alarm));
alarmList.insert (AlarmList::value_type(INVALID_ALARM_ID, alarm));
}
activeAlarm.close();
// release lock
if (flock(fd, LOCK_UN) == -1)
{
throw runtime_error ("Release lock active alarm log file error");
}
close(fd);
if (ALARM_DEBUG)
{
AlarmList :: iterator i;
for (i = alarmList.begin(); i != alarmList.end(); ++i)
{
cout << i->second << endl;
}
}
return;
}
/*****************************************************************************************
* @brief getAlarm API
*
* purpose: Get List of Historical Alarms from alarm file
*
* date = MM/DD/YY format
*
*****************************************************************************************/
void ALARMManager::getAlarm(std::string date, AlarmList& alarmList) const
{
string alarmFile = startup::StartUp::tmpDir() + "/alarms";
//make 1 alarm log file made up of archive and current alarm.log
string cmd = "touch " + alarmFile;
(void)system(cmd.c_str());
cmd = "ls " + ALARM_ARCHIVE_FILE + " | grep 'alarm.log' > " + alarmFile;
(void)system(cmd.c_str());
string fileName = startup::StartUp::tmpDir() + "/alarmlogfiles";
ifstream oldFile (fileName.c_str());
if (oldFile)
{
char line[200];
string buf;
while (oldFile.getline(line, 200))
{
buf = line;
string cmd = "cat " + ALARM_ARCHIVE_FILE + "/" + buf + " >> " + alarmFile;
(void)system(cmd.c_str());
}
oldFile.close();
unlink (fileName.c_str());
}
cmd = "cat " + ALARM_FILE + " >> " + alarmFile;
(void)system(cmd.c_str());
int fd = open(alarmFile.c_str(), O_RDONLY);
if (fd == -1)
// doesn't exist yet, return
return;
ifstream hisAlarm (alarmFile.c_str(), ios::in);
// acquire read lock
if (flock(fd, LOCK_SH) == -1)
{
throw runtime_error ("Lock alarm log file error");
}
//get mm / dd / yy from incoming date
string mm = date.substr(0, 2);
string dd = date.substr(3, 2);
string yy = date.substr(6, 2);
Alarm alarm;
while (!hisAlarm.eof())
{
hisAlarm >> alarm;
if (alarm.getAlarmID() != INVALID_ALARM_ID)
{
time_t cal = alarm.getTimestampSeconds();
struct tm tm;
localtime_r(&cal, &tm);
char tmp[3];
strftime (tmp, 3, "%m", &tm);
string alarm_mm = tmp;
alarm_mm = alarm_mm.substr(0, 2);
strftime (tmp, 3, "%d", &tm);
string alarm_dd = tmp;
alarm_dd = alarm_dd.substr(0, 2);
strftime (tmp, 3, "%y", &tm);
string alarm_yy = tmp;
alarm_yy = alarm_yy.substr(0, 2);
if ( mm == alarm_mm && dd == alarm_dd && yy == alarm_yy )
//don't sort
// alarmList.insert (AlarmList::value_type(alarm.getAlarmID(), alarm));
alarmList.insert (AlarmList::value_type(INVALID_ALARM_ID, alarm));
}
}
hisAlarm.close();
unlink (alarmFile.c_str());
// release lock
if (flock(fd, LOCK_UN) == -1)
{
throw runtime_error ("Release lock active alarm log file error");
}
if (ALARM_DEBUG)
{
AlarmList :: iterator i;
for (i = alarmList.begin(); i != alarmList.end(); ++i)
{
cout << i->second << endl;
}
}
}
} //namespace alarmmanager
// vim:ts=4 sw=4:

View File

@ -1,125 +0,0 @@
/* Copyright (C) 2016 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/******************************************************************************************
* Author: Zhixuan Zhu
******************************************************************************************/
/**
* @file
*/
#ifndef ALARM_MANAGER_H
#define ALARM_MANAGER_H
#include <string>
#include <map>
#include "alarm.h"
#if defined(_MSC_VER) && defined(xxxALARMMANAGER_DLLEXPORT)
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
namespace alarmmanager
{
/** @brief type define
*
*/
typedef std::multimap<int, Alarm> AlarmList;
/** @brief constant define
*
*/
/** @brief ALARMManager class interface
*
*/
class ALARMManager
{
public:
/** @brief default ctor
*
*/
EXPORT ALARMManager();
/** @brief dtor
*
*/
EXPORT virtual ~ALARMManager();
/** @brief send an alarm
*
* @param componentID the component, hardware or software ID
* @param alarmID the alarm ID
* @param state set or clear
* @param repModuleName reported Module Name (used by non-realtime process)
* @param repProcessName reporting Process Name (used by non-realtime process)
*/
EXPORT void sendAlarmReport (const char* componentID,
const int alarmID,
const int state,
std::string repModuleName = "",
std::string repProcessName = "");
EXPORT void processAlarmReport (Alarm& calAlarm);
/** @brief return active alarm list
*
* @param AlarmList the alarm map reference to store alarms
*/
EXPORT void getActiveAlarm (AlarmList& ) const;
/** @brief return alarm list
*
* @param date date of alarms, "today" or date in YYYYMMDD
* @param AlarmList the alarm map reference to store alarms
*/
EXPORT void getAlarm (std::string date, AlarmList& ) const;
/** @brief get NMS address for trapd
*
* @param addr the reference to store addr
*/
private:
/** @brief copy ctor. keep private for now
*
*/
ALARMManager(const ALARMManager& rhs);
/** @brief assign op. keep private for now
*
*/
ALARMManager& operator=(const ALARMManager& rhs);
/**
* this is to avoid running create_trap_session more than once.
*/
static bool initFlag;
std::string parentOAMModuleName;
};
}
#undef EXPORT
#endif

View File

@ -1,124 +0,0 @@
/* Copyright (C) 2016 MariaDB Corporation.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
#include <cstring>
#include <cppunit/extensions/HelperMacros.h>
#include "alarmmanager.h"
#include "liboamcpp.h"
using namespace alarmmanager;
using namespace oam;
using namespace messageqcpp;
using namespace std;
class ALARMManagerTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( ALARMManagerTest );
CPPUNIT_TEST( test1 );
CPPUNIT_TEST( test2 );
//CPPUNIT_TEST( test3 ); // requires ProcMgr to be running
CPPUNIT_TEST_SUITE_END();
private:
public:
void setUp()
{
}
void tearDown()
{
}
void test1()
{
// set alarm
ALARMManager sm;
sm.sendAlarmReport("EC-DISK-1", 4, SET);
AlarmList activeAlarms;
sm.getActiveAlarm(activeAlarms);
//clear alarm
sm.sendAlarmReport("EC-DISK-1", 4, CLEAR);
sm.getActiveAlarm(activeAlarms);
}
void test2()
{
Alarm alarm;
alarm.setAlarmID (2);
alarm.setComponentID ("atlanta");
alarm.setSeverity (MAJOR);
alarm.setState (1);
cout << alarm << endl;
string a;
uint32_t b;
b = alarm.getCtnThreshold();
alarm.setCtnThreshold(b);
b = alarm.getOccurrence();
alarm.setOccurrence(b);
a = alarm.getTimestamp();
b = alarm.getLastIssueTime();
alarm.setLastIssueTime(b);
a = alarm.getSname();
alarm.setSname(a);
a = alarm.getPname();
alarm.setPname(a);
b = alarm.getTid();
alarm.setTid(b);
b = alarm.getPid();
alarm.setPid(b);
}
void test3()
{
ALARMManager sm;
string value;
sm.setSNMPConfig ("atlanta", SUB_AGENT, "DISK_CRITICAL", "2000000");
sm.getSNMPConfig ("atlanta", SUB_AGENT, "DISK_CRITICAL", value);
cout << "DISK: " << value << endl;
sm.setSNMPConfig ("atlanta", SUB_AGENT, "MEM_MAJOR", "333333");
sm.getSNMPConfig ("atlanta", SUB_AGENT, "MEM_MAJOR", value);
cout << "MEM " << value << endl;
sm.setSNMPConfig ("atlanta", SUB_AGENT, "SWAP_MINOR", "543216");
sm.getSNMPConfig ("atlanta", SUB_AGENT, "SWAP_MINOR", value);
cout << "SWAP " << value << endl;
sm.setNMSAddr ("10.100.3.141");
sm.getNMSAddr (value);
cout << "NMS address: " << value << endl;
}
};
CPPUNIT_TEST_SUITE_REGISTRATION( ALARMManagerTest );
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
int main( int argc, char** argv)
{
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest( registry.makeTest() );
bool wasSuccessful = runner.run( "", false );
return (wasSuccessful ? 0 : 1);
}

View File

@ -45,6 +45,8 @@
using namespace std;
using namespace oam;
using namespace config;
#include "calpontsystemcatalog.h"
using namespace execplan;
namespace
{
@ -67,6 +69,213 @@ void usage(char* prog)
}
}
/******************************************************************************************
* @brief DisplayLockedTables
*
* purpose: Show the details of all the locks in tableLocks
* Used when attempting to suspend or stop the
* database, but there are table locks.
*
******************************************************************************************/
void DisplayLockedTables(std::vector<BRM::TableLockInfo>& tableLocks, BRM::DBRM* pDBRM)
{
cout << "The following tables are locked:" << endl;
// Initial widths of columns to display. We pass thru the table
// and see if we need to grow any of these.
unsigned int lockIDColumnWidth = 6; // "LockID"
unsigned int tableNameColumnWidth = 12; // "Name"
unsigned int ownerColumnWidth = 7; // "Process"
unsigned int pidColumnWidth = 3; // "PID"
unsigned int sessionIDColumnWidth = 7; // "Session"
unsigned int createTimeColumnWidth = 12; // "CreationTime"
unsigned int dbrootColumnWidth = 7; // "DBRoots"
unsigned int stateColumnWidth = 9; // "State"
// Initialize System Catalog object used to get table name
boost::shared_ptr<execplan::CalpontSystemCatalog> systemCatalogPtr =
execplan::CalpontSystemCatalog::makeCalpontSystemCatalog(0);
std::string fullTblName;
const char* tableState;
// Make preliminary pass through the table locks in order to determine our
// output column widths based on the data. Min column widths are based on
// the width of the column heading (except for the 'state' column).
uint64_t maxLockID = 0;
uint32_t maxPID = 0;
int32_t maxSessionID = 0;
int32_t minSessionID = 0;
std::vector<std::string> createTimes;
std::vector<std::string> pms;
char cTimeBuffer[64];
execplan::CalpontSystemCatalog::TableName tblName;
for (unsigned idx = 0; idx < tableLocks.size(); idx++)
{
if (tableLocks[idx].id > maxLockID)
{
maxLockID = tableLocks[idx].id;
}
try
{
tblName = systemCatalogPtr->tableName(tableLocks[idx].tableOID);
}
catch (...)
{
tblName.schema.clear();
tblName.table.clear();
}
fullTblName = tblName.toString();
if (fullTblName.size() > tableNameColumnWidth)
{
tableNameColumnWidth = fullTblName.size();
}
if (tableLocks[idx].ownerName.length() > ownerColumnWidth)
{
ownerColumnWidth = tableLocks[idx].ownerName.length();
}
if (tableLocks[idx].ownerPID > maxPID)
{
maxPID = tableLocks[idx].ownerPID;
}
if (tableLocks[idx].ownerSessionID > maxSessionID)
{
maxSessionID = tableLocks[idx].ownerSessionID;
}
if (tableLocks[idx].ownerSessionID < minSessionID)
{
minSessionID = tableLocks[idx].ownerSessionID;
}
// Creation Time.
// While we're at it, we save the time string off into a vector
// so we can display it later without recalcing it.
struct tm timeTM;
localtime_r(&tableLocks[idx].creationTime, &timeTM);
ctime_r(&tableLocks[idx].creationTime, cTimeBuffer);
strftime(cTimeBuffer, 64, "%F %r:", &timeTM);
cTimeBuffer[strlen(cTimeBuffer) - 1] = '\0'; // strip trailing '\n'
std::string cTimeStr( cTimeBuffer );
if (cTimeStr.length() > createTimeColumnWidth)
{
createTimeColumnWidth = cTimeStr.length();
}
createTimes.push_back(cTimeStr);
}
tableNameColumnWidth += 1;
ownerColumnWidth += 1;
createTimeColumnWidth += 1;
std::ostringstream idString;
idString << maxLockID;
if (idString.str().length() > lockIDColumnWidth)
lockIDColumnWidth = idString.str().length();
lockIDColumnWidth += 1;
std::ostringstream pidString;
pidString << maxPID;
if (pidString.str().length() > pidColumnWidth)
pidColumnWidth = pidString.str().length();
pidColumnWidth += 1;
const std::string sessionNoneStr("BulkLoad");
std::ostringstream sessionString;
sessionString << maxSessionID;
if (sessionString.str().length() > sessionIDColumnWidth)
sessionIDColumnWidth = sessionString.str().length();
if ((minSessionID < 0) &&
(sessionNoneStr.length() > sessionIDColumnWidth))
sessionIDColumnWidth = sessionNoneStr.length();
sessionIDColumnWidth += 1;
// write the column headers before the first entry
cout.setf(ios::left, ios::adjustfield);
cout << setw(lockIDColumnWidth) << "LockID" <<
setw(tableNameColumnWidth) << "Name" <<
setw(ownerColumnWidth) << "Process" <<
setw(pidColumnWidth) << "PID" <<
setw(sessionIDColumnWidth) << "Session" <<
setw(createTimeColumnWidth) << "CreationTime" <<
setw(stateColumnWidth) << "State" <<
setw(dbrootColumnWidth) << "DBRoots" << endl;
for (unsigned idx = 0; idx < tableLocks.size(); idx++)
{
try
{
tblName = systemCatalogPtr->tableName(tableLocks[idx].tableOID);
}
catch (...)
{
tblName.schema.clear();
tblName.table.clear();
}
fullTblName = tblName.toString();
cout <<
setw(lockIDColumnWidth) << tableLocks[idx].id <<
setw(tableNameColumnWidth) << fullTblName <<
setw(ownerColumnWidth) << tableLocks[idx].ownerName <<
setw(pidColumnWidth) << tableLocks[idx].ownerPID;
// Log session ID, or "BulkLoad" if session is -1
if (tableLocks[idx].ownerSessionID < 0)
cout << setw(sessionIDColumnWidth) << sessionNoneStr;
else
cout << setw(sessionIDColumnWidth) <<
tableLocks[idx].ownerSessionID;
// Creation Time
cout << setw(createTimeColumnWidth) << createTimes[idx];
// Processor State
if (pDBRM && !pDBRM->checkOwner(tableLocks[idx].id))
{
tableState = "Abandoned";
}
else
{
tableState = ((tableLocks[idx].state == BRM::LOADING) ?
"LOADING" : "CLEANUP");
}
cout << setw(stateColumnWidth) << tableState;
// PM List
cout << setw(dbrootColumnWidth);
for (unsigned k = 0; k < tableLocks[idx].dbrootList.size(); k++)
{
if (k > 0)
cout << ',';
cout << tableLocks[idx].dbrootList[k];
}
cout << endl;
} // end of loop through table locks
}
int main(int argc, char** argv)
{
string command;
@ -104,7 +313,7 @@ int main(int argc, char** argv)
if (!tableLocks.empty())
{
oam.DisplayLockedTables(tableLocks, &dbrm);
DisplayLockedTables(tableLocks, &dbrm);
}
else
{

View File

@ -766,7 +766,7 @@ int main(int argc, char* argv[])
//check for mysql password set
string pwprompt = " ";
if (oam.checkLogStatus(logFile, "ERROR 1045") )
if (checkLogStatus(logFile, "ERROR 1045") )
{
cout << "NOTE: MariaDB Columnstore root user password is set" << endl;
@ -823,7 +823,7 @@ int main(int argc, char* argv[])
string cmd = columnstoreMysql + pwprompt + " -e 'status' > " + logFile + " 2>&1";
system(cmd.c_str());
if (oam.checkLogStatus(logFile, "ERROR 1045") )
if (checkLogStatus(logFile, "ERROR 1045") )
{
cout << "FAILED: Failed login using MariaDB Columnstore root user password '" << mysqlpw << "'" << endl;
FAILED = true;

View File

@ -20,7 +20,6 @@
using namespace std;
using namespace oam;
using namespace config;
using namespace alarmmanager;
void getSystemNetworkConfig(FILE * pOutputFile)
{
@ -116,7 +115,7 @@ void getSystemNetworkConfig(FILE * pOutputFile)
{
/* MCOL-1607. IPAddr may be a host name here b/c it is read straight
from the config file. */
string tmphost = oam.getIPAddress(pt1->IPAddr);
string tmphost = getIPAddress(pt1->IPAddr);
string ipAddr;
if (tmphost.empty())
ipAddr = pt1->IPAddr;
@ -304,7 +303,7 @@ void getStorageConfig(FILE * pOutputFile)
}
//get any unassigned DBRoots
DBRootConfigList undbrootlist;
/*DBRootConfigList undbrootlist;
try
{
@ -327,7 +326,7 @@ void getStorageConfig(FILE * pOutputFile)
}
fprintf(pOutputFile,"\n");
}
}*/
fprintf(pOutputFile,"\n");
@ -399,7 +398,7 @@ void getStorageConfig(FILE * pOutputFile)
}
// print un-assigned dbroots
DBRootConfigList::iterator pt1 = undbrootlist.begin();
/*DBRootConfigList::iterator pt1 = undbrootlist.begin();
for ( ; pt1 != undbrootlist.end() ; pt1++)
{
@ -422,7 +421,7 @@ void getStorageConfig(FILE * pOutputFile)
}
fprintf(pOutputFile,"Amazon EC2 Volume Name/Device Name/Amazon Device Name for DBRoot%u: %s, %s, %s",*pt1,volumeName.c_str(),deviceName.c_str(),amazondeviceName.c_str());
}
}*/
}
string DataRedundancyConfig;
@ -471,7 +470,7 @@ void getStorageConfig(FILE * pOutputFile)
try
{
string errmsg;
oam.glusterctl(oam::GLUSTER_WHOHAS, oam.itoa(*pt), pmList, errmsg);
//oam.glusterctl(oam::GLUSTER_WHOHAS, oam.itoa(*pt), pmList, errmsg);
}
catch (...)
{}
@ -505,14 +504,13 @@ void getStorageConfig(FILE * pOutputFile)
void getStorageStatus(FILE * pOutputFile)
{
SystemStatus systemstatus;
Oam oam;
fprintf(pOutputFile,"System External DBRoot Storage Statuses\n\n");
fprintf(pOutputFile,"Component Status Last Status Change\n");
fprintf(pOutputFile,"------------ -------------------------- ------------------------\n");
try
/*try
{
oam.getSystemStatus(systemstatus, false);
@ -541,7 +539,7 @@ void getStorageStatus(FILE * pOutputFile)
catch (exception& e)
{
cout << endl << "**** getSystemStatus Failed = " << e.what() << endl;
}
}*/
string DataRedundancyConfig;
int DataRedundancyCopies;
@ -555,21 +553,71 @@ void getStorageStatus(FILE * pOutputFile)
}
catch (...) {}
if ( DataRedundancyConfig == "y" )
{
string arg1 = "";
string arg2 = "";
string errmsg = "";
int ret = oam.glusterctl(oam::GLUSTER_STATUS, arg1, arg2, errmsg);
if ( ret == 0 )
{
cout << arg2 << endl;
}
else
{
cerr << "FAILURE: Status check error: " + errmsg << endl;
}
}
}
/********************************************************************
*
* checkLogStatus - Check for a phrase in a log file and return status
*
********************************************************************/
bool checkLogStatus(std::string fileName, std::string phrase )
{
ifstream file (fileName.c_str());
if (!file.is_open())
{
return false;
}
string buf;
while (getline(file, buf))
{
string::size_type pos = buf.find(phrase, 0);
if (pos != string::npos)
//found phrase
return true;
}
if (file.bad())
{
return false;
}
file.close();
return false;
}
/******************************************************************************************
* @brief Get Network IP Address for Host Name
*
* purpose: Get Network IP Address for Host Name
*
******************************************************************************************/
string getIPAddress(string hostName)
{
static uint32_t my_bind_addr;
struct hostent* ent;
string IPAddr = "";
Oam oam;
ent = gethostbyname(hostName.c_str());
if (ent != 0)
{
my_bind_addr = (uint32_t) ((in_addr*)ent->h_addr_list[0])->s_addr;
uint8_t split[4];
uint32_t ip = my_bind_addr;
split[0] = (ip & 0xff000000) >> 24;
split[1] = (ip & 0x00ff0000) >> 16;
split[2] = (ip & 0x0000ff00) >> 8;
split[3] = (ip & 0x000000ff);
IPAddr = oam.itoa(split[3]) + "." + oam.itoa(split[2]) + "." + oam.itoa(split[1]) + "." + oam.itoa(split[0]);
}
return IPAddr;
}

View File

@ -26,12 +26,12 @@
#include <sstream>
#include "configcpp.h"
#include "liboamcpp.h"
#include "alarmmanager.h"
void getSystemNetworkConfig(FILE * pOutputFile);
void getModuleTypeConfig(FILE * pOutputFile);
void getStorageConfig(FILE * pOutputFile);
void getStorageStatus(FILE * pOutputFile);
bool checkLogStatus(std::string filename, std::string phase);
std::string getIPAddress(std::string hostName);
#endif

View File

@ -1,412 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***************************************************************************
* $Id: hardwareMonitor.cpp 34 2006-09-29 21:13:54Z dhill $
*
* Author: David Hill
***************************************************************************/
#include "hardwareMonitor.h"
using namespace std;
using namespace oam;
using namespace alarmmanager;
using namespace logging;
/************************************************************************************************************
* @brief main function
*
* purpose: Get current hardware status and report alarms
*
* Parses file generated by the ipmitool
*
* pattern = what it is | value | units | status | value 1 | value 2 | value 3 | value 4 | value 5 | value 6
* data(0) = what it is
* data(1) = value
* data(2) = units
* data(3) = status
* data(4)-data(9) = barrier values
* data(4) - low non-recoverable, i.e. fatal
* data(5) - low critical
* data(6) - low warning
* data(7) - high warning
* data(8) - high critical
* data(9) - high non-recoverable, i.e. fatal
*
************************************************************************************************************/
int main (int argc, char** argv)
{
string data[10];
string SensorName;
float SensorValue;
string Units;
string SensorStatus;
float lowFatal;
float lowCritical;
float lowWarning;
float highWarning;
float highCritical;
float highFatal;
char* p;
// check for IPMI_SUPPORT FLAG passed in
if (argc > 1)
IPMI_SUPPORT = atoi(argv[1]);
// loop forever reading the hardware status
while (true)
{
if ( IPMI_SUPPORT == 0)
{
int returnCode = system("ipmitool sensor list > /tmp/harwareMonitor.txt");
if (returnCode)
{
// System error, Log this event
LoggingID lid;
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Error running ipmitool sensor list!!!");
msg.format(args);
ml.logWarningMessage(msg);
sleep(300);
continue;
}
}
// parse output file
ifstream File ("/tmp/harwareMonitor.txt");
if (!File)
{
// System error, Log this event
LoggingID lid;
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Error opening /tmp/harwareMonitor.txt!!!");
msg.format(args);
ml.logWarningMessage(msg);
sleep(300);
continue;
}
char line[200];
while (File.getline(line, 200))
{
// parse the line
int f = 0;
p = strtok(line, "|");
while (p)
{
data[f] = p;
data[f] = StripWhitespace(data[f]);
p = strtok (NULL, "|");
f++;
}
if ( f == 0 )
// nothing on this line, skip
continue;
SensorName = data[0];
SensorValue = atof(data[1].c_str());
Units = data[2];
SensorStatus = data[3];
lowFatal = atof(data[4].c_str());
lowCritical = atof(data[5].c_str());
lowWarning = atof(data[6].c_str());
highWarning = atof(data[7].c_str());
highCritical = atof(data[8].c_str());
highFatal = atof(data[9].c_str());
// check status and issue apporiate alarm if needed
if ( (SensorStatus != "ok") && (SensorStatus != "nr") && (SensorStatus != "na") )
{
// Status error, check for warning or critical levels
if ( SensorValue >= highFatal )
{
// issue critical alarm and send message to shutdown Server
sendAlarm(SensorName, HARDWARE_HIGH, SET, SensorValue);
sendMsgShutdownServer();
}
else if ( (SensorValue < highFatal) && (SensorValue >= highCritical) )
// issue major alarm
sendAlarm(SensorName, HARDWARE_MED, SET, SensorValue);
else if ( (SensorValue < highCritical ) && (SensorValue >= highWarning) )
// issue minor alarm
sendAlarm(SensorName, HARDWARE_LOW, SET, SensorValue);
else if ( (SensorValue <= lowWarning) && (SensorValue > lowCritical) )
// issue minor alarm
sendAlarm(SensorName, HARDWARE_LOW, SET, SensorValue);
else if ( (SensorValue <= lowCritical) && (SensorValue > lowFatal) )
// issue major alarm
sendAlarm(SensorName, HARDWARE_MED, SET, SensorValue);
else if ( SensorValue <= lowFatal )
{
// issue critical alarm and send message to shutdown Server
sendAlarm(SensorName, HARDWARE_HIGH, SET, SensorValue);
sendMsgShutdownServer();
}
else
// check if there are any active alarms that needs to be cleared
checkAlarm(SensorName);
}
else
// check if there are any active alarms that needs to be cleared
checkAlarm(SensorName);
} //end of parsing file while
File.close();
// sleep for 1 minute
sleep(60);
} //end of forever while loop
}
/******************************************************************************************
* @brief sendAlarm
*
* purpose: send a trap and log the process information
*
******************************************************************************************/
void sendAlarm(string alarmItem, ALARMS alarmID, int action, float sensorValue)
{
Oam oam;
//Log this event
LoggingID lid;
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add(alarmItem);
args.add(", sensor value out-of-range: ");
args.add(sensorValue);
// get current server name
string serverName;
oamServerInfo_t st;
try
{
st = oam.getServerInfo();
serverName = boost::get<0>(st);
}
catch (...)
{
serverName = "Unknown Server";
}
// check if there is an active alarm above the reporting theshold
// that needs to be cleared
checkAlarm(alarmItem, alarmID);
// check if Alarm is already active, don't resend
if ( !( oam.checkActiveAlarm(alarmID, serverName, alarmItem)) )
{
ALARMManager alarmMgr;
// send alarm
alarmMgr.sendAlarmReport(alarmItem.c_str(), alarmID, action);
args.add(", Alarm set: ");
args.add(alarmID);
}
// output log
msg.format(args);
ml.logWarningMessage(msg);
return;
}
/******************************************************************************************
* @brief checkAlarm
*
* purpose: check to see if an alarm(s) is set on device and clear if so
*
******************************************************************************************/
void checkAlarm(string alarmItem, ALARMS alarmID)
{
Oam oam;
// get current server name
string serverName;
oamServerInfo_t st;
try
{
st = oam.getServerInfo();
serverName = boost::get<0>(st);
}
catch (...)
{
serverName = "Unknown Server";
}
switch (alarmID)
{
case ALARM_NONE: // clear all alarms set if any found
if ( oam.checkActiveAlarm(HARDWARE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, HARDWARE_HIGH);
if ( oam.checkActiveAlarm(HARDWARE_MED, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, HARDWARE_MED);
if ( oam.checkActiveAlarm(HARDWARE_LOW, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, HARDWARE_LOW);
break;
case HARDWARE_LOW: // clear high and medium alarms set if any found
if ( oam.checkActiveAlarm(HARDWARE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, HARDWARE_HIGH);
if ( oam.checkActiveAlarm(HARDWARE_MED, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, HARDWARE_MED);
break;
case HARDWARE_MED: // clear high alarms set if any found
if ( oam.checkActiveAlarm(HARDWARE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, HARDWARE_HIGH);
break;
default: // none to clear
break;
} // end of switch
return;
}
/******************************************************************************************
* @brief clearAlarm
*
* purpose: clear Alarm that was previously set
*
******************************************************************************************/
void clearAlarm(string alarmItem, ALARMS alarmID)
{
ALARMManager alarmMgr;
alarmMgr.sendAlarmReport(alarmItem.c_str(), alarmID, CLEAR);
//Log this event
LoggingID lid;
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add(alarmItem);
args.add(" alarm #");
args.add(alarmID);
args.add("cleared");
msg.format(args);
ml.logWarningMessage(msg);
}
/******************************************************************************************
* @brief sendMsgShutdownServer
*
* purpose: send a Message to Shutdown server
*
******************************************************************************************/
void sendMsgShutdownServer()
{
Oam oam;
//Log this event
LoggingID lid;
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Fatal Hardware Alarm detected, Server being shutdown");
msg.format(args);
ml.logCriticalMessage(msg);
string serverName;
oamServerInfo_t st;
try
{
st = oam.getServerInfo();
serverName = boost::get<0>(st);
}
catch (...)
{
// o well, let's take out own action
if ( IPMI_SUPPORT == 0)
system("init 0");
}
try
{
oam.shutdownServer(serverName, FORCEFUL, ACK_NO);
}
catch (exception& e)
{
// o well, let's take out own action
if ( IPMI_SUPPORT == 0)
system("init 0");
}
}
/******************************************************************************************
* @brief StripWhitespace
*
* purpose: strip off whitespaces from a string
*
******************************************************************************************/
string StripWhitespace(string value)
{
for (;;)
{
string::size_type pos = value.find (' ', 0);
if (pos == string::npos)
// no more found
break;
// strip leading
if (pos == 0)
{
value = value.substr (pos + 1, 10000);
}
else
{
// strip trailing
value = value.substr (0, pos);
}
}
return value;
}

View File

@ -1,71 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***************************************************************************
* $Id: hardwareMonitor.h 34 2006-09-29 21:13:54Z dhill $
*
* Author: David Hill
***************************************************************************/
/**
* @file
*/
#ifndef HARDWARE_MONITOR_H
#define HARDWARE_MONITOR_H
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdlib>
#include <cerrno>
#include <exception>
#include <stdexcept>
#include "liboamcpp.h"
#include "messagelog.h"
#include "messageobj.h"
#include "loggingid.h"
#include "alarmmanager.h"
int IPMI_SUPPORT = 0; // 0 for supported
/**
* @brief send alarm
*/
void sendAlarm(std::string alarmItem, oam::ALARMS alarmID, int action, float sensorValue);
/**
* @brief check alarm
*/
void checkAlarm(std::string alarmItem, oam::ALARMS alarmID = oam::ALARM_NONE);
/**
* @brief clear alarm
*/
void clearAlarm(std::string alarmItem, oam::ALARMS alarmID);
/**
* @brief send msg to shutdown server
*/
void sendMsgShutdownServer();
/**
* @brief strip off whitespaces from a string
*/
std::string StripWhitespace(std::string value);
#endif

View File

@ -1,16 +0,0 @@
include_directories( ${ENGINE_COMMON_INCLUDES} )
########### next target ###############
set(mcsadmin_SRCS mcsadmin.cpp)
add_executable(mcsadmin ${mcsadmin_SRCS})
target_compile_options(mcsadmin PRIVATE -Wno-unused-result)
target_link_libraries(mcsadmin ${ENGINE_LDFLAGS} ${ENGINE_READLINE_LIBRARY} ncurses ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS} ${ENGINE_WRITE_LIBS})
install(TARGETS mcsadmin DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine)

File diff suppressed because it is too large Load Diff

View File

@ -1,135 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/******************************************************************************************
* $Id: MCSADMIN.h 3071 2013-04-04 18:45:53Z rdempsey $
*
******************************************************************************************/
/**
* @file
*/
#ifndef MCSADMIN_H
#define MCSADMIN_H
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <limits.h>
#include <sstream>
#include <exception>
#include <stdexcept>
#include <vector>
#include <stdio.h>
#include <ctype.h>
#include <sys/signal.h>
#include <sys/types.h>
#include <readline/history.h>
#include <time.h>
#include <pthread.h>
#include <errno.h>
#include "liboamcpp.h"
#include "configcpp.h"
#include "alarmmanager.h"
#include "alarmglobal.h"
#include "calpontsystemcatalog.h"
#include "brmtypes.h"
const int CmdSize = 80;
const int ArgNum = 10;
const int DescNumMax = 10;
const int cmdNum = 68;
const std::string DEFAULT_LOG_FILE = "/var/log/mariadb/columnstore/mcsadmin.log";
std::ofstream logFile;
/**
* write the command to the log file
*/
void writeLog(std::string command);
/** @brief location of the Process Configuration file
*/
const std::string ConsoleCmdsFile = "ConsoleCmds.xml";
void getFlags(const std::string* arguments, oam::GRACEFUL_FLAG& gracefulTemp, oam::ACK_FLAG& ackTemp, oam::CC_SUSPEND_ANSWER& suspendAnswer, bool& bNeedsConfirm, std::string* password = NULL);
int confirmPrompt(std::string warningCommand);
std::string dataPrompt(std::string promptCommand);
int processCommand(std::string*);
int ProcessSupportCommand(int CommandID, std::string arguments[]);
void printAlarmSummary();
void printCriticalAlarms();
void checkRepeat(std::string*, int);
void printSystemStatus();
void printProcessStatus(std::string port = "ProcStatusControl");
void printModuleCpuUsers(oam::TopProcessCpuUsers topprocesscpuusers);
void printModuleCpu(oam::ModuleCpu modulecpu);
void printModuleMemoryUsers(oam::TopProcessMemoryUsers topprocessmemoryusers);
void printModuleMemory(oam::ModuleMemory modulememory);
void printModuleDisk(oam::ModuleDisk moduledisk);
void printModuleResources(oam::TopProcessCpuUsers topprocesscpuusers, oam::ModuleCpu modulecpu, oam::TopProcessMemoryUsers topprocessmemoryusers, oam::ModuleMemory modulememory, oam::ModuleDisk moduledisk);
void printState(int state, std::string addInfo);
std::string getParentOAMModule();
bool checkForDisabledModules();
oam::CC_SUSPEND_ANSWER AskSuspendQuestion(int CmdID);
class to_lower
{
public:
char operator() (char c) const // notice the return type
{
return tolower(c);
}
};
/** @brief Hidden Support commands in lower-case
*/
const std::string supportCmds[] = { "helpsupport",
"stopprocess",
"startprocess",
"restartprocess",
"killpid",
"rebootsystem",
"rebootnode",
"stopdbrmprocess",
"startdbrmprocess",
"restartdbrmprocess",
"setsystemstartupstate",
"stopprimprocs",
"startprimprocs",
"restartprimprocs",
"stopexemgrs",
"startexemgrs",
"restartexemgrs",
"getprocessstatusstandby",
"distributeconfigfile",
"getpmdbrootconfig",
"getdbrootpmconfig",
"getsystemdbrootconfig",
"checkdbfunctional",
"getsystemreadflags",
"setsystemqueryready",
""
};
#endif

View File

@ -1,69 +0,0 @@
include_directories( ${ENGINE_COMMON_INCLUDES} )
########### next target ###############
set(postConfigure_SRCS postConfigure.cpp helpers.cpp)
add_executable(postConfigure ${postConfigure_SRCS})
target_compile_options(postConfigure PRIVATE -Wno-unused-result)
target_link_libraries(postConfigure ${ENGINE_LDFLAGS} ${ENGINE_READLINE_LIBRARY} ncurses ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS})
install(TARGETS postConfigure DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine)
########### next target ###############
set(installer_SRCS installer.cpp helpers.cpp)
add_executable(columnstore_installer ${installer_SRCS})
target_compile_options(columnstore_installer PRIVATE -Wno-unused-result)
target_link_libraries(columnstore_installer ${ENGINE_LDFLAGS} ${ENGINE_READLINE_LIBRARY} ncurses ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS})
install(TARGETS columnstore_installer DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine)
########### next target ###############
set(getMySQLpw_SRCS getMySQLpw.cpp)
add_executable(getMySQLpw ${getMySQLpw_SRCS})
target_link_libraries(getMySQLpw ${ENGINE_LDFLAGS} ${ENGINE_READLINE_LIBRARY} ncurses ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS})
install(TARGETS getMySQLpw DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine)
########### next target ###############
#set(amazonInstaller_SRCS amazonInstaller.cpp helpers.cpp)
#add_executable(amazonInstaller ${amazonInstaller_SRCS})
#target_link_libraries(amazonInstaller ${ENGINE_LDFLAGS} ${ENGINE_READLINE_LIBRARY} ncurses ${SNMP_LIBRARIES} ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS})
#install(TARGETS amazonInstaller DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-platform)
########### next target ###############
set(mycnfUpgrade_SRCS mycnfUpgrade.cpp)
add_executable(mycnfUpgrade ${mycnfUpgrade_SRCS})
target_compile_options(mycnfUpgrade PRIVATE -Wno-unused-result)
target_link_libraries(mycnfUpgrade ${ENGINE_LDFLAGS} ${ENGINE_READLINE_LIBRARY} ncurses ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS})
install(TARGETS mycnfUpgrade DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine)
########### next target ###############
install(PROGRAMS quick_installer_single_server.sh quick_installer_multi_server.sh
DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine)

View File

@ -1,275 +0,0 @@
# Doxyfile 1.4.1-KDevelop
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = postConfigure.kdevelop
PROJECT_NUMBER = $VERSION$
OUTPUT_DIRECTORY =
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class" \
"The $name widget" \
"The $name file" \
is \
provides \
specifies \
contains \
represents \
a \
an \
the
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH = /home/dhill/InfiniDB_MariaDB/oamapps/mcsadmin/
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
SUBGROUPING = YES
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = NO
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = YES
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = /home/dhill/InfiniDB_MariaDB/oamapps/postConfigure
FILE_PATTERNS = *.c \
*.cc \
*.cxx \
*.cpp \
*.c++ \
*.java \
*.ii \
*.ixx \
*.ipp \
*.i++ \
*.inl \
*.h \
*.hh \
*.hxx \
*.hpp \
*.h++ \
*.idl \
*.odl \
*.cs \
*.php \
*.php3 \
*.inc \
*.m \
*.mm \
*.dox \
*.C \
*.CC \
*.C++ \
*.II \
*.I++ \
*.H \
*.HH \
*.H++ \
*.CS \
*.PHP \
*.PHP3 \
*.M \
*.MM \
*.C \
*.H \
*.tlh \
*.diff \
*.patch \
*.moc \
*.xpm \
*.dox
RECURSIVE = yes
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = YES
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = yes
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE = postConfigure.tag
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = NO
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 1000
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO

View File

@ -1,128 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2017 MariaDB
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/******************************************************************************************
* $Id: getMySQLpw.cpp 64 2006-10-12 22:21:51Z dhill $
*
*
*
******************************************************************************************/
/**
* @file
*/
#include <unistd.h>
#include <iterator>
#include <numeric>
#include <deque>
#include <iostream>
#include <ostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <limits.h>
#include <sstream>
#include <exception>
#include <stdexcept>
#include <vector>
#include <stdio.h>
#include <ctype.h>
#include <netdb.h>
#include <sys/sysinfo.h>
#include <climits>
#include <cstring>
#include <glob.h>
#include "liboamcpp.h"
#include "installdir.h"
using namespace std;
using namespace oam;
int main(int argc, char* argv[])
{
Oam oam;
cout << oam::UnassignedName << endl;
exit (0);
string USER = "root";
char* p = getenv("USER");
if (p && *p)
USER = p;
string HOME = "/root";
p = getenv("HOME");
if (p && *p)
HOME = p;
string fileName = HOME + "/.my.cnf";
ifstream file (fileName.c_str());
if (!file)
{
cout << oam::UnassignedName << endl;
exit (1);
}
char line[400];
string buf;
while (file.getline(line, 400))
{
buf = line;
string::size_type pos = buf.find("root", 0);
if (pos != string::npos)
{
file.getline(line, 400);
buf = line;
pos = buf.find("password", 0);
if (pos != string::npos)
{
string::size_type pos1 = buf.find("=", pos);
if (pos1 != string::npos)
{
//password found
string password = buf.substr(pos1 + 2, 80);
cout << password << endl;
exit (0);
}
}
}
}
file.close();
cout << oam::UnassignedName << endl;
exit (1);
}
// vim:ts=4 sw=4:

View File

@ -1,844 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
#include <string>
#include <vector>
#include <unistd.h>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <stdio.h>
#include <readline.h>
#include "mcsconfig.h"
#include "configcpp.h"
using namespace config;
using namespace std;
#include "liboamcpp.h"
using namespace oam;
#include "helpers.h"
using namespace installer;
#include "installdir.h"
string pwprompt = " ";
string masterLogFile = oam::UnassignedName;
string masterLogPos = oam::UnassignedName;
string prompt;
const char* pcommand = 0;
bool noPrompting = false;
namespace installer
{
const char* callReadline(string prompt)
{
if ( !noPrompting )
{
const char* ret = readline(prompt.c_str());
if ( ret == 0 )
exit(1);
return ret;
}
else
{
cout << prompt << endl;
return "";
}
}
void callFree(const char* )
{
if ( !noPrompting )
free((void*)pcommand);
pcommand = 0;
}
bool waitForActive()
{
Oam oam;
try
{
oam.waitForActive();
return true;
}
catch (...)
{}
return false;
}
void dbrmDirCheck()
{
const string fname = std::string(MCSSYSCONFDIR) + "/columnstore/Columnstore.xml.rpmsave";
ifstream oldFile (fname.c_str());
if (!oldFile) return;
string SystemSection = "SystemConfig";
Config* sysConfig = Config::makeConfig();
Config* sysConfigPrev = Config::makeConfig(fname);
string dbrmroot = "";
string dbrmrootPrev = "";
try
{
dbrmroot = sysConfig->getConfig(SystemSection, "DBRMRoot");
dbrmrootPrev = sysConfigPrev->getConfig(SystemSection, "DBRMRoot");
}
catch (const std::exception& exc)
{
std::cerr << exc.what() << std::endl;
}
if ( dbrmrootPrev.empty() )
return;
if ( dbrmroot == dbrmrootPrev )
return;
string dbrmrootDir = "";
string dbrmrootPrevDir = "";
string::size_type pos = dbrmroot.find("/BRM_saves", 0);
if (pos != string::npos)
//get directory path
dbrmrootDir = dbrmroot.substr(0, pos);
else
{
return;
}
pos = dbrmrootPrev.find("/BRM_saves", 0);
if (pos != string::npos)
//get directory path
dbrmrootPrevDir = dbrmrootPrev.substr(0, pos);
else
{
return;
}
// return if prev directory doesn't exist
ifstream File (dbrmrootPrevDir.c_str());
if (!File)
return;
string dbrmrootCurrent = dbrmroot + "_current";
string dbrmrootCurrentPrev = dbrmrootPrev + "_current";
// return if prev current file doesn't exist
ifstream File1 (dbrmrootCurrentPrev.c_str());
if (!File1)
return;
string cmd;
// check if current file does't exist
// if not, copy prev files to current directory
ifstream File2 (dbrmrootCurrent.c_str());
if (!File2)
{
cout << endl << "===== DBRM Data File Directory Check =====" << endl << endl;
cmd = "/bin/cp -rpf " + dbrmrootPrevDir + "/* " + dbrmrootDir + "/.";
system(cmd.c_str());
//update the current file hardcoded path
ifstream oldFile (dbrmrootCurrent.c_str());
if (oldFile)
{
char line[200];
oldFile.getline(line, 200);
string dbrmFile = line;
string::size_type pos = dbrmFile.find("/BRM_saves", 0);
if (pos != string::npos)
dbrmFile = dbrmrootDir + dbrmFile.substr(pos, 80);
unlink (dbrmrootCurrent.c_str());
ofstream newFile (dbrmrootCurrent.c_str());
string cmd = "echo " + dbrmFile + " > " + dbrmrootCurrent;
system(cmd.c_str());
newFile.close();
}
cmd = "mv -f " + dbrmrootPrevDir + " " + dbrmrootPrevDir + ".old";
system(cmd.c_str());
cout << endl << "DBRM data files were copied from dbrm directory" << endl;
cout << dbrmrootPrevDir << " to current directory of " << dbrmrootDir << "." << endl;
cout << "The old dbrm directory was renamed to " << dbrmrootPrevDir << ".old ." << endl;
}
else
{
string start = "y";
cout << endl << "===== DBRM Data File Directory Check =====" << endl << endl;
cout << endl << "DBRM data files were found in " << dbrmrootPrevDir << endl;
cout << "and in the new location " << dbrmrootDir << "." << endl << endl;
cout << "Make sure that the correct set of files are in the new location." << endl;
cout << "Then rename the directory " << dbrmrootPrevDir << " to " << dbrmrootPrevDir << ".old" << endl;
cout << "If the files were copied from " << dbrmrootPrevDir << " to " << dbrmrootDir << endl;
cout << "you will need to edit the file BRM_saves_current to contain the current path of" << endl;
cout << dbrmrootDir << endl << endl;
cout << "Please reference the MariaDB Columnstore Installation Guide on Upgrade Installs for" << endl;
cout << "addition information, if needed." << endl << endl;
while (true)
{
string answer = "n";
prompt = "Enter 'y' when you are ready to continue > ";
pcommand = callReadline(prompt.c_str());
if (pcommand)
{
if (strlen(pcommand) > 0) answer = pcommand;
callFree(pcommand);
pcommand = 0;
}
if ( answer == "y" )
break;
else
cout << "Invalid Entry, please enter 'y' for yes" << endl;
}
}
cmd = "chmod 755 -R /var/lib/columnstore/data1/systemFiles/dbrm > /dev/null 2>&1";
system(cmd.c_str());
return;
}
void mysqlSetup()
{
Oam oam;
string cmd;
string tmpDir = startup::StartUp::tmpDir();
string mysqlpw = oam.getMySQLPassword();
string passwordOption = "";
if ( mysqlpw != oam::UnassignedName )
passwordOption = " --password=" + mysqlpw;
cmd = "post-mysqld-install " + passwordOption + " --tmpdir=" + tmpDir + " > " + tmpDir + "/post-mysqld-install.log 2>&1";
int rtnCode = system(cmd.c_str());
if (WEXITSTATUS(rtnCode) != 0)
{
cout << "Error running post-mysqld-install, check " << tmpDir << "/post-mysqld-install.log" << endl;
cout << "Exiting..." << endl;
exit (1);
}
else
cout << "post-mysqld-install Successfully Completed" << endl;
int user;
bool rootUser = true;
user = getuid();
if (user != 0)
rootUser = false;
string HOME = "/root";
if (!rootUser)
{
char* p = getenv("HOME");
if (p && *p)
HOME = p;
}
cmd = "post-mysql-install --tmpdir=" + tmpDir + " > " + tmpDir + "/post-mysql-install.log";
rtnCode = system(cmd.c_str());
if (WEXITSTATUS(rtnCode) == 2)
{
cout << "Error running post-mysql-install, password is needed. check " + HOME + "/.my.cnf " << endl;
cout << "Exiting..." << endl;
exit (1);
}
else if (WEXITSTATUS(rtnCode) == 1)
{
cout << "Error running post-mysql-install, " + tmpDir + "/post-mysql-install.log" << endl;
cout << "Exiting..." << endl;
exit (1);
}
else
cout << "post-mysql-install Successfully Completed" << endl;
return;
}
/******************************************************************************************
* @brief sendReplicationRequest
*
* purpose: send Upgrade Request Msg to all ACTIVE UMs
*
*
******************************************************************************************/
int sendReplicationRequest(int IserverTypeInstall, std::string password, bool pmwithum)
{
Oam oam;
SystemModuleTypeConfig systemmoduletypeconfig;
string tmpDir = startup::StartUp::tmpDir();
try
{
oam.getSystemConfig(systemmoduletypeconfig);
}
catch (const std::exception& exc)
{
std::cerr << exc.what() << std::endl;
}
//get Primary (Master) UM
string masterModule = oam::UnassignedName;
try
{
oam.getSystemConfig("PrimaryUMModuleName", masterModule);
}
catch (...)
{
masterModule = oam::UnassignedName;
}
if ( masterModule == oam::UnassignedName )
{
// use default setting
masterModule = "um1";
if ( IserverTypeInstall == oam::INSTALL_COMBINE_DM_UM_PM )
masterModule = "pm1";
}
int returnStatus = oam::API_SUCCESS;
bool masterDone = false;
for ( unsigned int i = 0; i < systemmoduletypeconfig.moduletypeconfig.size(); i++)
{
int moduleCount = systemmoduletypeconfig.moduletypeconfig[i].ModuleCount;
if ( moduleCount == 0)
continue;
string moduleType = systemmoduletypeconfig.moduletypeconfig[i].ModuleType;
DeviceNetworkList::iterator pt = systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.begin();
for ( ; pt != systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.end(); )
{
// we want to do master first
if ( ( (*pt).DeviceName == masterModule && !masterDone ) ||
( (*pt).DeviceName != masterModule && masterDone ) )
{
int opState = oam::ACTIVE;
bool degraded;
try
{
oam.getModuleStatus((*pt).DeviceName, opState, degraded);
if (opState == oam::ACTIVE ||
opState == oam::DEGRADED)
{
if ( (*pt).DeviceName == masterModule )
{
// set for Master MySQL DB distrubution to slaves
messageqcpp::ByteStream msg1;
messageqcpp::ByteStream::byte requestID = oam::MASTERDIST;
msg1 << requestID;
msg1 << password;
msg1 << "all"; // dist to all slave modules
returnStatus = sendMsgProcMon( (*pt).DeviceName, msg1, requestID, 600 );
if ( returnStatus != API_SUCCESS)
{
cout << endl << "ERROR: Error return in running the MariaDB ColumnStore Master DB Distribute, check " + tmpDir + "/master-dist*.logs on " << masterModule << endl;
return returnStatus;
}
// set for master repl request
messageqcpp::ByteStream msg;
requestID = oam::MASTERREP;
msg << requestID;
returnStatus = sendMsgProcMon( (*pt).DeviceName, msg, requestID, 30 );
if ( returnStatus != API_SUCCESS)
{
cout << endl << "ERROR: Error return in running the MariaDB ColumnStore Master replication, check " + tmpDir + "/master-rep*.logs on " << masterModule << endl;
return returnStatus;
}
masterDone = true;
pt = systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.begin();
}
else
{
// set for slave repl request
// don't do PMs unless PMwithUM flag is set
string moduleType = (*pt).DeviceName.substr(0, MAX_MODULE_TYPE_SIZE);
if ( ( moduleType == "pm" && !pmwithum ) &&
( IserverTypeInstall != oam::INSTALL_COMBINE_DM_UM_PM ) )
{
pt++;
continue;
}
messageqcpp::ByteStream msg;
messageqcpp::ByteStream::byte requestID = oam::SLAVEREP;
msg << requestID;
if ( masterLogFile == oam::UnassignedName ||
masterLogPos == oam::UnassignedName )
return API_FAILURE;
msg << masterLogFile;
msg << masterLogPos;
returnStatus = sendMsgProcMon( (*pt).DeviceName, msg, requestID, 30 );
if ( returnStatus != API_SUCCESS)
{
cout << endl << "ERROR: Error return in running the MariaDB ColumnStore Slave replication, check " + tmpDir + "/slave-rep*.logs on " << (*pt).DeviceName << endl;
return returnStatus;
}
pt++;
}
}
else
{
pt++;
}
}
catch (const std::exception& exc)
{
std::cerr << exc.what() << std::endl;
}
}
else
pt++;
}
}
return returnStatus;
}
/******************************************************************************************
* @brief sendMsgProcMon
*
* purpose: Sends a Msg to ProcMon
*
******************************************************************************************/
int sendMsgProcMon( std::string module, messageqcpp::ByteStream msg, int requestID, int timeout )
{
string msgPort = module + "_ProcessMonitor";
int returnStatus = API_FAILURE;
Oam oam;
// do a ping test to determine a quick failure
Config* sysConfig = Config::makeConfig();
string IPAddr = sysConfig->getConfig(msgPort, "IPAddr");
if ( IPAddr == oam::UnassignedIpAddr )
{
return returnStatus;
}
string cmdLine = "ping ";
string cmdOption = " -w 1 >> /dev/null";
string cmd = cmdLine + IPAddr + cmdOption;
if ( system(cmd.c_str()) != 0)
{
//ping failure
return returnStatus;
}
try
{
messageqcpp::MessageQueueClient mqRequest(msgPort);
mqRequest.write(msg);
if ( timeout > 0 )
{
// wait for response
messageqcpp::ByteStream::byte returnACK;
messageqcpp::ByteStream::byte returnRequestID;
messageqcpp::ByteStream::byte requestStatus;
messageqcpp::ByteStream receivedMSG;
struct timespec ts = { timeout, 0 };
// get current time in seconds
time_t startTimeSec;
time (&startTimeSec);
while (true)
{
try
{
receivedMSG = mqRequest.read(&ts);
}
catch (const std::exception& exc)
{
std::cerr << exc.what() << std::endl;
return returnStatus;
}
if (receivedMSG.length() > 0)
{
receivedMSG >> returnACK;
receivedMSG >> returnRequestID;
receivedMSG >> requestStatus;
if ( requestID == oam::MASTERREP )
{
receivedMSG >> masterLogFile;
receivedMSG >> masterLogPos;
}
if ( returnACK == oam::ACK && returnRequestID == requestID)
{
// ACK for this request
returnStatus = requestStatus;
break;
}
}
else
{
//api timeout occurred, check if retry should be done
// get current time in seconds
time_t endTimeSec;
time (&endTimeSec);
if ( timeout <= (endTimeSec - startTimeSec) )
{
break;
}
}
}
}
else
returnStatus = oam::API_SUCCESS;
mqRequest.shutdown();
}
catch (const std::exception& exc)
{
std::cerr << exc.what() << std::endl;
}
return returnStatus;
}
void checkFilesPerPartion(int DBRootCount, Config* sysConfig)
{
// check 'files per parition' with number of dbroots
// 'files per parition' need to be a multiple of dbroots
// update if no database already exist
// issue warning if database exist
Oam oam;
string SystemSection = "SystemConfig";
string dbRoot = "/var/lib/columnstore/data1";
try
{
dbRoot = sysConfig->getConfig(SystemSection, "DBRoot1");
}
catch (const std::exception& exc)
{
std::cerr << exc.what() << std::endl;
}
dbRoot = dbRoot + "/000.dir";
float FilesPerColumnPartition = 4;
try
{
string tmp = sysConfig->getConfig("ExtentMap", "FilesPerColumnPartition");
FilesPerColumnPartition = atoi(tmp.c_str());
}
catch (const std::exception& exc)
{
std::cerr << exc.what() << std::endl;
}
if ( fmod(FilesPerColumnPartition, (float) DBRootCount) != 0 )
{
ifstream oldFile (dbRoot.c_str());
if (!oldFile)
{
//set FilesPerColumnPartition == DBRootCount
sysConfig->setConfig("ExtentMap", "FilesPerColumnPartition", oam.itoa(DBRootCount));
cout << endl << "***************************************************************************" << endl;
cout << "NOTE: Mismatch between FilesPerColumnPartition (" + oam.itoa((int)FilesPerColumnPartition) + ") and number of DBRoots (" + oam.itoa(DBRootCount) + ")" << endl;
cout << " Setting FilesPerColumnPartition = number of DBRoots" << endl;
cout << "***************************************************************************" << endl;
}
else
{
cout << endl << "***************************************************************************" << endl;
cout << "WARNING: Mismatch between FilesPerColumnPartition (" + oam.itoa((int)FilesPerColumnPartition) + ") and number of DBRoots (" + oam.itoa(DBRootCount) + ")" << endl;
cout << " Database already exist, going forward could corrupt the database" << endl;
cout << " Please Contact Customer Support" << endl;
cout << "***************************************************************************" << endl;
exit (1);
}
}
return;
}
void checkMysqlPort(std::string& mysqlPort)
{
string tmpDir = startup::StartUp::tmpDir();
while (true)
{
string cmd = "netstat -na | grep -e :" + mysqlPort + "[[:space:]] | grep LISTEN > " + tmpDir + "/mysqlport";
system(cmd.c_str());
string fileName = tmpDir + "/mysqlport";
ifstream oldFile (fileName.c_str());
if (oldFile)
{
oldFile.seekg(0, std::ios::end);
int size = oldFile.tellg();
if (size != 0)
{
cout << endl << "The MariaDB ColumnStore port of '" + mysqlPort + "' is already in-use" << endl;
cout << "Please stop the process that is using port '" + mysqlPort + "'" << endl;
exit(1);
}
else
break;
}
else
break;
}
}
void checkSystemMySQLPort(std::string& mysqlPort, Config* sysConfig, std::string USER, std::string password, ChildModuleList childmodulelist, int IserverTypeInstall, bool pmwithum)
{
Oam oam;
bool inUse = false;
string tmpDir = startup::StartUp::tmpDir();
while (true)
{
string localnetstat = "netstat -na | grep -e :" + mysqlPort + "[[:space:]] | grep LISTEN > " + tmpDir + "/mysqlport";
string remotenetstat = "netstat -na | grep -e :" + mysqlPort + "[[:space:]] | grep LISTEN";
//first check local mysql, if needed
if ( ( IserverTypeInstall == oam::INSTALL_COMBINE_DM_UM_PM ) ||
( ( IserverTypeInstall != oam::INSTALL_COMBINE_DM_UM_PM ) && pmwithum ) )
{
system(localnetstat.c_str());
string fileName = tmpDir + "/mysqlport";
ifstream oldFile (fileName.c_str());
if (oldFile)
{
oldFile.seekg(0, std::ios::end);
int size = oldFile.tellg();
if ( size != 0 )
{
if ( noPrompting )
{
cout << endl << "The MariaDB ColumnStore port of '" + mysqlPort + "' is already in-use" << endl;
cout << "Either use the command line argument of 'port' to enter a different number" << endl;
cout << "or stop the process that is using port '" + mysqlPort + "'" << endl;
cout << "For No-prompt install, exiting" << endl;
exit(1);
}
else
inUse = true;
}
}
}
// if not inuse by local, go check remote servers
string inUseServer = "";
if ( !inUse )
{
ChildModuleList::iterator list1 = childmodulelist.begin();
for (; list1 != childmodulelist.end() ; list1++)
{
string remoteModuleName = (*list1).moduleName;
string remoteModuleIP = (*list1).moduleIP;
string remoteHostName = (*list1).hostName;
string remoteModuleType = remoteModuleName.substr(0, MAX_MODULE_TYPE_SIZE);
if ( remoteModuleType == "um" ||
(remoteModuleType == "pm" && IserverTypeInstall == oam::INSTALL_COMBINE_DM_UM_PM) ||
(remoteModuleType == "pm" && pmwithum) )
{
string cmd = "remote_command_verify.sh " + remoteModuleIP + " " + " " + USER + " " + password + " '" + remotenetstat + "' tcp error 5 0 > /dev/null 2>&1";
int rtnCode = system(cmd.c_str());
if (WEXITSTATUS(rtnCode) == 0)
{
if ( noPrompting )
{
cout << endl << "The MariaDB ColumnStore port of '" + mysqlPort + "' is already in-use on " << remoteModuleName << endl;
cout << "Either use the command line argument of 'port' to enter a different number" << endl;
cout << "or stop the process that is using port '" + mysqlPort + "'" << endl;
cout << "For No-prompt install, exiting" << endl;
cout << "exiting..." << endl;
exit(1);
}
else
{
inUseServer = remoteModuleName;
inUse = true;
break;
}
}
}
}
}
if ( inUse )
{
cout << endl << "The MariaDB ColumnStore port of '" + mysqlPort + "' is already in-use on " << inUseServer << endl;
cout << "Either enter a different port to use" << endl;
cout << "or stop the process that is using port '" + mysqlPort + "' and enter '" + mysqlPort + "' to continue" << endl;
while (true)
{
prompt = "Enter a port number > ";
pcommand = callReadline(prompt.c_str());
if (pcommand)
{
if (strlen(pcommand) > 0) mysqlPort = pcommand;
callFree(pcommand);
pcommand = 0;
}
if ( atoi(mysqlPort.c_str()) < 1000 || atoi(mysqlPort.c_str()) > 9999)
{
cout << " ERROR: Invalid MariaDB ColumnStore Port ID supplied, must be between 1000-9999" << endl;
}
else
break;
}
inUse = false;
}
else
{
cout << endl;
try
{
sysConfig->setConfig("Installation", "MySQLPort", mysqlPort);
}
catch (const std::exception& exc)
{
std::cerr << exc.what() << std::endl;
}
if ( !writeConfig(sysConfig) )
{
cout << "ERROR: Failed trying to update MariaDB Columnstore System Configuration file" << endl;
exit(1);
}
break;
}
}
// set mysql password
oam.changeMyCnf( "port", mysqlPort );
return;
}
/*
* writeConfig
*/
bool writeConfig( Config* sysConfig )
{
for ( int i = 0 ; i < 3 ; i++ )
{
try
{
sysConfig->write();
return true;
}
catch (const std::exception& exc)
{
std::cerr << exc.what() << std::endl;
}
}
return false;
}
}

View File

@ -1,52 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
#ifndef HELPERS_H__
#define HELPERS_H__
#include "liboamcpp.h"
namespace installer
{
typedef struct Child_Module_struct
{
std::string moduleName;
std::string moduleIP;
std::string hostName;
} ChildModule;
typedef std::vector<ChildModule> ChildModuleList;
extern bool waitForActive();
extern void dbrmDirCheck();
extern void mysqlSetup();
extern int sendMsgProcMon( std::string module, messageqcpp::ByteStream msg, int requestID, int timeout );
extern int sendReplicationRequest(int IserverTypeInstall, std::string password, bool pmwithum);
extern void checkFilesPerPartion(int DBRootCount, Config* sysConfig);
extern void checkMysqlPort(string& mysqlPort);
extern bool writeConfig(Config* sysConfig);
extern void checkSystemMySQLPort(std::string& mysqlPort, Config* sysConfig, std::string USER, std::string password, ChildModuleList childmodulelist, int IserverTypeInstall, bool pmwithum);
extern const char* callReadline(string prompt);
extern void callFree(const char* );
}
#endif

View File

@ -1,785 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/******************************************************************************************
* $Id: installer.cpp 64 2006-10-12 22:21:51Z dhill $
*
*
* List of files that will be updated during system install time on each server
* /etc/rc.local
*
******************************************************************************************/
/**
* @file
*/
#include <iterator>
#include <numeric>
#include <deque>
#include <iostream>
#include <ostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <limits.h>
#include <sstream>
#include <exception>
#include <stdexcept>
#include <vector>
#include "stdio.h"
#include "ctype.h"
#include <netdb.h>
#include <sys/sysinfo.h>
#include "mcsconfig.h"
#include "liboamcpp.h"
#include "configcpp.h"
using namespace std;
using namespace oam;
using namespace config;
#include "helpers.h"
using namespace installer;
#include "installdir.h"
typedef struct Module_struct
{
std::string moduleName;
std::string moduleIP;
std::string hostName;
} Module;
typedef std::vector<Module> ModuleList;
bool setOSFiles(string parentOAMModuleName, int serverTypeInstall);
bool makeBASH();
bool makeModuleFile(string moduleName, string parentOAMModuleName);
bool updateProcessConfig(int serverTypeInstall);
bool makeRClocal(string moduleName, int IserverTypeInstall);
bool uncommentCalpontXml( string entry);
extern string pwprompt;
string mysqlpw = " ";
bool rootUser = true;
string USER = "root";
int main(int argc, char* argv[])
{
string cmd;
Oam oam;
string parentOAMModuleIPAddr;
string parentOAMModuleHostName;
ModuleList childmodulelist;
ModuleList directormodulelist;
ModuleList usermodulelist;
ModuleList performancemodulelist;
Module childmodule;
string prompt;
string nodeps = "-h";
string installer_debug = "0";
string packageType = "rpm";
Config* sysConfig = Config::makeConfig();
string SystemSection = "SystemConfig";
string InstallSection = "Installation";
string DBRootStorageType;
if (argc < 12)
{
cerr << "installer: ERROR: not enough arguments" << endl;
exit(1);
}
string calpont_rpm1 = argv[1];
string calpont_rpm2 = argv[2];
string calpont_rpm3 = argv[3];
string mysql_rpm = argv[4];
string mysqld_rpm = argv[5];
string installType = argv[6];
string password = argv[7];
string reuseConfig = argv[8];
nodeps = argv[9];
mysqlpw = argv[10];
installer_debug = argv[11];
string numBlocksPctParam = "";
string totalUmMemoryParam = "";
if (argc >= 14) {
if (string(argv[12]) != "-") {
numBlocksPctParam = argv[12];
}
if (string(argv[13]) != "-") {
totalUmMemoryParam = argv[13];
}
}
ofstream file("/dev/null");
//save cout stream buffer
streambuf* strm_buffer = cout.rdbuf();
// redirect cout to /dev/null
cout.rdbuf(file.rdbuf());
cout << calpont_rpm1 << endl;
cout << calpont_rpm2 << endl;
cout << calpont_rpm3 << endl;
cout << mysql_rpm << endl;
cout << mysqld_rpm << endl;
cout << installType << endl;
cout << password << endl;
cout << reuseConfig << endl;
cout << nodeps << endl;
cout << mysqlpw << endl;
cout << installer_debug << endl;
if (!numBlocksPctParam.empty()) {
cout << numBlocksPctParam << endl;
}
if (!totalUmMemoryParam.empty()) {
cout << totalUmMemoryParam << endl;
}
// restore cout stream buffer
cout.rdbuf (strm_buffer);
if ( mysqlpw == "dummymysqlpw" )
mysqlpw = " ";
pwprompt = "--password=" + mysqlpw;
//check if root-user
int user;
user = getuid();
if (user != 0)
rootUser = false;
char* p = getenv("USER");
if (p && *p)
USER = p;
string tmpDir = startup::StartUp::tmpDir();
// setup to start on reboot, for non-root amazon installs
if ( !rootUser )
{
system("sed -i -e 's/#runuser/runuser/g' /etc/rc.d/rc.local >/dev/null 2>&1");
}
//copy Columnstore.xml.rpmsave if upgrade option is selected
if ( installType == "upgrade" )
{
cmd = "/bin/cp -f " + std::string(MCSSYSCONFDIR) + "/columnstore/Columnstore.xml " + std::string(MCSSYSCONFDIR) + "/columnstore/Columnstore.xml.new 2>&1";
system(cmd.c_str());
cmd = "/bin/cp -f " + std::string(MCSSYSCONFDIR) + "/columnstore/Columnstore.xml.rpmsave " + std::string(MCSSYSCONFDIR) + "/columnstore/Columnstore.xml 2>&1";
system(cmd.c_str());
}
string serverTypeInstall;
int IserverTypeInstall;
try
{
serverTypeInstall = sysConfig->getConfig(InstallSection, "ServerTypeInstall");
}
catch (...)
{
cout << "ERROR: Problem getting ServerTypeInstall from the MariaDB ColumnStore System Configuration file" << endl;
exit(1);
}
IserverTypeInstall = atoi(serverTypeInstall.c_str());
//get PPackage Type
try
{
packageType = sysConfig->getConfig(InstallSection, "EEPackageType");
}
catch (...)
{
cout << "ERROR: Problem getting EEPackageType" << endl;
exit(1);
}
//get Parent OAM Module Name and setup of it's Custom OS files
string parentOAMModuleName;
try
{
parentOAMModuleName = sysConfig->getConfig(SystemSection, "ParentOAMModuleName");
if ( parentOAMModuleName == oam::UnassignedName )
{
cout << "ERROR: Parent OAM Module Name is unassigned" << endl;
exit(1);
}
}
catch (...)
{
cout << "ERROR: Problem getting Parent OAM Module Name" << endl;
exit(1);
}
if ( installType == "initial" )
{
//cleanup/create /local/etc directories
cmd = "rm -rf /var/lib/columnstore/local/etc > /dev/null 2>&1";
system(cmd.c_str());
cmd = "mkdir /var/lib/columnstore/local/etc > /dev/null 2>&1";
system(cmd.c_str());
//create associated /local/etc directory for parentOAMModuleName
cmd = "mkdir /var/lib/columnstore/local/etc/" + parentOAMModuleName + " > /dev/null 2>&1";
system(cmd.c_str());
}
//Get list of configured system modules
SystemModuleTypeConfig sysModuleTypeConfig;
try
{
oam.getSystemConfig(sysModuleTypeConfig);
}
catch (...)
{
cout << "ERROR: Problem reading the MariaDB ColumnStore System Configuration file" << endl;
exit(1);
}
string ModuleSection = "SystemModuleConfig";
//get OAM Parent Module IP addresses and Host Name
for ( unsigned int i = 0 ; i < sysModuleTypeConfig.moduletypeconfig.size(); i++)
{
DeviceNetworkList::iterator listPT = sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.begin();
for ( ; listPT != sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.end() ; listPT++)
{
HostConfigList::iterator pt1 = (*listPT).hostConfigList.begin();
if ( (*listPT).DeviceName == parentOAMModuleName )
{
parentOAMModuleIPAddr = (*pt1).IPAddr;
parentOAMModuleHostName = (*pt1).HostName;
break;
}
}
}
for ( unsigned int i = 0 ; i < sysModuleTypeConfig.moduletypeconfig.size(); i++)
{
string moduleType = sysModuleTypeConfig.moduletypeconfig[i].ModuleType;
int moduleCount = sysModuleTypeConfig.moduletypeconfig[i].ModuleCount;
if ( moduleCount == 0 )
//no modules equipped for this Module Type, skip
continue;
//get IP addresses and Host Names
DeviceNetworkList::iterator listPT = sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.begin();
for ( ; listPT != sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.end() ; listPT++)
{
string moduleName = (*listPT).DeviceName;
HostConfigList::iterator pt1 = (*listPT).hostConfigList.begin();
string moduleIPAddr = (*pt1).IPAddr;
string moduleHostName = (*pt1).HostName;
//save module info
childmodule.moduleName = moduleName;
childmodule.moduleIP = moduleIPAddr;
childmodule.hostName = moduleHostName;
if ( moduleName != parentOAMModuleName)
{
childmodulelist.push_back(childmodule);
}
if ( moduleType == "dm")
directormodulelist.push_back(childmodule);
if ( moduleType == "um")
usermodulelist.push_back(childmodule);
if ( moduleType == "pm")
performancemodulelist.push_back(childmodule);
if ( installType == "initial" )
{
//create associated /local/etc directory for module
cmd = "mkdir /var/lib/columnstore/local/etc/" + moduleName + " > /dev/null 2>&1";
system(cmd.c_str());
}
}
} //end of i for loop
if ( installType != "uninstall" )
{
//setup rc.local file in local parent module
if ( !makeRClocal(parentOAMModuleName, IserverTypeInstall) )
cout << "makeRClocal error" << endl;
//create associated /local/etc directory for module
// generate module
ModuleList::iterator list1 = directormodulelist.begin();
for (; list1 != directormodulelist.end() ; list1++)
{
cmd = "mkdir /var/lib/columnstore/local/etc/" + (*list1).moduleName + " > /dev/null 2>&1";
system(cmd.c_str());
//make module file in /local/etc/"modulename"
if ( !makeModuleFile((*list1).moduleName, parentOAMModuleName) )
cout << "makeModuleFile error" << endl;
//setup rc.local file in module tmp dir
if ( !makeRClocal((*list1).moduleName, IserverTypeInstall) )
cout << "makeRClocal error" << endl;
}
list1 = usermodulelist.begin();
for (; list1 != usermodulelist.end() ; list1++)
{
cmd = "mkdir /var/lib/columnstore/local/etc/" + (*list1).moduleName + " > /dev/null 2>&1";
system(cmd.c_str());
//make module file in /local/etc/"modulename"
if ( !makeModuleFile((*list1).moduleName, parentOAMModuleName) )
cout << "makeModuleFile error" << endl;
//setup rc.local file in module tmp dir
if ( !makeRClocal((*list1).moduleName, IserverTypeInstall) )
cout << "makeRClocal error" << endl;
}
list1 = performancemodulelist.begin();
for (; list1 != performancemodulelist.end() ; list1++)
{
cmd = "mkdir /var/lib/columnstore/local/etc/" + (*list1).moduleName + " > /dev/null 2>&1";
system(cmd.c_str());
//make module file in /local/etc/"modulename"
if ( !makeModuleFile((*list1).moduleName, parentOAMModuleName) )
cout << "makeModuleFile error" << endl;
//setup rc.local file in module tmp dir
if ( !makeRClocal((*list1).moduleName, IserverTypeInstall) )
cout << "makeRClocal error" << endl;
}
}
if ( installType == "initial" )
{
//setup local OS Files
if ( !setOSFiles(parentOAMModuleName, IserverTypeInstall) )
{
cout << "ERROR: setOSFiles error" << endl;
cout << " IMPORTANT: Once issue has been resolved, rerun postConfigure" << endl << endl;
exit(1);
}
cmd = "chmod 755 -R /var/lib/columnstore/data1/systemFiles/dbrm > /dev/null 2>&1";
system(cmd.c_str());
}
//
// perform single-server install from postConfigure
//
//run the mysql / mysqld setup scripts
cout << endl << "Running the MariaDB ColumnStore setup scripts" << endl << endl;
// call the mysql setup scripts
mysqlSetup();
sleep(5);
exit(0);
}
/*
* Setup OS Files by appending the Calpont versions
*/
// /etc OS Files to be updated
string files[] =
{
" "
};
bool setOSFiles(string parentOAMModuleName, int serverTypeInstall)
{
string cmd;
bool allfound = true;
//update /etc files
for ( int i = 0;; ++i)
{
if ( files[i] == " ")
//end of list
break;
string fileName = "/etc/" + files[i];
//make a backup copy before changing
cmd = "rm -f " + fileName + ".columnstoreSave";
system(cmd.c_str());
cmd = "cp " + fileName + " " + fileName + ".columnstoreSave > /dev/null 2>&1";
system(cmd.c_str());
cmd = "cat /var/lib/columnstore/local/etc/" + parentOAMModuleName + "/" + files[i] + ".calpont >> " + fileName;
if (geteuid() == 0) system(cmd.c_str());
cmd = "rm -f /var/lib/columnstore/local/ " + files[i] + "*.calpont > /dev/null 2>&1";
system(cmd.c_str());
cmd = "cp /var/lib/columnstore/local/etc/" + parentOAMModuleName + "/" + files[i] + ".calpont /var/lib/columnstore/local/. > /dev/null 2>&1";
system(cmd.c_str());
}
return allfound;
}
/*
* Create a module file
*/
bool makeModuleFile(string moduleName, string parentOAMModuleName)
{
string cmd;
string fileName;
if ( moduleName == parentOAMModuleName )
fileName = "/var/lib/columnstore/local/module";
else
fileName = "/var/lib/columnstore/local/etc/" + moduleName + "/module";
unlink (fileName.c_str());
ofstream newFile (fileName.c_str());
cmd = "echo " + moduleName + " > " + fileName;
system(cmd.c_str());
newFile.close();
return true;
}
/*
* Update ProcessConfig.xml file for a single server configuration
* Change the 'um' and 'pm' to 'dm'
*/
bool updateProcessConfig(int serverTypeInstall)
{
vector <string> oldModule;
string newModule;
string cmd;
switch ( serverTypeInstall )
{
case (oam::INSTALL_COMBINE_DM_UM_PM):
{
newModule = ">pm";
oldModule.push_back(">um");
oldModule.push_back(">pm");
break;
}
case (oam::INSTALL_COMBINE_DM_UM):
{
newModule = ">um";
oldModule.push_back(">dm");
break;
}
case (oam::INSTALL_COMBINE_PM_UM):
{
newModule = ">pm";
oldModule.push_back(">um");
break;
}
}
string fileName = std::string(MCSSYSCONFDIR) + "/columnstore/ProcessConfig.xml";
//Save a copy of the original version
cmd = "/bin/cp -f " + fileName + " " + fileName + ".columnstoreSave > /dev/null 2>&1";
system(cmd.c_str());
ifstream oldFile (fileName.c_str());
if (!oldFile) return false;
vector <string> lines;
char line[200];
string buf;
string newLine;
string newLine1;
while (oldFile.getline(line, 200))
{
buf = line;
newLine = line;
std::vector<std::string>::iterator pt1 = oldModule.begin();
for ( ; pt1 != oldModule.end() ; pt1++)
{
int start = 0;
while (true)
{
string::size_type pos = buf.find(*pt1, start);
if (pos != string::npos)
{
newLine = buf.substr(0, pos);
newLine.append(newModule);
newLine1 = buf.substr(pos + 3, 200);
newLine.append(newLine1);
start = pos + 3;
}
else
{
buf = newLine;
start = 0;
break;
}
}
}
//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<string>(newFile, "\n"));
newFile.close();
close(fd);
return true;
}
/*
* Make makeRClocal to set mount scheduler
*/
bool makeRClocal(string moduleName, int IserverTypeInstall)
{
return true;
string moduleType = moduleName.substr(0, MAX_MODULE_TYPE_SIZE);
vector <string> lines;
string mount1;
string mount2
;
switch ( IserverTypeInstall )
{
case (oam::INSTALL_NORMAL): // normal
{
if ( moduleType == "um" )
mount1 = "/mnt\\/tmp/";
else if ( moduleType == "pm" )
mount1 = "/mariadb/columnstore\\/data/";
else
return true;
break;
}
case (oam::INSTALL_COMBINE_DM_UM_PM): // combined #1 - dm/um/pm
{
if ( moduleType == "pm" )
{
mount1 = "/mnt\\/tmp/";
mount2 = "/mariadb/columnstore\\/data/";
}
else
return true;
break;
}
case (oam::INSTALL_COMBINE_DM_UM): // combined #2 dm/um on a same server
{
if ( moduleType == "um" )
mount1 = "/mnt\\/tmp/";
else if ( moduleType == "pm" )
mount1 = "/mariadb/columnstore\\/data/";
else
return true;
break;
}
case (oam::INSTALL_COMBINE_PM_UM): // combined #3 um/pm on a same server
{
if ( moduleType == "pm" )
{
mount1 = "/mnt\\/tmp/";
mount2 = "/mariadb/columnstore\\/data/";
}
else
return true;
break;
}
}
if ( !mount1.empty() )
{
string line1 = "for scsi_dev in `mount | awk '" + mount1 + " {print $1}' | awk -F/ '{print $3}' | sed 's/[0-9]*$//'`; do";
string line2 = " echo deadline > /sys/block/$scsi_dev/queue/scheduler";
string line3 = "done";
lines.push_back(line1);
lines.push_back(line2);
lines.push_back(line3);
}
else
{
if ( !mount2.empty() )
{
string line1 = "for scsi_dev in `mount | awk '" + mount2 + " {print $1}' | awk -F/ '{print $3}' | sed 's/[0-9]*$//'`; do";
string line2 = " echo deadline > /sys/block/$scsi_dev/queue/scheduler";
string line3 = "done";
lines.push_back(line1);
lines.push_back(line2);
lines.push_back(line3);
}
}
if ( lines.begin() == lines.end())
return true;
string RCfileName = "/etc/rc.d/rc.local";
std::ofstream file;
file.open(RCfileName.c_str(), std::ios::out | std::ios::app);
if (file.fail())
{
RCfileName = "/etc/rc.local";
file.open(RCfileName.c_str(), std::ios::out | std::ios::app);
if (file.fail())
return true;
}
file.exceptions(file.exceptions() | std::ios::failbit | std::ifstream::badbit);
copy(lines.begin(), lines.end(), ostream_iterator<string>(file, "\n"));
file.close();
return true;
}
/*
* Uncomment entry in Columnstore.xml
*/
bool uncommentCalpontXml( string entry)
{
string fileName = std::string(MCSSYSCONFDIR) + "/columnstore/Columnstore.xml";
ifstream oldFile (fileName.c_str());
if (!oldFile) return true;
vector <string> lines;
char line[200];
string buf;
string newLine;
string firstComment = "<!--";
string lastComment = "-->";
while (oldFile.getline(line, 200))
{
buf = line;
string::size_type pos = buf.find(entry, 0);
if (pos != string::npos)
{
pos = buf.find(firstComment, 0);
if (pos == string::npos)
{
return true;
}
else
{
buf = buf.substr(pos + 4, 80);
pos = buf.find(lastComment, 0);
if (pos == string::npos)
{
return true;
}
else
{
buf = buf.substr(0, pos);
}
}
}
//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<string>(newFile, "\n"));
newFile.close();
close(fd);
return true;
}
// vim:ts=4 sw=4:

View File

@ -1,287 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/******************************************************************************************
* $Id: mycnfUpgrade.cpp 64 2006-10-12 22:21:51Z dhill $
*
*
*
******************************************************************************************/
/**
* @file
*/
#include <unistd.h>
#include <iterator>
#include <numeric>
#include <deque>
#include <iostream>
#include <ostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <limits.h>
#include <sstream>
#include <exception>
#include <stdexcept>
#include <vector>
#include <stdio.h>
#include <ctype.h>
#include <netdb.h>
#include <sys/sysinfo.h>
#include <climits>
#include <cstring>
#include <glob.h>
#include <boost/regex.hpp>
#include "liboamcpp.h"
#include "installdir.h"
#include "mcsconfig.h"
using namespace std;
using namespace oam;
/* MCOL-1844. On an upgrade, the user may have customized options in their old
* myCnf-include-args.text file. Merge it with the packaged version, and then process as we
* have before.
*/
string rtrim(const string &in) {
string::const_reverse_iterator rbegin = in.rbegin();
while (rbegin != in.rend() && isspace(*rbegin))
++rbegin;
return string(in.begin(), rbegin.base());
}
void mergeMycnfIncludeArgs()
{
string userArgsFilename = std::string(MCSSUPPORTDIR) + "/myCnf-include-args.text.rpmsave";
string packagedArgsFilename = std::string(MCSSUPPORTDIR) + "/myCnf-include-args.text";
ifstream userArgs(userArgsFilename.c_str());
fstream packagedArgs(packagedArgsFilename.c_str(), ios::in);
if (!userArgs || !packagedArgs)
return;
// de-dup the args and comments in both files
set<string> argMerger;
set<string> comments;
string line;
while (getline(packagedArgs, line)) {
line = rtrim(line);
if (line[0] == '#')
comments.insert(line);
else if (line.size() > 0)
argMerger.insert(line);
}
while (getline(userArgs, line)) {
line = rtrim(line);
if (line[0] == '#')
comments.insert(line);
else if (line.size() > 0)
argMerger.insert(line);
}
userArgs.close();
packagedArgs.close();
// write the merged version, comments first. They'll get ordered
// alphabetically but, meh.
packagedArgs.open(packagedArgsFilename.c_str(), ios::out | ios::trunc);
for (set<string>::iterator it = comments.begin(); it != comments.end(); it++)
packagedArgs << *it << endl;
for (set<string>::iterator it = argMerger.begin(); it != argMerger.end(); it++)
packagedArgs << *it << endl;
packagedArgs.close();
}
int main(int argc, char* argv[])
{
Oam oam;
//check for port argument
string mysqlPort;
if (argc > 1)
{
mysqlPort = argv[1];
// set mysql password
oam.changeMyCnf( "port", mysqlPort );
exit (0);
}
//my.cnf file
string mycnfFile = std::string(MCSMYCNFDIR) + "/columnstore.cnf";
ifstream mycnffile (mycnfFile.c_str());
if (!mycnffile)
{
cerr << "mycnfUpgrade - columnstore.cnf file not found: " << mycnfFile << endl;
exit (1);
}
//my.cnf.rpmsave file
string mycnfsaveFile = std::string(MCSMYCNFDIR) + "/columnstore.cnf.rpmsave";
ifstream mycnfsavefile (mycnfsaveFile.c_str());
if (!mycnfsavefile)
{
cerr << "mycnfUpgrade - columnstore.cnf.rpmsave file not found: " << mycnfsaveFile << endl;
exit (1);
}
// MCOL-1844. The user may have added options to their myCnf-include-args file. Merge
// myCnf-include-args.text with myCnf-include-args.text.rpmsave, save in myCnf-include-args.text
mergeMycnfIncludeArgs();
//include arguments file
string includeFile = std::string(MCSSUPPORTDIR) + "/myCnf-include-args.text";
ifstream includefile (includeFile.c_str());
if (!includefile)
{
cerr << "mycnfUpgrade - columnstore.cnf include argument file not found: " << includeFile << endl;
exit (1);
}
//exclude arguments file
string excludeFile = std::string(MCSSUPPORTDIR) + "/myCnf-exclude-args.text";
ifstream excludefile (excludeFile.c_str());
if (!excludefile)
{
cerr << "mycnfUpgrade - columnstore.cnf exclude argument file not found: " << endl;
exit (1);
}
//go though include list
char line[200];
string includeArg;
while (includefile.getline(line, 200))
{
includeArg = line;
boost::regex icludeArgRegEx("^#*\\s*" + includeArg + "\\s*=");
//see if in columnstore.cnf.rpmsave
ifstream mycnfsavefile (mycnfsaveFile.c_str());
char line[200];
string oldbuf;
while (mycnfsavefile.getline(line, 200))
{
oldbuf = line;
if ( boost::regex_search(oldbuf.begin(), oldbuf.end(), icludeArgRegEx) )
{
//found in columnstore.cnf.rpmsave, check if this is commented out
if ( line[0] != '#' )
{
// no, check in columnstore.cnf and replace if exist or add if it doesn't
ifstream mycnffile (mycnfFile.c_str());
vector <string> lines;
char line1[200];
string newbuf;
bool updated = false;
while (mycnffile.getline(line1, 200))
{
newbuf = line1;
if ( boost::regex_search(newbuf.begin(), newbuf.end(), icludeArgRegEx) )
{
newbuf = oldbuf;
cout << "Updated argument: " << includeArg << endl;
updated = true;
}
//output to temp file
lines.push_back(newbuf);
}
//write out a new columnstore.cnf
mycnffile.close();
unlink (mycnfFile.c_str());
ofstream newFile (mycnfFile.c_str());
//create new file
int fd = open(mycnfFile.c_str(), O_RDWR|O_CREAT, 0644);
copy(lines.begin(), lines.end(), ostream_iterator<string>(newFile, "\n"));
newFile.close();
close(fd);
if (!updated)
{
//not found, so add
ifstream mycnffile (mycnfFile.c_str());
vector <string> lines;
char line1[200];
string newbuf;
while (mycnffile.getline(line1, 200))
{
newbuf = line1;
boost::regex mysqldSectionRegEx("\\[mysqld\\]");
if ( boost::regex_search(newbuf.begin(), newbuf.end(), mysqldSectionRegEx) )
{
lines.push_back(newbuf);
newbuf = oldbuf;
cout << "Added argument: " << includeArg << endl;
}
//output to temp file
lines.push_back(newbuf);
}
//write out a new columnstore.cnf
mycnffile.close();
unlink (mycnfFile.c_str());
ofstream newFile (mycnfFile.c_str());
//create new file
int fd = open(mycnfFile.c_str(), O_RDWR | O_CREAT, 0666);
copy(lines.begin(), lines.end(), ostream_iterator<string>(newFile, "\n"));
newFile.close();
close(fd);
break;
}
}
}
}
}
string USER = "mysql";
char* p = getenv("USER");
if (p && *p)
USER = p;
string cmd = "chown " + USER + ":" + USER + " " + mycnfFile;
system(cmd.c_str());
exit (0);
}
// vim:ts=4 sw=4:

View File

@ -1,154 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/******************************************************************************************
* $Id: postConfigure.cpp 64 2006-10-12 22:21:51Z dhill $
*
*
* List of files being updated by post-install configure:
* mariadb/columnstore/etc/Columnstore.xml
* mariadb/columnstore/etc/ProcessConfig.xml
* /etc/rc.d/rc.local
*
******************************************************************************************/
/**
* @file
*/
#include <unistd.h>
#include <iterator>
#include <numeric>
#include <deque>
#include <iostream>
#include <ostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <limits.h>
#include <sstream>
#include <exception>
#include <stdexcept>
#include <vector>
#include <stdio.h>
#include <ctype.h>
#include <netdb.h>
#include <sys/sysinfo.h>
#include <climits>
#include <cstring>
#include <glob.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <ifaddrs.h>
#include <string.h> /* for strncpy */
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <net/if.h>
#include <readline/history.h>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/tokenizer.hpp>
#include "mcsconfig.h"
#include "columnstoreversion.h"
#include "liboamcpp.h"
#include "configcpp.h"
using namespace std;
using namespace config;
#include "helpers.h"
using namespace installer;
#include "installdir.h"
bool updateBash(string homeDir);
int main(int argc, char* argv[])
{
string cmd;
string numBlocksPctParam = "";
string totalUmMemoryParam = "";
string homeDir = "/root";
bool rootUser = true;
//check if root-user
int user;
user = getuid();
if (user != 0)
{
rootUser = false;
}
if (!rootUser)
{
char* p = getenv("HOME");
if (p && *p)
homeDir = p;
}
//get current time and date
time_t now;
now = time(NULL);
struct tm tm;
localtime_r(&now, &tm);
char timestamp[200];
strftime (timestamp, 200, "%m:%d:%y-%H:%M:%S", &tm);
string currentDate = timestamp;
string postConfigureLog = "/var/log/columnstore-postconfigure-" + currentDate;
// perform single server install
cout << endl << "Performing the Single Server Install." << endl << endl;
if (!rootUser)
{
if (!updateBash(homeDir))
cout << "updateBash error" << endl;
}
//check if dbrm data resides in older directory path and inform user if it does
dbrmDirCheck();
if (numBlocksPctParam.empty()) {
numBlocksPctParam = "-";
}
if (totalUmMemoryParam.empty()) {
totalUmMemoryParam = "-";
}
cmd = "columnstore_installer dummy.rpm dummy.rpm dummy.rpm dummy.rpm dummy.rpm initial dummy n --nodeps ' ' 1 " + numBlocksPctParam + " " + totalUmMemoryParam;
system(cmd.c_str());
exit(0);
}
bool updateBash(string homeDir)
{
string fileName = homeDir + "/.bashrc";
ifstream newFile (fileName.c_str());
newFile.close();
return true;
}
// vim:ts=4 sw=4:

View File

@ -1,67 +0,0 @@
#!/bin/bash
#
# $Id: quick_installer_amazon.sh 3705 2018-07-07 19:47:20Z dhill $
#
# Poddst- Quick Installer for Amazon MariaDB Columnstore
pmCount=""
umCount=""
systemName=""
for arg in "$@"; do
if [ `expr -- "$arg" : '--pm-count='` -eq 11 ]; then
pmCount="`echo $arg | awk -F= '{print $2}'`"
elif [ `expr -- "$arg" : '--um-count='` -eq 11 ]; then
umCount="`echo $arg | awk -F= '{print $2}'`"
elif [ `expr -- "$arg" : '--system-name='` -eq 14 ]; then
systemName="`echo $arg | awk -F= '{print $2}'`"
systemName="-sn "$systemName
elif [ `expr -- "$arg" : '--help'` -eq 6 ]; then
echo "Usage ./quick_installer_amazon.sh [OPTION]"
echo ""
echo "Quick Installer for an Amazon MariaDB ColumnStore Install"
echo "This requires to be run on a MariaDB ColumnStore AMI"
echo ""
echo "Performace Module (pm) number is required"
echo "User Module (um) number is option"
echo "When only pm counts provided, system is combined setup"
echo "When both pm/um counts provided, system is separate setup"
echo
echo "--pm-count=x Number of pm instances to create"
echo "--um-count=x Number of um instances to create, optional"
echo "--system-name=nnnn System Name, optional"
echo ""
exit 1
else
echo "./quick_installer_amazon.sh: unknown argument: $arg, enter --help for help" 1>&2
exit 1
fi
done
if [[ $pmCount = "" ]]; then
echo ""
echo "Performace Module (pm) count is required, exiting"
exit 1
else
if [[ $umCount = "" ]]; then
echo ""
echo "NOTE: Performing a Multi-Server Combined install with um/pm running on some server"
echo""
else
echo ""
echo "NOTE: Performing a Multi-Server separate install with um and pm running on separate servers"
echo""
fi
fi
echo ""
echo "${bold}Run post-install script${normal}"
echo ""
columnstore-post-install
echo "${bold}Run postConfigure script${normal}"
echo ""
if [[ $umCount = "" ]]; then
postConfigure -qa -pm-count $pmCount $systemName -d
else
postConfigure -qa -pm-count $pmCount -um-count $umCount $systemName -d
fi

View File

@ -1,69 +0,0 @@
#!/bin/bash
#
# $Id: quick_installer_multi_server.sh 3705 2018-07-07 19:47:20Z dhill $
#
# Poddst- Quick Installer for Multi Server MariaDB Columnstore
pmIpAddrs=""
umIpAddrs=""
systemName=""
for arg in "$@"; do
if [ `expr -- "$arg" : '--pm-ip-addresses='` -eq 18 ]; then
pmIpAddrs="`echo $arg | awk -F= '{print $2}'`"
elif [ `expr -- "$arg" : '--um-ip-addresses='` -eq 18 ]; then
umIpAddrs="`echo $arg | awk -F= '{print $2}'`"
elif [ `expr -- "$arg" : '--system-name='` -eq 14 ]; then
systemName="`echo $arg | awk -F= '{print $2}'`"
systemName="-sn "$systemName
elif [ `expr -- "$arg" : '--help'` -eq 6 ]; then
echo "Usage ./quick_installer_multi_server.sh [OPTION]"
echo ""
echo "Quick Installer for a Multi Server MariaDB ColumnStore Install"
echo ""
echo "Defaults to non-distrubuted install, meaning MariaDB Columnstore"
echo "needs to be preinstalled on all nodes in the system"
echo ""
echo "Performace Module (pm) IP addresses are required"
echo "User Module (um) IP addresses are option"
echo "When only pm IP addresses provided, system is combined setup"
echo "When both pm/um IP addresses provided, system is separate setup"
echo
echo "--pm-ip-addresses=xxx.xxx.xxx.xxx,xxx.xxx.xxx.xxx"
echo "--um-ip-addresses=xxx.xxx.xxx.xxx,xxx.xxx.xxx.xxx, optional"
echo "--system-name=nnnn System Name, optional"
echo ""
exit 1
else
echo "quick_installer_multi_server.sh: unknown argument: $arg, enter --help for help" 1>&2
exit 1
fi
done
if [[ $pmIpAddrs = "" ]]; then
echo ""
echo "Performace Module (pm) IP addresses required, exiting"
exit 1
else
if [[ $umIpAddrs = "" ]]; then
echo ""
echo "NOTE: Performing a Multi-Server Combined install with um/pm running on some server"
echo""
else
echo ""
echo "NOTE: Performing a Multi-Server separate install with um and pm running on separate servers"
echo""
fi
fi
echo ""
echo "${bold}Run post-install script${normal}"
echo ""
columnstore-post-install
echo "${bold}Run postConfigure script${normal}"
echo ""
if [[ $umIpAddrs = "" ]]; then
postConfigure -qm -pm-ip-addrs $pmIpAddrs $systemName
else
postConfigure -qm -pm-ip-addrs $pmIpAddrs -um-ip-addrs $umIpAddrs $systemName
fi

View File

@ -1,26 +0,0 @@
#!/bin/bash
#
# $Id: quick_installer_single_server.sh 3705 2018-07-07 19:47:20Z dhill $
#
# Poddst- Quick Installer for Single Server MariaDB Columnstore
for arg in "$@"; do
if [ `expr -- "$arg" : '--help'` -eq 6 ]; then
echo "Usage ./quick_installer_single_server.sh"
echo ""
echo "Quick Installer for a Single Server MariaDB ColumnStore Install"
echo ""
exit 1
else
echo "quick_installer_single_server.sh: ignoring unknown argument: $arg" 1>&2
fi
done
echo ""
echo "Run post-install script"
echo ""
columnstore-post-install
echo "Run postConfigure script"
echo ""
postConfigure -qs

View File

@ -1,213 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***************************************************************************
* $Id: hardwareMonitor.cpp 34 2006-09-29 21:13:54Z dhill $
*
* Author: David Hill
***************************************************************************/
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdlib>
#include <cerrno>
#include <exception>
#include <stdexcept>
#include "liboamcpp.h"
#include "messagelog.h"
#include "messageobj.h"
#include "loggingid.h"
#include "alarmmanager.h"
#include "installdir.h"
using namespace std;
using namespace oam;
using namespace alarmmanager;
using namespace logging;
/**
* @brief send alarm
*/
void sendAlarm(string alarmItem, ALARMS alarmID, int action);
/************************************************************************************************************
* @brief main function
*
* purpose: Get current hardware status and report alarms
*
* Parses file generated by the ipmitool
*
* pattern = what it is | value | units | status | value 1 | value 2 | value 3 | value 4 | value 5 | value 6
* data(0) = what it is
* data(1) = value
* data(2) = units
* data(3) = status
* data(4)-data(9) = barrier values
* data(4) - low non-recoverable, i.e. fatal
* data(5) - low critical
* data(6) - low warning
* data(7) - high warning
* data(8) - high critical
* data(9) - high non-recoverable, i.e. fatal
*
************************************************************************************************************/
int main (int argc, char** argv)
{
string data[10];
string SensorName;
string SensorValue;
string Units;
string SensorStatus;
string lowFatal;
string lowCritical;
string lowWarning;
string highWarning;
string highCritical;
string highFatal;
char* p;
string tmpDir = startup::StartUp::tmpDir();
// loop forever reading the hardware status
while (TRUE)
{
string logFile = tmpDir + "/harwareMonitor.txt";
string cmd = "ipmitool sensor list > " + logFile;
int returnCode = system(cmd.c_str());
if (returnCode)
{
// System error
cout << "Error running ipmitool sensor list!!!" << endl;
exit(-1);
}
// parse output file
ifstream File (logFile);
if (!File)
{
// System error
cout << "Error opening " << logFile << endl;
exit(-1);
}
char line[200];
while (File.getline(line, 200))
{
// parse the line
int f = 0;
p = strtok(line, "|");
while (p)
{
data[f] = p;
p = strtok (NULL, "|");
f++;
}
if ( f == 0 )
// nothing on this line, skip
continue;
SensorName = data[0];
SensorValue = data[1];
Units = data[2];
SensorStatus = data[3];
lowFatal = data[4];
lowCritical = data[5];
lowWarning = data[6];
highWarning = data[7];
highCritical = data[8];
highFatal = data[9];
// check status and issue apporiate alarm if needed
if ( (SensorStatus != "ok") && (SensorStatus != "nr") )
{
// Status error, check for warning or critical levels
if ( SensorValue >= highFatal )
// issue critical alarm
sendAlarm(SensorName, HARDWARE_HIGH, SET);
else if ( (SensorValue < highFatal) && (SensorValue >= highCritical) )
// issue major alarm
sendAlarm(SensorName, HARDWARE_MED, SET);
else if ( (SensorValue < highCritical ) && (SensorValue >= highWarning) )
// issue minor alarm
sendAlarm(SensorName, HARDWARE_LOW, SET);
else if ( (SensorValue <= lowWarning) && (SensorValue > lowCritical) )
// issue minor alarm
sendAlarm(SensorName, HARDWARE_LOW, SET);
else if ( (SensorValue <= lowCritical) && (SensorValue > lowFatal) )
// issue major alarm
sendAlarm(SensorName, HARDWARE_MED, SET);
else if ( SensorValue <= lowFatal )
// issue critical alarm
sendAlarm(SensorName, HARDWARE_HIGH, SET);
}
} //end of parsing file while
File.close();
sleep(5);
} //end of forever while loop
}
/******************************************************************************************
* @brief sendAlarm
*
* purpose: send a trap and log the process information
*
******************************************************************************************/
void sendAlarm(string alarmItem, ALARMS alarmID, int action)
{
Oam oam;
ALARMManager alarmMgr;
// send alarm
alarmMgr.sendAlarmReport(alarmItem.c_str(), alarmID, action);
//Log this event
LoggingID lid;
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Alarm action against ");
args.add(alarmItem);
if ( action == SET )
{
args.add("Action type: SET");
}
else
{
args.add("Action type: CLEAR");
}
ml.logDebugMessage(msg);
return;
}

View File

@ -1,348 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***************************************************************************
* $Id: resourceMonitor.cpp 3072 2013-04-04 19:04:45Z rdempsey $
*
* Author: Zhixuan Zhu
***************************************************************************/
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdlib>
#include <cerrno>
#include <exception>
#include <stdexcept>
#include "liboamcpp.h"
using namespace std;
using namespace oam;
/**
* constants define
*/
enum HOST_INFO
{
USER = 0,
SYSTEM,
NICE,
IDLE
};
const string FE_MOUNT_DIR = "/var/log/mariadb/columnstore/"; // FE mount dir
const int MONITOR_FREQ = 15; // monitor frequency in sec
const int LOG_FREQ = 900; // log frequency in sec
const int DEBUG = false;
/**
* global variables
*/
static char cpu[5];
static unsigned int usage[LOG_FREQ / MONITOR_FREQ];
static int usageCount = 0;
/**
* @brief get cpu usage for cpuNo
*/
unsigned int* getUsage(char* cpuNo);
/**
* @brief get cpu usage diffence over 3 seconds
*/
unsigned int* diffUsage();
/**
* @brief calculate overall cpu usage
*/
unsigned int calcCPUusage(unsigned int* times);
/**
* @brief log cpu usage to active log file
*/
void logCPUactive (unsigned int);
/**
* @brief log cpu peak and average to stat file
*/
void logCPUstat ();
/*****************************************************************************************
* @brief main function
*
* purpose: Get current CPU usage and return current state
*
*****************************************************************************************/
int main (int argc, char** argv)
{
unsigned int* times;
unsigned int cpuUsage = 0;
// set defaults
unsigned int cpuCritical = 9000,
cpuMajor = 8000,
cpuMinor = 7000,
cpuMinorClear = 6000;
strcpy (cpu, "cpu");
// get specific CPU info
times = diffUsage();
// no cpus available on the system
if (times == NULL)
{
cout << "No cpus on the system" << endl;
return 0;
}
cpuUsage = calcCPUusage(times);
logCPUactive(cpuUsage);
cout << "cpuUsage: " << cpuUsage << endl;
// Get CPU usage water mark from server configuration and compare
ServerConfig serverConfig;
Oam oam;
try
{
oam.getSystemConfig (serverConfig);
cpuCritical = serverConfig.ServerCPUCriticalThreshold;
cpuMajor = serverConfig.ServerCPUMajorThreshold;
cpuMinor = serverConfig.ServerCPUMinorThreshold;
cpuMinorClear = serverConfig.ServerCPUMinorClearThreshold;
}
catch (runtime_error e)
{
throw e;
}
cout << "critical water: " << serverConfig.ServerCPUCriticalThreshold << endl;
if (cpuUsage >= cpuCritical)
{
cout << "return critical: " << CRITICAL << endl;
return CRITICAL;
}
else if (cpuUsage >= cpuMajor)
{
cout << "return major: " << MAJOR << endl;
return MAJOR;
}
else if (cpuUsage >= cpuMinor)
{
cout << "return Minor: " << MINOR << endl;
return MINOR;
}
else if (cpuUsage >= cpuMinorClear)
{
cout << "return MinorClear: " << WARNING << endl;
return WARNING;
}
else
{
cout << "return Below MinorClear: " << NO_SEVERITY << endl;
return NO_SEVERITY;
}
}
/*****************************************************************************************
* @brief diffUsage
*
* purpose: Compare usage different for changes
*
*****************************************************************************************/
unsigned int* diffUsage()
{
static unsigned int times1[4];
unsigned int* times;
int i;
times = getUsage(cpu);
if (times == NULL)
return NULL;
memcpy(times1, getUsage(cpu), sizeof(unsigned int) * 4);
sleep(3);
times = getUsage(cpu);
for (i = 0; i < 4; i++)
times1[i] = times[i] - times1[i];
return times1;
}
/*****************************************************************************************
* @brief diffUsage
*
* purpose: Compare usage different for changes
*
*****************************************************************************************/
unsigned int* getUsage(char* cpuNo)
{
static unsigned int times[4];
char tmp[5];
char str[80];
FILE* file;
file = fopen("/proc/stat", "r");
while (fgets(str, 80, file))
{
// search for cpuNo
if ((strstr (str, cpuNo) != NULL))
{
sscanf(str, "%s %u %u %u %u", tmp,
&times[0], &times[1], &times[2], &times[3]);
fclose(file);
return times;
}
}
fclose(file);
return NULL;
}
/*****************************************************************************************
* @brief calcCPUusage
*
* purpose: Calculate CPU usage
*
*****************************************************************************************/
unsigned int calcCPUusage (unsigned int* times)
{
unsigned int total = 0;
for (int i = 0; i < 4; i++)
total += times[i];
double load = (double)times[IDLE] * 100.0 / (double)total;
return (int)((100.0 - load));
}
/*****************************************************************************************
* @brief logCPUactive
*
* purpose: Log Peak and Average CPU usage
*
*****************************************************************************************/
void logCPUactive (unsigned int cpuUsage)
{
// determin the active log file name
string usageLogFileName = FE_MOUNT_DIR;
usageLogFileName = usageLogFileName + cpu + ".log";
if (DEBUG)
cout << usageLogFileName << endl;
fstream usageLogFile;
usageLogFile.open (usageLogFileName.c_str(), ios::in | ios::out);
if (usageLogFile.fail())
{
ofstream file (usageLogFileName.c_str());
file.close();
usageLogFile.open(usageLogFileName.c_str(), ios::in | ios::out);
if (!usageLogFile) cout << "--error" << endl;
}
// get the counter
usageLogFile.seekg(0, ios::beg);
usageLogFile.read (reinterpret_cast<char*>(&usageCount), sizeof (int));
if (usageLogFile.eof()) usageLogFile.clear();
// new iteration
if (usageCount == 0)
{
usageLogFile.seekp(0, ios::beg);
usageLogFile.write (reinterpret_cast<char*>(&usageCount), sizeof (int));
}
usageCount ++;
// append new usage data to the end
usageLogFile.seekp (0, ios::end);
usageLogFile.write (reinterpret_cast<char*>(&cpuUsage), sizeof (int));
if (DEBUG)
cout << "usage: " << usageCount << endl;
// calculate peak and average if it's time to log usage data
if (usageCount >= LOG_FREQ / MONITOR_FREQ)
{
usageLogFile.seekg (4, ios::beg);
usageLogFile.read ((char*)usage, sizeof(unsigned int) * LOG_FREQ / MONITOR_FREQ);
if (usageLogFile.eof()) usageLogFile.clear();
if (DEBUG)
{
for (int i = 0; i < usageCount; i++)
{
cout << usage [i] << endl;
}
}
logCPUstat();
// delete the file
usageLogFile.close();
unlink (usageLogFileName.c_str());
}
// else, update usageCount
else
{
usageLogFile.seekp(0, ios::beg);
usageLogFile.write (reinterpret_cast<char*>(&usageCount), sizeof (int));
usageLogFile.close();
}
}
/*****************************************************************************************
* @brief logCPUstat
*
* purpose: Log CPU stat using system API
*
*****************************************************************************************/
void logCPUstat ()
{
unsigned int max = 0;
unsigned int sum = 0;
float average = 0.0;
for (int i = 0; i < usageCount; i++)
{
if (usage[i] > max)
max = usage[i];
sum += usage[i];
}
average = sum / usageCount;
// Call system log api to store stats.
// for now, write on local for testing purpose.
string statFileName = FE_MOUNT_DIR;
statFileName = statFileName + cpu + "stat.log";
ofstream file (statFileName.c_str(), ios::app);
file << max << " " << average << endl;
file.close();
}

View File

@ -1,64 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/* $Id: tdriver.cpp 3072 2013-04-04 19:04:45Z rdempsey $ */
#include <cstring>
#include <cppunit/extensions/HelperMacros.h>
class ResourceMonitorTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( ResourceMonitorTest );
CPPUNIT_TEST( test1 );
CPPUNIT_TEST_SUITE_END();
private:
public:
void setUp()
{
}
void tearDown()
{
}
void test1()
{
//system ("./resourceMonitor 0");
}
};
CPPUNIT_TEST_SUITE_REGISTRATION( ResourceMonitorTest );
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
int main( int argc, char** argv)
{
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest( registry.makeTest() );
bool wasSuccessful = runner.run( "", false );
return (wasSuccessful ? 0 : 1);
}

View File

@ -1,26 +0,0 @@
include_directories( ${ENGINE_COMMON_INCLUDES} )
########### next target ###############
set(ServerMonitor_SRCS
main.cpp
serverMonitor.cpp
cpuMonitor.cpp
diskMonitor.cpp
memoryMonitor.cpp
procmonMonitor.cpp
msgProcessor.cpp
dbhealthMonitor.cpp
UMAutoSync.cpp
../../utils/common/crashtrace.cpp)
add_executable(ServerMonitor ${ServerMonitor_SRCS})
target_compile_options(ServerMonitor PRIVATE -Wno-unused-result)
target_link_libraries(ServerMonitor ${ENGINE_LDFLAGS} ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS})
install(TARGETS ServerMonitor DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine)

View File

@ -1,270 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
* Copyright (C) 2016 MariaDB Corporation.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***************************************************************************
* $Id: UMAutoSync.cpp 34 2006-09-29 21:13:54Z dhill $
*
* Author: Zhixuan Zhu
***************************************************************************/
#include "serverMonitor.h"
#include "installdir.h"
using namespace std;
using namespace oam;
using namespace alarmmanager;
using namespace logging;
using namespace servermonitor;
using namespace config;
typedef struct UMmodule_struct
{
std::string moduleName;
std::string IPAddr;
} UMmodule;
typedef std::vector<UMmodule> UMmoduleList;
void rsync(std::string moduleName, std::string IPAddr, std::string rootPassword);
/*****************************************************************************************
* @brief UMAutoSync Thread
*
* purpose: check db health
*
*****************************************************************************************/
void UMAutoSync()
{
ServerMonitor serverMonitor;
Oam oam;
UMmoduleList ummodulelist;
// sync run time in minutes
int UMSyncTime = 10;
try
{
oam.getSystemConfig( "UMSyncTime", UMSyncTime);
}
catch (...)
{
UMSyncTime = 10;
}
if ( UMSyncTime < 1 )
UMSyncTime = 10;
//get root password
string rootPassword = oam::UnassignedName; // default to 'n'
try
{
oam.getSystemConfig( "rpw", rootPassword);
}
catch (...)
{
rootPassword = oam::UnassignedName;
}
//if assigned, exit thread
if (rootPassword == oam::UnassignedName)
pthread_exit((void*) NULL);
oamModuleInfo_t t;
//get local module info
string localModuleName;
string localModuleType;
try
{
t = oam.getModuleInfo();
localModuleName = boost::get<0>(t);
localModuleType = boost::get<1>(t);
}
catch (...) {}
// loop forever
while (true)
{
// LoggingID lid(SERVER_MONITOR_LOG_ID);
// MessageLog ml(lid);
// Message msg;
// Message::Args args;
// args.add("rsync thread running");
// msg.format(args);
// ml.logDebugMessage(msg);
//
// find non-disabled modules to sync up
//
try
{
SystemStatus systemstatus;
oam.getSystemStatus(systemstatus);
ummodulelist.clear();
for ( unsigned int i = 0 ; i < systemstatus.systemmodulestatus.modulestatus.size(); i++)
{
if ( systemstatus.systemmodulestatus.modulestatus[i].Module.empty() )
// end of list
break;
string moduleName = systemstatus.systemmodulestatus.modulestatus[i].Module;
string moduleType = moduleName.substr(0, MAX_MODULE_TYPE_SIZE);
if ( moduleType == localModuleType && moduleName != localModuleName )
{
int state = systemstatus.systemmodulestatus.modulestatus[i].ModuleOpState;
if ( state == oam::MAN_DISABLED || state == oam::AUTO_DISABLED )
continue;
else //get module IP Address
{
ModuleConfig moduleconfig;
oam.getSystemConfig(moduleName, moduleconfig);
HostConfigList::iterator pt1 = moduleconfig.hostConfigList.begin();
UMmodule ummodule;
ummodule.IPAddr = (*pt1).IPAddr;
ummodule.moduleName = moduleName;
ummodulelist.push_back(ummodule);
}
}
}
}
catch (...) {}
//update all ums
UMmoduleList::iterator list1 = ummodulelist.begin();
for (; list1 != ummodulelist.end() ; list1++)
{
//call rsync function
rsync((*list1).moduleName, (*list1).IPAddr, rootPassword);
}
//
// go into check for um module update module, rsync to new modules
//
for ( int time = 0 ; time < UMSyncTime ; time++ )
{
try
{
SystemStatus systemstatus;
oam.getSystemStatus(systemstatus);
for ( unsigned int i = 0 ; i < systemstatus.systemmodulestatus.modulestatus.size(); i++)
{
if ( systemstatus.systemmodulestatus.modulestatus[i].Module.empty() )
// end of list
break;
string moduleName = systemstatus.systemmodulestatus.modulestatus[i].Module;
string moduleType = moduleName.substr(0, MAX_MODULE_TYPE_SIZE);
if ( moduleType == localModuleType && moduleName != localModuleName )
{
int state = systemstatus.systemmodulestatus.modulestatus[i].ModuleOpState;
if ( state == oam::MAN_DISABLED || state == oam::AUTO_DISABLED )
continue;
else //check if in current sync list
{
UMmoduleList::iterator list1 = ummodulelist.begin();
bool found = false;
for (; list1 != ummodulelist.end() ; list1++)
{
if ( moduleName == (*list1).moduleName)
{
found = true;
break;
}
}
if ( !found)
{
//get module IP Address
ModuleConfig moduleconfig;
oam.getSystemConfig(moduleName, moduleconfig);
HostConfigList::iterator pt1 = moduleconfig.hostConfigList.begin();
//call rsync function
rsync(moduleName, (*pt1).IPAddr, rootPassword);
UMmodule ummodule;
ummodule.IPAddr = (*pt1).IPAddr;
ummodule.moduleName = moduleName;
ummodulelist.push_back(ummodule);
}
}
}
}
}
catch (...) {}
sleep(60);
}
} // end of while loop
}
/*
* rsync script function
*/
void rsync(std::string moduleName, std::string IPAddr, std::string rootPassword)
{
string cmd = "rsync.sh " + IPAddr + " " + rootPassword + " 1 > /tmp/rsync_" + moduleName + ".log";
int ret = system(cmd.c_str());
if ( WEXITSTATUS(ret) == 0 )
{
/* LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Successfully rsync to module: ");
args.add(moduleName);
msg.format(args);
ml.logDebugMessage(msg);
*/
}
else
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Failure rsync to module: ");
args.add(moduleName);
msg.format(args);
ml.logDebugMessage(msg);
}
return;
}

View File

@ -1,593 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***************************************************************************
* $Id: cpuMonitor.cpp 34 2006-09-29 21:13:54Z dhill $
*
* Author: Zhixuan Zhu
***************************************************************************/
#include "serverMonitor.h"
using namespace std;
using namespace oam;
using namespace alarmmanager;
using namespace logging;
using namespace servermonitor;
//using namespace procheartbeat;
float currentCpuUsage;
ProcessCPUList pcl;
pthread_mutex_t CPU_LOCK;
/**
* constants define
*/
const std::string FE_MOUNT_DIR = "/var/log/mariadb/columnstore/"; // FE mount dir
const int MONITOR_FREQ = 5; // monitor frequency in sec
const int LOG_FREQ = 900; // log frequency in sec
const int RESOURCE_DEBUG = false;
static unsigned int usage[LOG_FREQ / MONITOR_FREQ];
static int usageCount = 0;
extern string tmpDir;
/*****************************************************************************************
* @brief cpuMonitor Thread
*
* purpose: Get current CPU usage, average over 5 readings and report alarms
*
*****************************************************************************************/
void cpuMonitor()
{
ServerMonitor serverMonitor;
// register for Heartbeat monitoring
/* try {
ProcHeartbeat procheartbeat;
procheartbeat.registerHeartbeat(CPU_HEARTBEAT_ID);
}
catch (exception& ex)
{
string error = ex.what();
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("EXCEPTION ERROR on registerHeartbeat: ");
args.add(error);
msg.format(args);
ml.logErrorMessage(msg);
}
catch(...)
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("EXCEPTION ERROR on sendHeartbeat: Caught unknown exception!");
msg.format(args);
ml.logErrorMessage(msg);
}
*/
const int periodCount = 5;
float cpuPeriod[periodCount];
int periodCounter = 0;
float averageCpuUsage = 0;
currentCpuUsage = 0;
// set defaults
unsigned int cpuCritical = 0,
cpuMajor = 0,
cpuMinor = 0,
cpuMinorClear = 0;
// initial cpu Period table
for (int i = 0; i < periodCount; i++)
{
cpuPeriod[i] = 0;
}
while (true)
{
// Get CPU usage water mark from server configuration and compare
ModuleTypeConfig moduleTypeConfig;
Oam oam;
try
{
oam.getSystemConfig(moduleTypeConfig);
cpuCritical = moduleTypeConfig.ModuleCPUCriticalThreshold;
cpuMajor = moduleTypeConfig.ModuleCPUMajorThreshold;
cpuMinor = moduleTypeConfig.ModuleCPUMinorThreshold;
cpuMinorClear = moduleTypeConfig.ModuleCPUMinorClearThreshold;
}
catch (...)
{
sleep(5);
continue;
}
if (RESOURCE_DEBUG)
cout << "critical water: " << moduleTypeConfig.ModuleCPUCriticalThreshold << endl;
pthread_mutex_lock(&CPU_LOCK);
//
// get Process and System CPU usage
//
serverMonitor.getCPUdata();
// store and get average
cpuPeriod[periodCounter] = currentCpuUsage;
averageCpuUsage = 0;
for (int i = 0; i < periodCount; i++)
{
averageCpuUsage += cpuPeriod[i];
}
averageCpuUsage = averageCpuUsage / periodCount;
// serverMonitor.logCPUactive(averageCpuUsage);
if (CPU_DEBUG)
{
cout << "Current CPU Usage: " << currentCpuUsage << endl;
cout << "Average CPU Usage: " << averageCpuUsage << endl;
}
if (averageCpuUsage >= cpuCritical && cpuCritical > 0 )
{
serverMonitor.sendResourceAlarm("CPU", CPU_USAGE_HIGH, SET, (int) averageCpuUsage);
}
else if (averageCpuUsage >= cpuMajor && cpuMajor > 0 )
serverMonitor.sendResourceAlarm("CPU", CPU_USAGE_MED, SET, (int) averageCpuUsage);
else if (averageCpuUsage >= cpuMinor && cpuMinor > 0 )
serverMonitor.sendResourceAlarm("CPU", CPU_USAGE_LOW, SET, (int) averageCpuUsage);
else if (averageCpuUsage >= cpuMinorClear && cpuMinorClear > 0 )
{
serverMonitor.checkCPUAlarm("CPU", CPU_USAGE_LOW);
//Log this event
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Current CPU usage = ");
args.add((int) currentCpuUsage);
args.add(", Average CPU usage = ");
args.add((int) averageCpuUsage);
msg.format(args);
ml.logInfoMessage(msg);
}
else
serverMonitor.checkCPUAlarm("CPU");
//
// check CPU usage by process
//
ProcessCPUList::iterator p = pcl.begin();
while (p != pcl.end())
{
string processName = (*p).processName;
double cpuUsage = (*p).usedPercent;
p++;
if (CPU_DEBUG)
{
cout << "Process Name : " << processName << endl;
cout << "CPU Usage: " << cpuUsage << endl;
}
// check if a Calpont Process, if so alarm is over thresholds
// if not, just log if over thresholds
if (cpuUsage >= cpuCritical && cpuCritical > 0)
{
/* try {
t = oam.getMyProcessStatus(processID);
processName = boost::get<1>(t);
serverMonitor.sendResourceAlarm(processName, CPU_USAGE_HIGH, SET, (int) cpuUsage);
}
catch (...) {
*/ LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Process");
args.add(processName);
args.add(" above Critical CPU threshold with a percentage of ");
args.add((int) cpuUsage);
msg.format(args);
ml.logInfoMessage(msg);
// }
}
else if (cpuUsage >= cpuMajor && cpuMajor > 0)
{
/* try {
t = oam.getMyProcessStatus(processID);
processName = boost::get<1>(t);
serverMonitor.sendResourceAlarm(processName, CPU_USAGE_MED, SET, (int) cpuUsage);
}
catch (...) {
*/ LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Process");
args.add(processName);
args.add(" above Major CPU threshold with a percentage of ");
args.add((int) cpuUsage);
msg.format(args);
ml.logInfoMessage(msg);
// }
}
else if (cpuUsage >= cpuMinor && cpuMinor > 0)
{
/* try {
t = oam.getMyProcessStatus(processID);
processName = boost::get<1>(t);
serverMonitor.sendResourceAlarm(processName, CPU_USAGE_LOW, SET, (int) cpuUsage);
}
catch (...) {
*/ LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Process");
args.add(processName);
args.add(" above Minor CPU threshold with a percentage of ");
args.add((int) cpuUsage);
msg.format(args);
ml.logInfoMessage(msg);
// }
}
/* else if (cpuUsage >= cpuMinorClear) {
try {
t = oam.getMyProcessStatus(processID);
processName = boost::get<1>(t);
serverMonitor.checkCPUAlarm(processName, CPU_USAGE_LOW);
}
catch (...) {}
}
else
serverMonitor.checkCPUAlarm(processName);
*/
}
// send heartbeat message
/* try {
ProcHeartbeat procheartbeat;
procheartbeat.sendHeartbeat(CPU_HEARTBEAT_ID);
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Sent Heartbeat Msg");
msg.format(args);
ml.logInfoMessage(msg);
}
catch (exception& ex)
{
string error = ex.what();
if ( error.find("Disabled") == string::npos ) {
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("EXCEPTION ERROR on sendHeartbeat: ");
args.add(error);
msg.format(args);
ml.logErrorMessage(msg);
}
}
catch(...)
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("EXCEPTION ERROR on sendHeartbeat: Caught unknown exception!");
msg.format(args);
ml.logErrorMessage(msg);
}
*/
pthread_mutex_unlock(&CPU_LOCK);
// sleep, 10 minutes
sleep(MONITOR_PERIOD * 10);
++periodCounter;
if ( periodCounter >= periodCount )
periodCounter = 0;
} // end of while loop
}
/******************************************************************************************
* @brief checkCPUAlarm
*
* purpose: check to see if an alarm(s) is set on CPU and clear if so
*
******************************************************************************************/
void ServerMonitor::checkCPUAlarm(string alarmItem, ALARMS alarmID)
{
Oam oam;
ServerMonitor serverMonitor;
// get current server name
string serverName;
oamModuleInfo_t st;
try
{
st = oam.getModuleInfo();
serverName = boost::get<0>(st);
}
catch (...)
{
serverName = "Unknown Server";
}
switch (alarmID)
{
case ALARM_NONE: // clear all alarms set if any found
if ( serverMonitor.checkActiveAlarm(CPU_USAGE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, CPU_USAGE_HIGH);
if ( serverMonitor.checkActiveAlarm(CPU_USAGE_MED, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, CPU_USAGE_MED);
if ( serverMonitor.checkActiveAlarm(CPU_USAGE_LOW, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, CPU_USAGE_LOW);
break;
case CPU_USAGE_LOW: // clear high and medium alarms set if any found
if ( serverMonitor.checkActiveAlarm(CPU_USAGE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, CPU_USAGE_HIGH);
if ( serverMonitor.checkActiveAlarm(CPU_USAGE_MED, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, CPU_USAGE_MED);
break;
case CPU_USAGE_MED: // clear high alarms set if any found
if ( serverMonitor.checkActiveAlarm(CPU_USAGE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, CPU_USAGE_HIGH);
break;
default: // none to clear
break;
} // end of switch
return;
}
/*****************************************************************************************
* @brief logCPUactive
*
* purpose: Log Peak and Average CPU usage
*
*****************************************************************************************/
void ServerMonitor::logCPUactive (unsigned int cpuUsage)
{
ServerMonitor serverMonitor;
// determin the active log file name
string usageLogFileName = FE_MOUNT_DIR;
usageLogFileName = usageLogFileName + "cpu.log";
if (RESOURCE_DEBUG)
cout << usageLogFileName << endl;
fstream usageLogFile;
usageLogFile.open (usageLogFileName.c_str(), ios::in | ios::out);
if (usageLogFile.fail())
{
ofstream file (usageLogFileName.c_str());
file.close();
usageLogFile.open(usageLogFileName.c_str(), ios::in | ios::out);
if (!usageLogFile) cout << "--error" << endl;
}
// get the counter
usageLogFile.seekg(0, ios::beg);
usageLogFile.read (reinterpret_cast<char*>(&usageCount), sizeof (int));
if (usageLogFile.eof()) usageLogFile.clear();
// new iteration
if (usageCount == 0)
{
usageLogFile.seekp(0, ios::beg);
usageLogFile.write (reinterpret_cast<char*>(&usageCount), sizeof (int));
}
usageCount ++;
// append new usage data to the end
usageLogFile.seekp (0, ios::end);
usageLogFile.write (reinterpret_cast<char*>(&cpuUsage), sizeof (int));
if (RESOURCE_DEBUG)
cout << "usage: " << usageCount << endl;
// calculate peak and average if it's time to log usage data
if (usageCount >= LOG_FREQ / MONITOR_FREQ)
{
usageLogFile.seekg (4, ios::beg);
usageLogFile.read ((char*)usage, sizeof(unsigned int) * LOG_FREQ / MONITOR_FREQ);
if (usageLogFile.eof()) usageLogFile.clear();
if (RESOURCE_DEBUG)
{
for (int i = 0; i < usageCount; i++)
{
cout << usage [i] << endl;
}
}
serverMonitor.logCPUstat(usageCount);
// delete the file
usageLogFile.close();
unlink (usageLogFileName.c_str());
}
// else, update usageCount
else
{
usageLogFile.seekp(0, ios::beg);
usageLogFile.write (reinterpret_cast<char*>(&usageCount), sizeof (int));
usageLogFile.close();
}
}
/*****************************************************************************************
* @brief logCPUstat
*
* purpose: Log CPU stat using system API
*
*****************************************************************************************/
void ServerMonitor::logCPUstat (int usageCount)
{
unsigned int max = 0;
unsigned int sum = 0;
float average = 0.0;
for (int i = 0; i < usageCount; i++)
{
if (usage[i] > max)
max = usage[i];
sum += usage[i];
}
if ( usageCount == 0 )
average = 0;
else
average = sum / usageCount;
// Call system log api to store stats.
// for now, write on local for testing purpose.
string statFileName = FE_MOUNT_DIR;
statFileName = statFileName + "cpustat.log";
ofstream file (statFileName.c_str(), ios::app);
file << max << " " << average << endl;
file.close();
}
/*****************************************************************************************
* @brief logCPUstat
*
* purpose: Log CPU stat using system API
*
*****************************************************************************************/
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());
ifstream oldFile1 (tmpProcessCpu.c_str());
// read top 5 users
int i = 0;
char line[400];
while (oldFile1.getline(line, 400))
{
string buf = line;
string::size_type pos = buf.find (' ', 0);
if (pos != string::npos)
{
processCPU pc;
pc.processName = buf.substr(pos + 1, 80);
pc.usedPercent = atol(buf.substr(0, pos).c_str());
pcl.push_back(pc);
i++;
}
}
oldFile1.close();
//
// get and check Total CPU usage
//
string tmpsystemCpu = tmpDir + "/processCpu";
cmd = "top -b -n 6 -d 1 | grep '%Cpu' | awk '{print $8}' > " + tmpsystemCpu;
system(cmd.c_str());
ifstream oldFile (tmpsystemCpu.c_str());
float systemIdle = 0;
// skip first line in file, and average the next 5 entries which contains idle times
oldFile.getline(line, 400);
int count = 0;
while (oldFile.getline(line, 400))
{
string buf = line;
// Questionable replacement
string::size_type pos = buf.find("id,", 0);
if (pos == string::npos)
{
systemIdle = systemIdle + atol(buf.substr(0, pos - 1).c_str());
count++;
}
else
{
systemIdle = systemIdle + 100;
count++;
}
}
oldFile.close();
if ( count == 0 )
currentCpuUsage = 0;
else
currentCpuUsage = 100 - (systemIdle / count);
}

View File

@ -1,263 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***************************************************************************
* $Id: dbhealthMonitor.cpp 34 2006-09-29 21:13:54Z dhill $
*
* Author: Zhixuan Zhu
***************************************************************************/
#include "serverMonitor.h"
#include "installdir.h"
using namespace std;
using namespace oam;
using namespace alarmmanager;
using namespace logging;
using namespace servermonitor;
using namespace config;
/*****************************************************************************************
* @brief dbhealthMonitor Thread
*
* purpose: check db health
*
*****************************************************************************************/
void dbhealthMonitor()
{
ServerMonitor serverMonitor;
Oam oam;
oamModuleInfo_t t;
//get local module info
string localModuleName;
int serverInstallType = 2;
string OAMParentModuleName;
try
{
t = oam.getModuleInfo();
OAMParentModuleName = boost::get<3>(t);
}
catch (...) {}
//Wait until DMLProc is Active, don't want to run if in rollback mode
while (true)
{
try
{
ProcessStatus procstat;
oam.getProcessStatus("DMLProc", OAMParentModuleName, procstat);
if ( procstat.ProcessOpState == oam::ACTIVE)
break;
}
catch (...)
{}
sleep(10);
}
bool setlog = false;
bool clearlog = false;
while (true)
{
try
{
t = oam.getModuleInfo();
localModuleName = boost::get<0>(t);
OAMParentModuleName = boost::get<3>(t);
serverInstallType = boost::get<5>(t);
}
catch (...) {}
string DBFunctionalMonitorFlag;
try
{
oam.getSystemConfig( "DBFunctionalMonitorFlag", DBFunctionalMonitorFlag);
}
catch (...) {}
// run on um1 or active pm
if ( localModuleName == "um1" ||
( localModuleName == OAMParentModuleName &&
serverInstallType == oam::INSTALL_COMBINE_DM_UM_PM ) )
{
if (DBFunctionalMonitorFlag == "y" )
{
if (!setlog )
{
try
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("DBFunctionalMonitorFlag set: Running dbfunctional tester");
msg.format(args);
ml.logDebugMessage(msg);
}
catch (...)
{}
setlog = true;
}
serverMonitor.healthCheck();
}
else
{
if (!clearlog )
{
try
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("DBFunctionalMonitorFlag not-set: Not Running dbfunctional tester");
msg.format(args);
ml.logDebugMessage(msg);
}
catch (...)
{}
clearlog = true;
}
}
}
// sleep
sleep(MONITOR_PERIOD);
} // end of while loop
}
pthread_mutex_t FUNCTION_LOCK;
int ServerMonitor::healthCheck(bool action)
{
Oam oam;
pthread_mutex_lock(&FUNCTION_LOCK);
//get local module name
string localModuleName;
oamModuleInfo_t t;
try
{
t = oam.getModuleInfo();
localModuleName = boost::get<0>(t);
}
catch (...) {}
//get action
string DBHealthMonitorAction;
oam.getSystemConfig( "DBHealthMonitorAction", DBHealthMonitorAction);
GRACEFUL_FLAG gracefulTemp = GRACEFUL;
ACK_FLAG ackTemp = ACK_YES;
//run Health script
string cmd = "dbhealth.sh > /var/log/mariadb/columnstore/dbfunctional.log1 2>&1";
system(cmd.c_str());
if (!oam.checkLogStatus("/var/log/mariadb/columnstore/dbfunctional.log1", "OK"))
{
if (oam.checkLogStatus("/var/log/mariadb/columnstore/dbfunctional.log1", "ERROR 1045") )
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("dbhealth.sh: Missing Password error");
msg.format(args);
ml.logDebugMessage(msg);
}
else
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("DB Functional check failed");
msg.format(args);
ml.logCriticalMessage(msg);
if (action)
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Send Notification for DB Functional check failed and perform OAM Command");
args.add( DBHealthMonitorAction);
msg.format(args);
ml.logDebugMessage(msg);
oam.sendDeviceNotification(localModuleName, DB_HEALTH_CHECK_FAILED);
if ( DBHealthMonitorAction == "stopSystem")
{
try
{
oam.stopSystem(gracefulTemp, ackTemp);
}
catch (...)
{
}
}
else if ( DBHealthMonitorAction == "restartSystem")
{
try
{
oam.restartSystem(gracefulTemp, ackTemp);
}
catch (...)
{
}
}
else if ( DBHealthMonitorAction == "shutdownSystem")
{
try
{
oam.shutdownSystem(gracefulTemp, ackTemp);
}
catch (...)
{
}
}
}
}
pthread_mutex_unlock(&FUNCTION_LOCK);
return API_FAILURE;
}
pthread_mutex_unlock(&FUNCTION_LOCK);
return API_SUCCESS;
}

View File

@ -1,756 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***************************************************************************
* $Id: diskMonitor.cpp 34 2006-09-29 21:13:54Z dhill $
*
* Author: Zhixuan Zhu
***************************************************************************/
#include "serverMonitor.h"
#include "installdir.h"
using namespace std;
using namespace oam;
using namespace alarmmanager;
using namespace logging;
using namespace servermonitor;
using namespace config;
//using namespace procheartbeat;
SystemDiskList sdl;
typedef struct DBrootData_struct
{
std::string dbrootDir;
bool downFlag;
}
DBrootData;
typedef std::vector<DBrootData> DBrootList;
/*****************************************************************************************
* @brief diskMonitor Thread
*
* purpose: Get current Local and External disk usage and report alarms
*
*****************************************************************************************/
void diskMonitor()
{
ServerMonitor serverMonitor;
Oam oam;
SystemConfig systemConfig;
ModuleTypeConfig moduleTypeConfig;
typedef std::vector<std::string> LocalFileSystems;
LocalFileSystems lfs;
struct statvfs buf;
// set defaults
int localDiskCritical = 90,
localDiskMajor = 80,
localDiskMinor = 70,
ExternalDiskCritical = 90,
ExternalDiskMajor = 80,
ExternalDiskMinor = 70;
// get module types
string moduleType;
int moduleID = -1;
string moduleName;
oamModuleInfo_t t;
try
{
t = oam.getModuleInfo();
moduleType = boost::get<1>(t);
moduleID = boost::get<2>(t);
moduleName = boost::get<0>(t);
}
catch (exception& e) {}
bool Externalflag = false;
string cloud = oam::UnassignedName;
try
{
oam.getSystemConfig( "Cloud", cloud);
}
catch (...)
{
cloud = oam::UnassignedName;
}
//get Gluster Config setting
string DataRedundancyConfig = "n";
try
{
oam.getSystemConfig( "DataRedundancyConfig", DataRedundancyConfig);
}
catch (...)
{
DataRedundancyConfig = "n";
}
int diskSpaceCheck = 0;
while (true)
{
//check for external disk
DBrootList dbrootList;
if (moduleType == "pm")
{
systemStorageInfo_t t;
t = oam.getStorageConfig();
if ( boost::get<0>(t) == "external")
Externalflag = true;
// get dbroot list and storage type from config file
DBRootConfigList dbrootConfigList;
oam.getPmDbrootConfig(moduleID, dbrootConfigList);
DBRootConfigList::iterator pt = dbrootConfigList.begin();
for ( ; pt != dbrootConfigList.end() ; pt++)
{
int dbrootID = *pt;
string dbroot = "DBRoot" + oam.itoa(dbrootID);
string dbootdir;
try
{
oam.getSystemConfig(dbroot, dbootdir);
}
catch (...) {}
if ( dbootdir.empty() || dbootdir == "" )
continue;
DBrootData dbrootData;
dbrootData.dbrootDir = dbootdir;
dbrootData.downFlag = false;
dbrootList.push_back(dbrootData);
}
}
SystemStatus systemstatus;
try
{
oam.getSystemStatus(systemstatus);
}
catch (exception& ex)
{}
if (systemstatus.SystemOpState != oam::ACTIVE )
{
sleep(5);
continue;
}
// Get Local/External Disk Mount points to monitor and associated thresholds
try
{
oam.getSystemConfig (moduleTypeConfig);
localDiskCritical = moduleTypeConfig.ModuleDiskCriticalThreshold;
localDiskMajor = moduleTypeConfig.ModuleDiskMajorThreshold;
localDiskMinor = moduleTypeConfig.ModuleDiskMinorThreshold;
DiskMonitorFileSystems::iterator p = moduleTypeConfig.FileSystems.begin();
for ( ; p != moduleTypeConfig.FileSystems.end() ; p++)
{
string fs = *p;
lfs.push_back(fs);
if (DISK_DEBUG)
{
//Log this event
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Local Config File System to monitor =");
args.add(fs);
msg.format(args);
ml.logDebugMessage(msg);
}
}
}
catch (...)
{
sleep(5);
continue;
}
// get External info
try
{
oam.getSystemConfig(systemConfig);
}
catch (...)
{
sleep(5);
continue;
}
if (Externalflag)
{
// get External info
try
{
ExternalDiskCritical = systemConfig.ExternalCriticalThreshold;
ExternalDiskMajor = systemConfig.ExternalMajorThreshold;
ExternalDiskMinor = systemConfig.ExternalMinorThreshold;
}
catch (...)
{
sleep(5);
continue;
}
}
if ( diskSpaceCheck == 0 )
{
//check for local file systems
LocalFileSystems::iterator p = lfs.begin();
while (p != lfs.end())
{
string deviceName = *p;
++p;
string fileName;
// check local
if ( deviceName == "/")
{
fileName = deviceName + "/var/lib/columnstore/";
}
else
{
fileName = deviceName + "/000.dir";
}
uint64_t totalBlocks;
uint64_t usedBlocks;
if (!statvfs(fileName.c_str(), &buf))
{
uint64_t blksize, blocks, freeblks, free;
blksize = buf.f_bsize;
blocks = buf.f_blocks;
freeblks = buf.f_bavail;
totalBlocks = blocks * blksize;
free = freeblks * blksize;
usedBlocks = totalBlocks - free;
}
else
continue;
int64_t diskUsage = 0;
if ( totalBlocks == 0 )
{
diskUsage = 0;
//Log this event
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Total Disk Usage is set to 0");
msg.format(args);
ml.logWarningMessage(msg);
}
else
diskUsage = (usedBlocks / (totalBlocks / 100)) + 1;
SMSystemDisk sd;
sd.deviceName = deviceName;
sd.usedPercent = diskUsage;
sd.totalBlocks = totalBlocks;
sd.usedBlocks = usedBlocks;
sdl.push_back(sd);
if (DISK_DEBUG)
cout << "Disk Usage for " << deviceName << " is " << diskUsage << endl;
if (diskUsage >= localDiskCritical && localDiskCritical > 0 )
{
//adjust if over 100%
if ( diskUsage > 100 )
diskUsage = 100;
if ( serverMonitor.sendResourceAlarm(deviceName, DISK_USAGE_HIGH, SET, (int) diskUsage) )
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Local Disk above Critical Disk threshold with a percentage of ");
args.add((int) diskUsage);
msg.format(args);
ml.logInfoMessage(msg);
}
}
else if (diskUsage >= localDiskMajor && localDiskMajor > 0 )
{
if (serverMonitor.sendResourceAlarm(deviceName, DISK_USAGE_MED, SET, (int) diskUsage))
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Local Disk above Major Disk threshold with a percentage of ");
args.add((int) diskUsage);
msg.format(args);
ml.logInfoMessage(msg);
}
}
else if (diskUsage >= localDiskMinor && localDiskMinor > 0 )
{
if ( serverMonitor.sendResourceAlarm(deviceName, DISK_USAGE_LOW, SET, (int) diskUsage))
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Local Disk above Minor Disk threshold with a percentage of ");
args.add((int) diskUsage);
msg.format(args);
ml.logInfoMessage(msg);
}
}
else
serverMonitor.checkDiskAlarm(deviceName);
}
//check for external file systems/devices
if (Externalflag ||
(!Externalflag && DataRedundancyConfig == "y" && moduleType == "pm") )
{
try
{
DBRootConfigList dbrootConfigList;
oam.getPmDbrootConfig(moduleID, dbrootConfigList);
DBRootConfigList::iterator pt = dbrootConfigList.begin();
for ( ; pt != dbrootConfigList.end() ; pt++)
{
int dbroot = *pt;
string deviceName = systemConfig.DBRoot[dbroot - 1];
string fileName = deviceName + "/000.dir";
if (DISK_DEBUG)
{
//Log this event
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("DBRoots monitoring");
args.add(dbroot);
args.add(" ,file system =" );
args.add(fileName);
msg.format(args);
ml.logDebugMessage(msg);
}
uint64_t totalBlocks;
uint64_t usedBlocks;
if (!statvfs(fileName.c_str(), &buf))
{
uint64_t blksize, blocks, freeblks, free;
blksize = buf.f_bsize;
blocks = buf.f_blocks;
freeblks = buf.f_bavail;
totalBlocks = blocks * blksize;
free = freeblks * blksize;
usedBlocks = totalBlocks - free;
}
else
{
SMSystemDisk sd;
sd.deviceName = deviceName;
sd.usedPercent = 0;
sd.totalBlocks = 0;
sd.usedBlocks = 0;
sdl.push_back(sd);
continue;
}
int diskUsage = 0;
if ( totalBlocks == 0 )
{
diskUsage = 0;
//Log this event
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Total Disk Usage is set to 0");
msg.format(args);
ml.logWarningMessage(msg);
}
else
diskUsage = (usedBlocks / (totalBlocks / 100)) + 1;
SMSystemDisk sd;
sd.deviceName = deviceName;
sd.usedPercent = diskUsage;
sd.totalBlocks = totalBlocks;
sd.usedBlocks = usedBlocks;
sdl.push_back(sd);
if (DISK_DEBUG)
cout << "Disk Usage for " << deviceName << " is " << diskUsage << endl;
if (diskUsage >= ExternalDiskCritical && ExternalDiskCritical > 0 )
{
//adjust if over 100%
if ( diskUsage > 100 )
diskUsage = 100;
if ( serverMonitor.sendResourceAlarm(deviceName, DISK_USAGE_HIGH, SET, diskUsage))
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Disk usage for");
args.add(deviceName);
args.add(" above Critical Disk threshold with a percentage of ");
args.add((int) diskUsage);
msg.format(args);
ml.logInfoMessage(msg);
}
}
else if (diskUsage >= ExternalDiskMajor && ExternalDiskMajor > 0 )
{
if ( serverMonitor.sendResourceAlarm(deviceName, DISK_USAGE_MED, SET, diskUsage))
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Disk usage for");
args.add(deviceName);
args.add(" above Major Disk threshold with a percentage of ");
args.add((int) diskUsage);
msg.format(args);
ml.logInfoMessage(msg);
}
}
else if (diskUsage >= ExternalDiskMinor && ExternalDiskMinor > 0 )
{
if ( serverMonitor.sendResourceAlarm(deviceName, DISK_USAGE_LOW, SET, diskUsage))
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Disk usage for");
args.add(deviceName);
args.add(" above Minor Disk threshold with a percentage of ");
args.add((int) diskUsage);
msg.format(args);
ml.logInfoMessage(msg);
}
}
else
serverMonitor.checkDiskAlarm(deviceName);
}
}
catch (exception& e)
{
cout << endl << "**** getPmDbrootConfig Failed : " << e.what() << endl;
}
}
}
//check OAM dbroot test flag to validate dbroot exist if on pm
if ( moduleName.find("pm") != string::npos )
{
//check OAM dbroot test flag to validate dbroot exist
if ( dbrootList.size() != 0 )
{
DBrootList::iterator p = dbrootList.begin();
while ( p != dbrootList.end() )
{
//get dbroot directory
string dbrootDir = (*p).dbrootDir;
string dbrootName;
string dbrootID;
//get dbroot name
string::size_type pos = dbrootDir.rfind("/", 80);
if (pos != string::npos)
dbrootName = dbrootDir.substr(pos + 1, 80);
//get ID
dbrootID = dbrootName.substr(4, 80);
string fileName = dbrootDir + "/OAMdbrootCheck";
// retry in case we hit the remount window
for ( int retry = 0 ; ; retry++ )
{
bool fail = false;
//first test, check if OAMdbrootCheck exists
ifstream file (fileName.c_str());
if (!file)
fail = true;
else
fail = false;
if (fail)
{
//double check system status before reporting any error BUG 5078
SystemStatus systemstatus;
try
{
oam.getSystemStatus(systemstatus);
}
catch (exception& ex)
{}
if (systemstatus.SystemOpState != oam::ACTIVE )
{
break;
}
if ( retry < 10 )
{
sleep(3);
continue;
}
else
{
if ( !(*p).downFlag )
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("dbroot monitoring: Lost access to ");
args.add(dbrootDir);
msg.format(args);
ml.logWarningMessage(msg);
oam.sendDeviceNotification(dbrootName, DBROOT_DOWN, moduleName);
(*p).downFlag = true;
try
{
oam.setDbrootStatus(dbrootID, oam::AUTO_OFFLINE);
}
catch (exception& ex)
{}
break;
}
}
}
else
{
if ( (*p).downFlag )
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("dbroot monitoring: Access back to ");
args.add(dbrootDir);
msg.format(args);
ml.logInfoMessage(msg);
oam.sendDeviceNotification(dbrootName, DBROOT_UP, moduleName);
(*p).downFlag = false;
try
{
oam.setDbrootStatus(dbrootID, oam::ACTIVE);
}
catch (exception& ex)
{}
}
file.close();
break;
}
}
p++;
}
}
}
//do Gluster status check, if configured
if ( DataRedundancyConfig == "y")
{
bool pass = true;
string errmsg = "unknown";
try
{
string arg1 = "";
string arg2 = "";
int ret = oam.glusterctl(oam::GLUSTER_STATUS, arg1, arg2, errmsg);
if ( ret != 0 )
{
cerr << "FAILURE: Status check error: " + errmsg << endl;
pass = false;
}
}
catch (exception& e)
{
cerr << endl << "**** glusterctl API exception: " << e.what() << endl;
cerr << "FAILURE: Status check error" << endl;
pass = false;
}
catch (...)
{
cerr << endl << "**** glusterctl API exception: UNKNOWN" << endl;
cerr << "FAILURE: Status check error" << endl;
pass = false;
}
if ( !pass )
{
// issue log and alarm
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Gluster Status check failure error msg: ");
args.add(errmsg);
msg.format(args);
ml.logWarningMessage(msg);
serverMonitor.sendResourceAlarm(errmsg, GLUSTER_DISK_FAILURE, SET, 0);
}
}
// sleep 30 seconds
sleep(MONITOR_PERIOD / 3);
//check disk space every 10 minutes
diskSpaceCheck++;
if ( diskSpaceCheck >= 20 )
{
diskSpaceCheck = 0;
lfs.clear();
sdl.clear();
}
} // end of while loop
}
/******************************************************************************************
* @brief checkDiskAlarm
*
* purpose: check to see if an alarm(s) is set on Disk and clear if so
*
******************************************************************************************/
void ServerMonitor::checkDiskAlarm(string alarmItem, ALARMS alarmID)
{
Oam oam;
ServerMonitor serverMonitor;
// get current server name
string serverName;
oamModuleInfo_t st;
try
{
st = oam.getModuleInfo();
serverName = boost::get<0>(st);
}
catch (...)
{
serverName = "Unknown Server";
}
switch (alarmID)
{
case ALARM_NONE: // clear all alarms set if any found
if ( serverMonitor.checkActiveAlarm(DISK_USAGE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, DISK_USAGE_HIGH);
if ( serverMonitor.checkActiveAlarm(DISK_USAGE_MED, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, DISK_USAGE_MED);
if ( serverMonitor.checkActiveAlarm(DISK_USAGE_LOW, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, DISK_USAGE_LOW);
break;
case DISK_USAGE_LOW: // clear high and medium alarms set if any found
if ( serverMonitor.checkActiveAlarm(DISK_USAGE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, DISK_USAGE_HIGH);
if ( serverMonitor.checkActiveAlarm(DISK_USAGE_MED, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, DISK_USAGE_MED);
break;
case DISK_USAGE_MED: // clear high alarms set if any found
if ( serverMonitor.checkActiveAlarm(DISK_USAGE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, DISK_USAGE_HIGH);
break;
default: // none to clear
break;
} // end of switch
return;
}

View File

@ -1,269 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
* Copyright (C) 2016 MariaDB Corporation.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***************************************************************************
* $Id: hardwareMonitor.cpp 34 2006-09-29 21:13:54Z dhill $
*
* Author: David Hill
***************************************************************************/
#include "serverMonitor.h"
using namespace std;
using namespace oam;
using namespace alarmmanager;
using namespace logging;
using namespace servermonitor;
//using namespace procheartbeat;
extern string tmpDir;
/************************************************************************************************************
* @brief hardwareMonitor function
*
* purpose: Monitor Hardware and report problems
*
* Parses file generated by the ipmitool
*
* pattern = what it is | value | units | status | value 1 | value 2 | value 3 | value 4 | value 5 | value 6
* data(0) = what it is
* data(1) = value
* data(2) = units
* data(3) = status
* data(4)-data(9) = barrier values
* data(4) - low non-recoverable, i.e. fatal
* data(5) - low critical
* data(6) - low warning
* data(7) - high warning
* data(8) - high critical
* data(9) - high non-recoverable, i.e. fatal
*
************************************************************************************************************/
void hardwareMonitor(int IPMI_SUPPORT)
{
ServerMonitor serverMonitor;
string data[10];
string SensorName;
float SensorValue;
string Units;
string SensorStatus;
float lowFatal;
float lowCritical;
float lowWarning;
float highWarning;
float highCritical;
float highFatal;
char* p;
if ( IPMI_SUPPORT == 0)
{
string tmpharwareMonitor = tmpDir + "/harwareMonitor.txt";
string cmd = "ipmitool sensor list > > " + tmpharwareMonitor;
int returnCode = system(cmd.c_str());
if (returnCode)
{
// System error, Log this event
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Error running ipmitool sensor list!!!");
msg.format(args);
ml.logWarningMessage(msg);
while (TRUE)
sleep(10000);
}
}
else
{
while (TRUE)
sleep(10000);
}
// register for Heartbeat monitoring
/* try {
ProcHeartbeat procheartbeat;
procheartbeat.registerHeartbeat(HW_HEARTBEAT_ID);
}
catch (exception& ex)
{
string error = ex.what();
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("EXCEPTION ERROR on registerHeartbeat: ");
args.add(error);
msg.format(args);
ml.logErrorMessage(msg);
}
catch(...)
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("EXCEPTION ERROR on sendHeartbeat: Caught unknown exception!");
msg.format(args);
ml.logErrorMessage(msg);
}
*/
// loop forever reading the hardware status
while (TRUE)
{
// parse output file
ifstream File (tmpharwareMonitor);
if (!File)
{
// System error, Log this event
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Error opening harwareMonitor.txt!!!");
msg.format(args);
ml.logWarningMessage(msg);
sleep(300);
continue;
}
char line[200];
while (File.getline(line, 200))
{
// parse the line
int f = 0;
p = strtok(line, "|");
while (p)
{
data[f] = p;
data[f] = serverMonitor.StripWhitespace(data[f]);
p = strtok (NULL, "|");
f++;
}
if ( f == 0 )
// nothing on this line, skip
continue;
SensorName = data[0];
SensorValue = atof(data[1].c_str());
Units = data[2];
SensorStatus = data[3];
lowFatal = atof(data[4].c_str());
lowCritical = atof(data[5].c_str());
lowWarning = atof(data[6].c_str());
highWarning = atof(data[7].c_str());
highCritical = atof(data[8].c_str());
highFatal = atof(data[9].c_str());
// check status and issue apporiate alarm if needed
if ( (SensorStatus != "ok") && (SensorStatus != "nr") && (SensorStatus != "na") )
{
// Status error, check for warning or critical levels
if ( SensorValue >= highFatal )
{
// issue critical alarm and send message to shutdown Server
serverMonitor.sendAlarm(SensorName, HARDWARE_HIGH, SET, SensorValue);
serverMonitor.sendMsgShutdownServer();
}
else if ( (SensorValue < highFatal) && (SensorValue >= highCritical) )
// issue major alarm
serverMonitor.sendAlarm(SensorName, HARDWARE_MED, SET, SensorValue);
else if ( (SensorValue < highCritical ) && (SensorValue >= highWarning) )
// issue minor alarm
serverMonitor.sendAlarm(SensorName, HARDWARE_LOW, SET, SensorValue);
else if ( (SensorValue <= lowWarning) && (SensorValue > lowCritical) )
// issue minor alarm
serverMonitor.sendAlarm(SensorName, HARDWARE_LOW, SET, SensorValue);
else if ( (SensorValue <= lowCritical) && (SensorValue > lowFatal) )
// issue major alarm
serverMonitor.sendAlarm(SensorName, HARDWARE_MED, SET, SensorValue);
else if ( SensorValue <= lowFatal )
{
// issue critical alarm and send message to shutdown Server
serverMonitor.sendAlarm(SensorName, HARDWARE_HIGH, SET, SensorValue);
serverMonitor.sendMsgShutdownServer();
}
else
// check if there are any active alarms that needs to be cleared
serverMonitor.checkAlarm(SensorName);
}
else
// check if there are any active alarms that needs to be cleared
serverMonitor.checkAlarm(SensorName);
} //end of parsing file while
File.close();
// send heartbeat message
/* try {
ProcHeartbeat procheartbeat;
procheartbeat.sendHeartbeat(HW_HEARTBEAT_ID);
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Sent Heartbeat Msg");
msg.format(args);
ml.logDebugMessage(msg);
}
catch (exception& ex)
{
string error = ex.what();
if ( error.find("Disabled") == string::npos ) {
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("EXCEPTION ERROR on sendHeartbeat: ");
args.add(error);
msg.format(args);
ml.logErrorMessage(msg);
}
}
catch(...)
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("EXCEPTION ERROR on sendHeartbeat: Caught unknown exception!");
msg.format(args);
ml.logErrorMessage(msg);
}
*/
// sleep
sleep(MONITOR_PERIOD);
} //end of forever while loop
}

View File

@ -1,364 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
#include "IDBPolicy.h"
#include "serverMonitor.h"
#include "crashtrace.h"
#include "installdir.h"
using namespace std;
using namespace servermonitor;
using namespace oam;
using namespace logging;
extern int swapFlag;
string tmpDir;
/*****************************************************************************
* @brief main
*
* purpose: Launch Resource Monitor threads and call Hardware Monitor function
*
*
******************************************************************************/
int main (int argc, char** argv)
{
ServerMonitor serverMonitor;
Oam oam;
tmpDir = startup::StartUp::tmpDir();
struct sigaction ign;
memset(&ign, 0, sizeof(ign));
ign.sa_handler = fatalHandler;
sigaction(SIGSEGV, &ign, 0);
sigaction(SIGABRT, &ign, 0);
sigaction(SIGFPE, &ign, 0);
//Launch Memory Monitor Thread and check if swap is in critical condition
pthread_t memoryMonitorThread;
pthread_create (&memoryMonitorThread, NULL, (void* (*)(void*)) &memoryMonitor, NULL);
// initialize IDBPolicy while waiting swap flag being set.
idbdatafile::IDBPolicy::configIDBPolicy();
// wait until swap flag is set.
while ( swapFlag == 0 )
{
sleep(1);
}
if ( swapFlag == 1 )
{
try
{
oam.processInitFailure();
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("processInitFailure Called");
msg.format(args);
ml.logInfoMessage(msg);
sleep(5);
exit(1);
}
catch (exception& ex)
{
string error = ex.what();
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("EXCEPTION ERROR on processInitComplete: ");
args.add(error);
msg.format(args);
ml.logErrorMessage(msg);
sleep(5);
exit(1);
}
catch (...)
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("EXCEPTION ERROR on processInitComplete: Caught unknown exception!");
msg.format(args);
ml.logErrorMessage(msg);
sleep(5);
exit(1);
}
}
else
{
try
{
oam.processInitComplete("ServerMonitor");
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("processInitComplete Successfully Called");
msg.format(args);
ml.logInfoMessage(msg);
}
catch (exception& ex)
{
string error = ex.what();
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("EXCEPTION ERROR on processInitComplete: ");
args.add(error);
msg.format(args);
ml.logErrorMessage(msg);
}
catch (...)
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("EXCEPTION ERROR on processInitComplete: Caught unknown exception!");
msg.format(args);
ml.logErrorMessage(msg);
}
}
//Ignore SIGPIPE signals
signal(SIGPIPE, SIG_IGN);
//Ignore SIGHUP signals
signal(SIGHUP, SIG_IGN);
//get auto rsync setting
string umAutoSync = "n"; // default to 'n'
try
{
oam.getSystemConfig( "UMAutoSync", umAutoSync);
}
catch (...)
{
umAutoSync = "n";
}
oamModuleInfo_t t;
//get local module info
string localModuleName;
string localModuleType;
int serverInstallType = 2;
string OAMParentModuleName;
try
{
t = oam.getModuleInfo();
localModuleName = boost::get<0>(t);
localModuleType = boost::get<1>(t);
serverInstallType = boost::get<5>(t);
}
catch (...) {}
string SingleServerInstall = "n"; // default to 'n'
try
{
oam.getSystemConfig( "SingleServerInstall", SingleServerInstall);
}
catch (...)
{
SingleServerInstall = "n";
}
//Launch Rsync Thread, if needed
// run on first non-disabled user-module
// if combo um/pm configured a non single-server, then that is a pm
// if separate um / pm, then that is a um
bool launchUMAutoSync = false;
SystemStatus systemstatus;
if (umAutoSync == "y" )
{
if ( serverInstallType == oam::INSTALL_COMBINE_DM_UM_PM )
{
if ( SingleServerInstall != "y" )
{
//get first non-disabled pm
try
{
oam.getSystemStatus(systemstatus, false);
for ( unsigned int i = 0 ; i < systemstatus.systemmodulestatus.modulestatus.size(); i++)
{
if ( systemstatus.systemmodulestatus.modulestatus[i].Module.empty() )
// end of list
break;
string moduleName = systemstatus.systemmodulestatus.modulestatus[i].Module;
string moduleType = moduleName.substr(0, MAX_MODULE_TYPE_SIZE);
if ( moduleType == "pm" )
{
int state = systemstatus.systemmodulestatus.modulestatus[i].ModuleOpState;
if ( state == oam::MAN_DISABLED || state == oam::AUTO_DISABLED )
continue;
else
{
//module is enabled, runs if this is pm1 and only pm1, so it will not run
//if pm1 is down for an extented period of time
if ( moduleName == "pm1" )
{
if (localModuleName == "pm1" )
launchUMAutoSync = true;
break;
}
}
}
}
}
catch (...) {}
}
}
else
{
//get first non-disabled um
if ( localModuleType == "um" )
{
try
{
oam.getSystemStatus(systemstatus, false);
for ( unsigned int i = 0 ; i < systemstatus.systemmodulestatus.modulestatus.size(); i++)
{
if ( systemstatus.systemmodulestatus.modulestatus[i].Module.empty() )
// end of list
break;
string moduleName = systemstatus.systemmodulestatus.modulestatus[i].Module;
string moduleType = moduleName.substr(0, MAX_MODULE_TYPE_SIZE);
if ( moduleType == "um" )
{
int state = systemstatus.systemmodulestatus.modulestatus[i].ModuleOpState;
if ( state == oam::MAN_DISABLED || state == oam::AUTO_DISABLED )
continue;
else
{
//module is enabled, runs if this is um1 and only um1, so it will not run
//if um1 is down for an extented period of time
if ( moduleName == "um1" )
{
if (localModuleName == "um1" )
launchUMAutoSync = true;
break;
}
}
}
}
}
catch (...) {}
}
}
}
//wait until system is active before launching monitoring threads
while (true)
{
SystemStatus systemstatus;
try
{
oam.getSystemStatus(systemstatus);
}
catch (exception& ex)
{}
if (systemstatus.SystemOpState == oam::ACTIVE )
{
if (launchUMAutoSync)
{
//Launch UM Auto Sync Thread
pthread_t rsyncThread;
pthread_create (&rsyncThread, NULL, (void* (*)(void*)) &UMAutoSync, NULL);
}
//Launch CPU Monitor Thread
pthread_t cpuMonitorThread;
pthread_create (&cpuMonitorThread, NULL, (void* (*)(void*)) &cpuMonitor, NULL);
//Launch Disk Monitor Thread if it's not a storagemanager cluster
config::Config *_config = config::Config::makeConfig();
string storageType = _config->getConfig("Installation", "DBRootStorageType");
if (storageType != "storagemanager")
{
pthread_t diskMonitorThread;
pthread_create (&diskMonitorThread, NULL, (void* (*)(void*)) &diskMonitor, NULL);
}
//Launch DB Health Check Thread
// pthread_t dbhealthMonitorThread;
// pthread_create (&dbhealthMonitorThread, NULL, (void*(*)(void*)) &dbhealthMonitor, NULL);
//Call msg process request function
msgProcessor();
break;
}
sleep(5);
}
return 0;
}
// common functions
//
// Check Active alarms
//
// Use a mutex to limit the number of calls
//
pthread_mutex_t THREAD_LOCK;
bool ServerMonitor::checkActiveAlarm(const int alarmid, const std::string moduleName, const std::string deviceName)
{
Oam oam;
pthread_mutex_lock(&THREAD_LOCK);
bool status = oam.checkActiveAlarm(alarmid, moduleName, deviceName);
pthread_mutex_unlock(&THREAD_LOCK);
return status;
}

View File

@ -1,573 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***************************************************************************
* $Id: memoryMonitor.cpp 34 2006-09-29 21:13:54Z dhill $
*
* Author: Zhixuan Zhu
***************************************************************************/
#include "cgroupconfigurator.h"
#include "serverMonitor.h"
using namespace std;
using namespace oam;
using namespace alarmmanager;
using namespace logging;
using namespace servermonitor;
//using namespace procheartbeat;
ProcessMemoryList pml;
int swapFlag = 0;
uint64_t totalMem;
pthread_mutex_t MEMORY_LOCK;
extern string tmpDir;
/*****************************************************************************************
* @brief memoryMonitor Thread
*
* purpose: Get current Memory and Swap usage, report alarms
*
*****************************************************************************************/
void memoryMonitor()
{
ServerMonitor serverMonitor;
int swapUsagePercent = 0;
// set defaults
int memoryCritical = 90,
memoryMajor = 0,
memoryMinor = 0,
swapCritical = 90,
swapMajor = 80,
swapMinor = 70;
int day = 0;
//set monitoring period to 60 seconds
int monitorPeriod = MONITOR_PERIOD;
utils::CGroupConfigurator cg;
while (true)
{
// Get MEMORY usage water mark from server configuration and compare
ModuleTypeConfig moduleTypeConfig;
Oam oam;
try
{
oam.getSystemConfig (moduleTypeConfig);
memoryCritical = moduleTypeConfig.ModuleMemCriticalThreshold;
memoryMajor = moduleTypeConfig.ModuleMemMajorThreshold;
memoryMinor = moduleTypeConfig.ModuleMemMinorThreshold;
swapCritical = moduleTypeConfig.ModuleSwapCriticalThreshold;
swapMajor = moduleTypeConfig.ModuleSwapMajorThreshold;
swapMinor = moduleTypeConfig.ModuleSwapMinorThreshold;
}
catch (...)
{
sleep(5);
continue;
}
//get memory stats
totalMem = cg.getTotalMemory();
uint64_t freeMem = cg.getFreeMemory();
uint64_t usedMem = totalMem - freeMem;
//get swap stats
uint64_t totalSwap = cg.getTotalSwapSpace();
uint64_t usedSwap = cg.getSwapInUse();
if ( totalSwap == 0 )
{
swapUsagePercent = 0;
swapFlag = 2;
//get current day, log warning only once a day
time_t now;
now = time(NULL);
struct tm tm;
localtime_r(&now, &tm);
if ( day != tm.tm_mday)
{
day = tm.tm_mday;
//Log this event
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Total Swap space is set to 0");
msg.format(args);
ml.logWarningMessage(msg);
}
}
else
swapUsagePercent = usedSwap / (totalSwap / 100);
int memoryUsagePercent;
if ( totalMem == 0 )
{
memoryUsagePercent = 0;
//Log this event
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Total Memory space is set to 0");
msg.format(args);
ml.logWarningMessage(msg);
}
else
memoryUsagePercent = (usedMem / (totalMem / 100)) + 1;
/*LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("memoryUsagePercent ");
args.add((uint64_t) memoryUsagePercent);
args.add("usedMem ");
args.add((uint64_t) usedMem);
args.add("totalMem ");
args.add((uint64_t) totalMem);
msg.format(args);
ml.logInfoMessage(msg);
*/
//first time called, log
//adjust if over 100%
if ( swapUsagePercent < 0 )
swapUsagePercent = 0;
if ( swapUsagePercent > 100 )
swapUsagePercent = 100;
if ( memoryUsagePercent < 0 )
memoryUsagePercent = 0;
if ( memoryUsagePercent > 100 )
memoryUsagePercent = 100;
// check for Memory alarms
if (memoryUsagePercent >= memoryCritical && memoryCritical > 0 )
{
if ( monitorPeriod == MONITOR_PERIOD )
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Local Memory above Critical Memory threshold with a percentage of ");
args.add((int) memoryUsagePercent);
args.add(" ; Swap ");
args.add((int) swapUsagePercent);
msg.format(args);
ml.logInfoMessage(msg);
serverMonitor.sendResourceAlarm("Local-Memory", MEMORY_USAGE_HIGH, SET, memoryUsagePercent);
pthread_mutex_lock(&MEMORY_LOCK);
serverMonitor.outputProcMemory(true);
pthread_mutex_unlock(&MEMORY_LOCK);
}
// change to 1 second for quick swap space monitoring
monitorPeriod = 1;
}
else if (memoryUsagePercent >= memoryMajor && memoryMajor > 0 )
{
monitorPeriod = MONITOR_PERIOD;
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Local Memory above Major Memory threshold with a percentage of ");
args.add((int) memoryUsagePercent);
msg.format(args);
ml.logInfoMessage(msg);
serverMonitor.sendResourceAlarm("Local-Memory", MEMORY_USAGE_MED, SET, memoryUsagePercent);
}
else if (memoryUsagePercent >= memoryMinor && memoryMinor > 0 )
{
monitorPeriod = MONITOR_PERIOD;
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Local Memory above Minor Memory threshold with a percentage of ");
args.add((int) memoryUsagePercent);
msg.format(args);
ml.logInfoMessage(msg);
serverMonitor.sendResourceAlarm("Local-Memory", MEMORY_USAGE_LOW, SET, memoryUsagePercent);
}
else
{
monitorPeriod = MONITOR_PERIOD;
serverMonitor.checkMemoryAlarm("Local-Memory");
}
// check for Swap alarms
if (swapUsagePercent >= swapCritical && swapCritical > 0 )
{
//adjust if over 100%
if ( swapUsagePercent > 100 )
swapUsagePercent = 100;
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Swap above Critical Memory threshold with a percentage of ");
args.add((int) swapUsagePercent);
msg.format(args);
ml.logInfoMessage(msg);
serverMonitor.sendResourceAlarm("Swap", SWAP_USAGE_HIGH, SET, swapUsagePercent);
serverMonitor.checkSwapAction();
}
else if (swapUsagePercent >= swapMajor && swapMajor > 0 )
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Swap above Major Memory threshold with a percentage of ");
args.add((int) swapUsagePercent);
msg.format(args);
ml.logInfoMessage(msg);
serverMonitor.sendResourceAlarm("Swap", SWAP_USAGE_MED, SET, swapUsagePercent);
serverMonitor.checkSwapAction();
}
else if (swapUsagePercent >= swapMinor && swapMinor > 0 )
{
swapFlag = 2;
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Swap above Minor Memory threshold with a percentage of ");
args.add((int) swapUsagePercent);
msg.format(args);
ml.logInfoMessage(msg);
serverMonitor.sendResourceAlarm("Swap", SWAP_USAGE_LOW, SET, swapUsagePercent);
}
else
{
swapFlag = 2;
serverMonitor.checkSwapAlarm("Swap");
}
// sleep, 1 minute
sleep(monitorPeriod);
} // end of while loop
}
/******************************************************************************************
* @brief checkMemoryAlarm
*
* purpose: check to see if an alarm(s) is set on MEMORY and clear if so
*
******************************************************************************************/
void ServerMonitor::checkMemoryAlarm(string alarmItem, ALARMS alarmID)
{
Oam oam;
ServerMonitor serverMonitor;
// get current server name
string serverName;
oamModuleInfo_t st;
try
{
st = oam.getModuleInfo();
serverName = boost::get<0>(st);
}
catch (...)
{
serverName = "Unknown Server";
}
switch (alarmID)
{
case ALARM_NONE: // clear all alarms set if any found
if ( serverMonitor.checkActiveAlarm(MEMORY_USAGE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, MEMORY_USAGE_HIGH);
if ( serverMonitor.checkActiveAlarm(MEMORY_USAGE_MED, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, MEMORY_USAGE_MED);
if ( serverMonitor.checkActiveAlarm(MEMORY_USAGE_LOW, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, MEMORY_USAGE_LOW);
break;
case MEMORY_USAGE_LOW: // clear high and medium alarms set if any found
if ( serverMonitor.checkActiveAlarm(MEMORY_USAGE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, MEMORY_USAGE_HIGH);
if ( serverMonitor.checkActiveAlarm(MEMORY_USAGE_MED, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, MEMORY_USAGE_MED);
break;
case MEMORY_USAGE_MED: // clear high alarms set if any found
if ( serverMonitor.checkActiveAlarm(MEMORY_USAGE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, MEMORY_USAGE_HIGH);
break;
default: // none to clear
break;
} // end of switch
return;
}
/******************************************************************************************
* @brief checkSwapAlarm
*
* purpose: check to see if an alarm(s) is set on SWAP and clear if so
*
******************************************************************************************/
void ServerMonitor::checkSwapAlarm(string alarmItem, ALARMS alarmID)
{
Oam oam;
ServerMonitor serverMonitor;
// get current server name
string serverName;
oamModuleInfo_t st;
try
{
st = oam.getModuleInfo();
serverName = boost::get<0>(st);
}
catch (...)
{
serverName = "Unknown Server";
}
switch (alarmID)
{
case ALARM_NONE: // clear all alarms set if any found
if ( serverMonitor.checkActiveAlarm(SWAP_USAGE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, SWAP_USAGE_HIGH);
if ( serverMonitor.checkActiveAlarm(SWAP_USAGE_MED, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, SWAP_USAGE_MED);
if ( serverMonitor.checkActiveAlarm(SWAP_USAGE_LOW, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, SWAP_USAGE_LOW);
break;
case SWAP_USAGE_LOW: // clear high and medium alarms set if any found
if ( serverMonitor.checkActiveAlarm(SWAP_USAGE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, SWAP_USAGE_HIGH);
if ( serverMonitor.checkActiveAlarm(SWAP_USAGE_MED, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, SWAP_USAGE_MED);
break;
case SWAP_USAGE_MED: // clear high alarms set if any found
if ( serverMonitor.checkActiveAlarm(SWAP_USAGE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, SWAP_USAGE_HIGH);
break;
default: // none to clear
break;
} // end of switch
return;
}
/******************************************************************************************
* @brief checkSwapAction
*
* purpose: check if any system action needs tyo be taken
*
******************************************************************************************/
void ServerMonitor::checkSwapAction()
{
Oam oam;
if ( swapFlag == 0 )
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Swap Space usage over Major threashold, startSystem failure");
msg.format(args);
ml.logCriticalMessage(msg);
swapFlag = 1;
sleep(5);
return;
}
string swapAction = "restartSystem";
try
{
oam.getSystemConfig ("SwapAction", swapAction);
}
catch (...)
{}
if (swapAction == "none")
return;
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Swap Space usage over Major threashold, perform OAM command ");
args.add( swapAction);
msg.format(args);
ml.logCriticalMessage(msg);
GRACEFUL_FLAG gracefulTemp = GRACEFUL;
ACK_FLAG ackTemp = ACK_YES;
if ( swapAction == "stopSystem")
{
try
{
oam.stopSystem(gracefulTemp, ackTemp);
}
catch (exception& e)
{
}
}
else if ( swapAction == "restartSystem")
{
try
{
oam.restartSystem(gracefulTemp, ackTemp);
}
catch (exception& e)
{
}
}
}
/******************************************************************************************
* @brief outputProcMemory
*
* purpose: output Top memory users
*
******************************************************************************************/
void ServerMonitor::outputProcMemory(bool log)
{
//
// get top 5 Memory users by process
//
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 (tmpprocessMem.c_str());
string process;
long long memory;
int memoryUsage;
pml.clear();
char line[400];
while (oldFile.getline(line, 400))
{
string buf = line;
string::size_type pos = buf.find (' ', 0);
if (pos != string::npos)
{
memory = atol(buf.substr(0, pos - 1).c_str());
memoryUsage = (memory * 1024 * 1000 / totalMem) + 1 ;
process = buf.substr(pos + 1, 80);
//cleanup process name
pos = process.rfind ('/');
if (pos != string::npos)
process = process.substr(pos + 1, 80);
else
{
pos = process.find ('[', 0);
if (pos != string::npos)
process = process.substr(pos + 1, 80);
pos = process.find (']', 0);
if (pos != string::npos)
process = process.substr(0, pos);
}
processMemory pm;
pm.processName = process;
pm.usedBlocks = memory;
pm.usedPercent = memoryUsage;
pml.push_back(pm);
if (log)
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Memory Usage for Process: ");
args.add(process);
args.add(" : Memory Used ");
args.add((int) memory);
args.add(" : % Used ");
args.add(memoryUsage);
msg.format(args);
ml.logInfoMessage(msg);
}
}
}
oldFile.close();
}

View File

@ -1,693 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***************************************************************************
* $Id: msgProcessor.cpp 34 2006-09-29 21:13:54Z dhill $
*
* Author: David Hill
***************************************************************************/
#include "serverMonitor.h"
using namespace std;
using namespace oam;
using namespace messageqcpp;
using namespace logging;
using namespace servermonitor;
using namespace config;
extern float currentCpuUsage;
extern unsigned long totalMem;
extern SystemDiskList sdl;
extern ProcessCPUList pcl;
extern ProcessMemoryList pml;
extern pthread_mutex_t CPU_LOCK;
extern pthread_mutex_t MEMORY_LOCK;
extern string tmpDir;
/**
* constants define
*/
struct PendingSQLStatement
{
string sqlStatement;
time_t startTime;
};
/*****************************************************************************************
* @brief msgProcessor Thread
*
* purpose: Process incoming message request
*
*****************************************************************************************/
void msgProcessor()
{
ServerMonitor serverMonitor;
Oam oam;
ByteStream msg;
IOSocket fIos;
string name[5];
double usage[5];
bool DBhealthActive = false;
// get current server name
string moduleName;
oamModuleInfo_t st;
try
{
st = oam.getModuleInfo();
moduleName = boost::get<0>(st);
}
catch (...)
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Failed to get Module Name");
msg.format(args);
ml.logErrorMessage(msg);
moduleName = "Unknown Server";
}
string msgPort = moduleName + "_ServerMonitor";
//read and cleanup port before trying to use
try
{
Config* sysConfig = Config::makeConfig();
string port = sysConfig->getConfig(msgPort, "Port");
string cmd = "fuser -k " + port + "/tcp >/dev/null 2>&1";
//int user;
//user = getuid();
system(cmd.c_str());
}
catch (...)
{
}
for (;;)
{
try
{
MessageQueueServer mqs(msgPort);
for (;;)
{
try
{
fIos = mqs.accept();
msg = fIos.read();
if (msg.length() > 0)
{
ByteStream::byte requestType;
msg >> requestType;
switch (requestType)
{
case GET_PROC_CPU_USAGE:
{
ByteStream::byte top_users;
ByteStream ackmsg;
msg >> top_users;
int count = 0;
//
// get Process and System CPU usage
//
pthread_mutex_lock(&CPU_LOCK);
serverMonitor.getCPUdata();
ProcessCPUList::iterator p = pcl.begin();
while (p != pcl.end())
{
double cpuUsage = (*p).usedPercent;
if ( cpuUsage != 0 )
{
usage[count] = cpuUsage;
name[count] = (*p).processName;
count++;
}
p++;
}
// if all processes are idle, puch the first one for display
if ( count == 0 )
{
p = pcl.begin();
usage[count] = (*p).usedPercent;
name[count] = (*p).processName;
count++;
}
pthread_mutex_unlock(&CPU_LOCK);
if ( count < top_users )
ackmsg << (ByteStream::byte) count;
else
ackmsg << (ByteStream::byte) top_users;
// output top requested processes
for (int i = 0 ; i < count ; i++)
{
ackmsg << name[i];
ackmsg << (ByteStream::quadbyte) usage[i];
if ( i == top_users )
break;
}
fIos.write(ackmsg);
ackmsg.reset();
}
break;
case GET_MODULE_CPU_USAGE:
{
ByteStream ackmsg;
//
// get Process and System CPU usage
//
pthread_mutex_lock(&CPU_LOCK);
serverMonitor.getCPUdata();
ackmsg << (ByteStream::byte) currentCpuUsage;
pthread_mutex_unlock(&CPU_LOCK);
fIos.write(ackmsg);
ackmsg.reset();
}
break;
case GET_PROC_MEMORY_USAGE:
{
ByteStream ackmsg;
ByteStream::byte top_users;
msg >> top_users;
//
// get top Memory users by process
//
pthread_mutex_lock(&MEMORY_LOCK);
serverMonitor.outputProcMemory(false);
ackmsg << (ByteStream::byte) pml.size();
ProcessMemoryList::iterator p = pml.end();
while (p != pml.begin())
{
p--;
ackmsg << (*p).processName;
ackmsg << (ByteStream::quadbyte) (*p).usedBlocks;
ackmsg << (ByteStream::byte) (*p).usedPercent;
}
pthread_mutex_unlock(&MEMORY_LOCK);
fIos.write(ackmsg);
ackmsg.reset();
}
break;
case GET_MODULE_MEMORY_USAGE:
{
//
// get Module Memory/Swap usage
//
ByteStream ackmsg;
// get cache MEMORY stats
string tmpcached = tmpDir + "/cached";
string cmd = "cat /proc/meminfo | grep Cached -m 1 | awk '{print $2}' > " + tmpcached;
system(cmd.c_str());
ifstream oldFile (tmpcached.c_str());
string strCache;
long long cache;
char line[400];
while (oldFile.getline(line, 400))
{
strCache = line;
break;
}
oldFile.close();
if (strCache.empty() )
cache = 0;
else
cache = atol(strCache.c_str()) * 1024;
struct sysinfo myinfo;
sysinfo(&myinfo);
//get memory stats
unsigned long mem_total = myinfo.totalram ;
unsigned long freeMem = myinfo.freeram ;
// adjust for cache, which is available memory
unsigned long mem_used = mem_total - freeMem - cache;
//get swap stats
unsigned long swap_total = myinfo.totalswap ;
unsigned long freeswap = myinfo.freeswap ;
unsigned long swap_used = swap_total - freeswap ;
unsigned int memoryUsagePercent;
memoryUsagePercent = (mem_used / (mem_total / 100));
unsigned int swapUsagePercent;
if ( swap_total == 0 )
swapUsagePercent = 0;
else
swapUsagePercent = (swap_used / (swap_total / 100));
ackmsg << (ByteStream::quadbyte) (mem_total / 1024);
ackmsg << (ByteStream::quadbyte) (mem_used / 1024);
ackmsg << (ByteStream::quadbyte) (cache / 1024);
ackmsg << (ByteStream::byte) memoryUsagePercent;
ackmsg << (ByteStream::quadbyte) (swap_total / 1024);
ackmsg << (ByteStream::quadbyte) (swap_used / 1024);
ackmsg << (ByteStream::byte) swapUsagePercent;
fIos.write(ackmsg);
ackmsg.reset();
}
break;
case GET_MODULE_DISK_USAGE:
{
//
// get Module Disk usage
//
ByteStream ackmsg;
ackmsg << (ByteStream::byte) sdl.size();
SystemDiskList::iterator p = sdl.begin();
while (p != sdl.end())
{
ackmsg << (*p).deviceName;
//ackmsg << (ByteStream::quadbyte) ((*p).totalBlocks / 1024) ;
//ackmsg << (ByteStream::quadbyte) ((*p).usedBlocks / 1024);
//ackmsg << (ByteStream::byte) (*p).usedPercent;
ackmsg << (uint64_t) ((*p).totalBlocks / 1024) ;
ackmsg << (uint64_t) ((*p).usedBlocks / 1024);
ackmsg << (uint8_t) (*p).usedPercent;
p++;
}
fIos.write(ackmsg);
ackmsg.reset();
}
break;
case GET_ACTIVE_SQL_QUERY:
{
//
// get Active SQL Query
// determined from UM debug.log file
//
map<uint64_t, PendingSQLStatement> pendingSQLStatements;
map<uint64_t, PendingSQLStatement>::iterator pendingIter;
ByteStream ackmsg;
char line[15100];
char* pos;
uint64_t currentSessionID;
const char* szStartSql = "Start SQL statement";
const char* szEndSql = "End SQL statement";
time_t rawtime;
struct tm tmStartTime;
time_t moduleStartTime = 0;
time_t queryStartTime = 0;
string fileName = "/var/log/mariadb/columnstore/debug.log";
try
{
// Get ServerMonitor start time. We don't report any SQL that started before then.
Oam oam;
ProcessStatus procstat;
oam.getProcessStatus("ExeMgr", moduleName, procstat);
if (strptime((procstat.StateChangeDate).c_str(), "%a %b %d %H:%M:%S %Y", &tmStartTime) != NULL)
{
tmStartTime.tm_isdst = -1;
moduleStartTime = mktime(&tmStartTime);
}
cout << "UM start time " << moduleStartTime << endl;
// Open the Calpont debug.log file
ifstream file (fileName.c_str());
if (!file)
{
try
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("File open error: ");
args.add(fileName);
msg.format(args);
ml.logErrorMessage(msg);
}
catch (...)
{}
ackmsg << (ByteStream::byte) oam::API_FILE_OPEN_ERROR;
fIos.write(ackmsg);
break;
}
ackmsg << (ByteStream::byte) oam::API_SUCCESS;
// Read the file. Filter out anything we don't care about. Store
// each SQL Start statement. When a SQL End statement is found, remove the
// corresponding SQL statement from the collection.
while (file.good())
{
file.getline(line, 15100, '\n');
pos = strstr(line, szStartSql);
if (pos)
{
//filter out System Catalog inqueries
if (strstr(pos + 21, "/FE") || strstr(pos + 21, "/EC"))
{
continue;
}
// Filter any query that started before the ServerMonitor
if (strptime(line, "%b %d %H:%M:%S", &tmStartTime) != NULL)
{
// The date in the debug.log file doesn't have a year.
// Assume the start time is no more than a year ago.
struct tm tmNow;
tmStartTime.tm_isdst = -1;
time ( &rawtime );
localtime_r ( &rawtime, &tmNow );
// Allow for New year turnover
if (tmStartTime.tm_mon > tmNow.tm_mon)
{
tmStartTime.tm_year = tmNow.tm_year - 1;
}
else
{
tmStartTime.tm_year = tmNow.tm_year;
}
queryStartTime = mktime(&tmStartTime);
// Ignore if the query started before this process
if (queryStartTime < moduleStartTime)
{
continue;
}
}
else
{
continue;
}
// Find the sessionid
char* pos1;
char* pos2;
pos1 = strchr(line, '|');
if (!pos1)
{
continue;
}
pos2 = strchr(pos1 + 1, '|');
if (!pos2)
{
continue;
}
currentSessionID = strtoll(pos1 + 1, NULL, 0);
// Check the map for this sessionid. If found, we have two pending
// SQL statements from the same session, which is theoretically
// impossible. Throw the first one away for now. Error handling?
if ((pendingIter = pendingSQLStatements.find(currentSessionID)) != pendingSQLStatements.end())
{
pendingSQLStatements.erase(pendingIter);
}
PendingSQLStatement pendingSQLStatement;
pendingSQLStatement.sqlStatement = pos + 21;
pendingSQLStatement.startTime = queryStartTime;
pair<int64_t, PendingSQLStatement> sqlPair;
sqlPair.first = currentSessionID;
sqlPair.second = pendingSQLStatement;
pendingSQLStatements.insert(sqlPair);
}
else
{
pos = strstr(line, szEndSql);
if (pos)
{
// Find the sessionid
char* pos1;
char* pos2;
pos1 = strchr(line, '|');
if (!pos1)
{
continue;
}
pos2 = strchr(pos1 + 1, '|');
if (!pos2)
{
continue;
}
currentSessionID = strtoll(pos1 + 1, NULL, 0);
// Check the map for this sessionid. If found, this is a completed SQL statement
// remove it from our collection
if ((pendingIter = pendingSQLStatements.find(currentSessionID)) != pendingSQLStatements.end())
{
pendingSQLStatements.erase(pendingIter);
}
}
}
}
file.close();
// Send the number of pending statements
ackmsg << (ByteStream::byte) pendingSQLStatements.size();
// Send the pending statements we discovered.
for (pendingIter = pendingSQLStatements.begin();
pendingIter != pendingSQLStatements.end();
++pendingIter)
{
ackmsg << (*pendingIter).second.sqlStatement;
ackmsg << (unsigned)(*pendingIter).second.startTime;
ackmsg << (*pendingIter).first;
}
}
catch (...)
{
}
fIos.write(ackmsg);
ackmsg.reset();
}
break;
case RUN_DBHEALTH_CHECK:
{
ByteStream::byte action;
msg >> action;
ByteStream ackmsg;
ackmsg << (ByteStream::byte) RUN_DBHEALTH_CHECK;
try
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("RUN_DBHEALTH_CHECK called");
msg.format(args);
ml.logDebugMessage(msg);
}
catch (...)
{}
if ( DBhealthActive )
{
try
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("RUN_DBHEALTH_CHECK already Active, exiting");
msg.format(args);
ml.logDebugMessage(msg);
}
catch (...)
{}
ackmsg << (ByteStream::byte) oam::API_ALREADY_IN_PROGRESS;
fIos.write(ackmsg);
ackmsg.reset();
break;
}
DBhealthActive = true;
int ret = serverMonitor.healthCheck(action);
if ( ret == API_SUCCESS )
{
try
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("RUN_DBHEALTH_CHECK passed");
msg.format(args);
ml.logDebugMessage(msg);
}
catch (...)
{}
ackmsg << (ByteStream::byte) oam::API_SUCCESS;
fIos.write(ackmsg);
ackmsg.reset();
}
else
{
try
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("RUN_DBHEALTH_CHECK failed, check dbhealthTest.log");
msg.format(args);
ml.logDebugMessage(msg);
}
catch (...)
{}
ackmsg << (ByteStream::byte) oam::API_FAILURE;
fIos.write(ackmsg);
ackmsg.reset();
}
DBhealthActive = false;
break;
}
default:
break;
} // end of switch
}
try
{
fIos.close();
}
catch (...)
{}
}
catch (...)
{}
} // end of for loop
}
catch (exception& ex)
{
string error = ex.what();
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("EXCEPTION ERROR on ServerMonitor: ");
args.add(error);
msg.format(args);
ml.logErrorMessage(msg);
// takes 2 - 4 minites to free sockets, sleep and retry
sleep(10);
}
catch (...)
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("EXCEPTION ERROR on ServerMonitor");
msg.format(args);
ml.logErrorMessage(msg);
// takes 2 - 4 minites to free sockets, sleep and retry
sleep(10);
}
}
}

View File

@ -1,193 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***************************************************************************
* $Id: procmonMonitor.cpp 34 2006-09-29 21:13:54Z dhill $
*
* Author: David Hill
***************************************************************************/
#include "serverMonitor.h"
using namespace std;
using namespace oam;
using namespace alarmmanager;
using namespace logging;
using namespace servermonitor;
using namespace messageqcpp;
/************************************************************************************************************
* @brief procmonMonitor function
*
* purpose: Monitor Local Process Monitor (like a local heartbeat check) abd reset when it's not responding
*
*
************************************************************************************************************/
void procmonMonitor()
{
ServerMonitor serverMonitor;
Oam oam;
//wait before monitoring is started
sleep(60);
// get current server name
string moduleName;
oamModuleInfo_t st;
try
{
st = oam.getModuleInfo();
moduleName = boost::get<0>(st);
}
catch (...)
{
// Critical error, Log this event and exit
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Failed to read local module Info");
msg.format(args);
ml.logCriticalMessage(msg);
exit(-1);
}
string msgPort = moduleName + "_ProcessMonitor";
int heartbeatCount = 0;
// loop forever monitoring Local Process Monitor
while (true)
{
ByteStream msg;
ByteStream::byte requestID = LOCALHEARTBEAT;
msg << requestID;
try
{
MessageQueueClient mqRequest(msgPort);
mqRequest.write(msg);
// wait 10 seconds for response
ByteStream::byte returnACK;
ByteStream::byte returnRequestID;
ByteStream::byte requestStatus;
ByteStream receivedMSG;
struct timespec ts = { 10, 0 };
try
{
receivedMSG = mqRequest.read(&ts);
if (receivedMSG.length() > 0)
{
receivedMSG >> returnACK;
receivedMSG >> returnRequestID;
receivedMSG >> requestStatus;
if ( returnACK == oam::ACK && returnRequestID == requestID)
{
// ACK for this request
heartbeatCount = 0;
}
}
else
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: ProcMon Msg timeout!!!");
msg.format(args);
ml.logWarningMessage(msg);
heartbeatCount++;
if ( heartbeatCount > 2 )
{
//Process Monitor not responding, restart it
system("pkill ProcMon");
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: Restarting ProcMon");
msg.format(args);
ml.logWarningMessage(msg);
sleep(60);
heartbeatCount = 0;
}
}
mqRequest.shutdown();
}
catch (SocketClosed& ex)
{
string error = ex.what();
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: EXCEPTION ERROR on mqRequest.read: " + error);
msg.format(args);
ml.logErrorMessage(msg);
}
catch (...)
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: EXCEPTION ERROR on mqRequest.read: Caught unknown exception");
msg.format(args);
ml.logErrorMessage(msg);
}
}
catch (exception& ex)
{
string error = ex.what();
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: EXCEPTION ERROR on MessageQueueClient.read: " + error);
msg.format(args);
ml.logErrorMessage(msg);
}
catch (...)
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: EXCEPTION ERROR on MessageQueueClient: Caught unknown exception");
msg.format(args);
ml.logErrorMessage(msg);
}
sleep(60);
} //while loop
}

View File

@ -1,369 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
* Copyright (C) 2016 MariaDB Corporation.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***************************************************************************
* $Id: serverMonitor.cpp 34 2006-09-29 21:13:54Z dhill $
*
* Author: David Hill
***************************************************************************/
#include "serverMonitor.h"
#include "installdir.h"
using namespace std;
using namespace oam;
using namespace alarmmanager;
using namespace logging;
using namespace servermonitor;
namespace servermonitor
{
/******************************************************************************************
* @brief ServerMonitor Constructor
*
* purpose: ServerMonitor Constructor
*
******************************************************************************************/
ServerMonitor::ServerMonitor()
{
}
/******************************************************************************************
* @brief ServerMonitor Destructor
*
* purpose: ServerMonitor Destructor
*
******************************************************************************************/
ServerMonitor::~ServerMonitor()
{
}
/******************************************************************************************
* @brief sendAlarm
*
* purpose: send a trap and log the process information
*
******************************************************************************************/
void ServerMonitor::sendAlarm(string alarmItem, ALARMS alarmID, int action, float sensorValue)
{
ServerMonitor serverMonitor;
Oam oam;
//Log this event
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add(alarmItem);
args.add(", sensor value out-of-range: ");
args.add(sensorValue);
// get current server name
string moduleName;
oamModuleInfo_t st;
try
{
st = oam.getModuleInfo();
moduleName = boost::get<0>(st);
}
catch (...)
{
moduleName = "Unknown Server";
}
// check if there is an active alarm above the reporting theshold
// that needs to be cleared
serverMonitor.checkAlarm(alarmItem, alarmID);
// check if Alarm is already active, don't resend
if ( !( oam.checkActiveAlarm(alarmID, moduleName, alarmItem)) )
{
ALARMManager alarmMgr;
// send alarm
alarmMgr.sendAlarmReport(alarmItem.c_str(), alarmID, action);
args.add(", Alarm set: ");
args.add(alarmID);
}
// output log
msg.format(args);
ml.logWarningMessage(msg);
return;
}
/******************************************************************************************
* @brief checkAlarm
*
* purpose: check to see if an alarm(s) is set on device and clear if so
*
******************************************************************************************/
void ServerMonitor::checkAlarm(string alarmItem, ALARMS alarmID)
{
Oam oam;
// get current server name
string moduleName;
oamModuleInfo_t st;
try
{
st = oam.getModuleInfo();
moduleName = boost::get<0>(st);
}
catch (...)
{
moduleName = "Unknown Server";
}
switch (alarmID)
{
case ALARM_NONE: // clear all alarms set if any found
if ( oam.checkActiveAlarm(HARDWARE_HIGH, moduleName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, HARDWARE_HIGH);
if ( oam.checkActiveAlarm(HARDWARE_MED, moduleName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, HARDWARE_MED);
if ( oam.checkActiveAlarm(HARDWARE_LOW, moduleName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, HARDWARE_LOW);
break;
case HARDWARE_LOW: // clear high and medium alarms set if any found
if ( oam.checkActiveAlarm(HARDWARE_HIGH, moduleName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, HARDWARE_HIGH);
if ( oam.checkActiveAlarm(HARDWARE_MED, moduleName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, HARDWARE_MED);
break;
case HARDWARE_MED: // clear high alarms set if any found
if ( oam.checkActiveAlarm(HARDWARE_HIGH, moduleName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, HARDWARE_HIGH);
break;
default: // none to clear
break;
} // end of switch
return;
}
/******************************************************************************************
* @brief clearAlarm
*
* purpose: clear Alarm that was previously set
*
******************************************************************************************/
void ServerMonitor::clearAlarm(string alarmItem, ALARMS alarmID)
{
ALARMManager alarmMgr;
alarmMgr.sendAlarmReport(alarmItem.c_str(), alarmID, CLEAR);
//Log this event
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add(alarmItem);
args.add(" alarm #");
args.add(alarmID);
args.add("cleared");
msg.format(args);
ml.logWarningMessage(msg);
}
/******************************************************************************************
* @brief sendMsgShutdownServer
*
* purpose: send a Message to Shutdown server
*
******************************************************************************************/
/*void ServerMonitor::sendMsgShutdownServer()
{
Oam oam;
//Log this event
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("serverMonitor: Fatal Hardware Alarm detected, Server being shutdown");
msg.format(args);
ml.logCriticalMessage(msg);
string moduleName;
oamModuleInfo_t st;
try {
st = oam.getModuleInfo();
moduleName = boost::get<0>(st);
}
catch (...) {
// o well, let's take out own action
system("init 0");
}
try
{
oam.shutdownModule(moduleName, FORCEFUL, ACK_NO);
}
catch (exception& e)
{
// o well, let's take out own action
system("init 0");
}
}
*/
/******************************************************************************************
* @brief StripWhitespace
*
* purpose: strip off whitespaces from a string
*
******************************************************************************************/
string ServerMonitor::StripWhitespace(string value)
{
for (;;)
{
string::size_type pos = value.find (' ', 0);
if (pos == string::npos)
// no more found
break;
// strip leading
if (pos == 0)
{
value = value.substr (pos + 1, 10000);
}
else
{
// strip trailing
value = value.substr (0, pos);
}
}
return value;
}
/******************************************************************************************
* @brief sendResourceAlarm
*
* purpose: send a trap and log the process information
*
******************************************************************************************/
bool ServerMonitor::sendResourceAlarm(string alarmItem, ALARMS alarmID, int action, int usage)
{
ServerMonitor serverMonitor;
Oam oam;
//Log this event
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add(alarmItem);
args.add(" usage at percentage of ");
args.add(usage);
// get current module name
string moduleName;
oamModuleInfo_t st;
try
{
st = oam.getModuleInfo();
moduleName = boost::get<0>(st);
}
catch (...)
{
moduleName = "Unknown Server";
}
// check if there is an active alarm above the reporting theshold
// that needs to be cleared
if (alarmItem == "CPU")
serverMonitor.checkCPUAlarm(alarmItem, alarmID);
else if (alarmItem == "Local Disk" || alarmItem == "External")
serverMonitor.checkDiskAlarm(alarmItem, alarmID);
else if (alarmItem == "Local Memory")
serverMonitor.checkMemoryAlarm(alarmItem, alarmID);
else if (alarmItem == "Local Swap")
serverMonitor.checkSwapAlarm(alarmItem, alarmID);
// don't issue an alarm on thge dbroots is already issued by this or another server
if ( alarmItem.find("/var/lib/columnstore/data") == 0 )
{
// check if Alarm is already active from any module, don't resend
if ( !( oam.checkActiveAlarm(alarmID, "*", alarmItem)) )
{
ALARMManager alarmMgr;
// send alarm
alarmMgr.sendAlarmReport(alarmItem.c_str(), alarmID, action);
args.add(", Alarm set: ");
args.add(alarmID);
msg.format(args);
ml.logInfoMessage(msg);
return true;
}
else
return false;
}
else
{
// check if Alarm is already active from this module, don't resend
if ( !( oam.checkActiveAlarm(alarmID, moduleName, alarmItem)) )
{
ALARMManager alarmMgr;
// send alarm
alarmMgr.sendAlarmReport(alarmItem.c_str(), alarmID, action);
args.add(", Alarm set: ");
args.add(alarmID);
msg.format(args);
ml.logInfoMessage(msg);
return true;
}
else
return false;
}
return true;
}
} // end of namespace

View File

@ -1,250 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
* Copyright (C) 2016 MariaDB Corporation.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***************************************************************************
* $Id: serverMonitor.h 34 2006-09-29 21:13:54Z dhill $
*
* Author: David Hill
***************************************************************************/
/**
* @file
*/
#ifndef SERVER_MONITOR_H
#define SERVER_MONITOR_H
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdlib>
#include <cerrno>
#include <exception>
#include <stdexcept>
#include <pthread.h>
#include <list>
#include <sys/statvfs.h>
#include <stdio.h>
#include <sys/sysinfo.h>
#include <string>
#include <sys/shm.h>
#include <sys/wait.h>
#include <errno.h>
#include "liboamcpp.h"
#include "messagelog.h"
#include "messageobj.h"
#include "loggingid.h"
#include "alarmmanager.h"
#include "socketclosed.h"
#include "shmkeys.h"
#include "alarmglobal.h"
#
#define CPU_DEBUG 0 // 0 for supported
#define DISK_DEBUG 0 // 0 for supported
#define CPU_HEARTBEAT_ID 1
#define MEMORY_HEARTBEAT_ID 2
#define HW_HEARTBEAT_ID 3
#define MONITOR_PERIOD 60 // 60 seconds
typedef struct
{
std::string processName;
double usedPercent;
} processCPU;
typedef std::list<processCPU> ProcessCPUList;
typedef struct
{
std::string processName;
long long usedBlocks;
double usedPercent;
} processMemory;
typedef std::list<processMemory> ProcessMemoryList;
typedef struct
{
std::string deviceName;
uint64_t totalBlocks;
uint64_t usedBlocks;
uint64_t usedPercent;
} SMSystemDisk;
typedef std::list<SMSystemDisk> SystemDiskList;
/**
* @brief Local Process-Monitor Monitor Thread
*/
void procmonMonitor();
/**
* @brief UM Auto Sync Thread
*/
void UMAutoSync();
/**
* @brief CPU Monitor Thread
*/
void cpuMonitor();
/**
* @brief Disk Monitor Thread
*/
void diskMonitor();
/**
* @brief Disk Monitor Thread
*/
void memoryMonitor();
/**
* @brief Hardware Monitor
*/
void hardwareMonitor(int IPMI_SUPPORT);
/**
* @brief Message Processor Thread
*/
void msgProcessor();
/**
* @brief Disk Monitor Thread
*/
void diskTest();
/**
* @brief DB Health Monitor Thread
*/
void dbhealthMonitor();
namespace servermonitor
{
// Log ID
#define SERVER_MONITOR_LOG_ID 9
class ServerMonitor
{
public:
/**
* @brief Constructor
*/
ServerMonitor();
/**
* @brief Default Destructor
*/
~ServerMonitor();
/**
* @brief send alarm
*/
void sendAlarm(std::string alarmItem, oam::ALARMS alarmID, int action, float sensorValue);
/**
* @brief check alarm
*/
void checkAlarm(std::string alarmItem, oam::ALARMS alarmID = oam::ALARM_NONE);
/**
* @brief clear alarm
*/
void clearAlarm(std::string alarmItem, oam::ALARMS alarmID);
/**
* @brief send msg to shutdown server
*/
void sendMsgShutdownServer();
/**
* @brief strip off whitespaces from a string
*/
std::string StripWhitespace(std::string value);
/**
* @brief log cpu usage to active log file
*/
void logCPUactive (unsigned int);
/**
* @brief log cpu peak and average to stat file
*/
void logCPUstat (int usageCount);
/**
* @brief send alarm
*/
bool sendResourceAlarm(std::string alarmItem, oam::ALARMS alarmID, int action, int usage);
/**
* @brief check CPU alarm
*/
void checkCPUAlarm(std::string alarmItem, oam::ALARMS alarmID = oam::ALARM_NONE);
/**
* @brief check Disk alarm
*/
void checkDiskAlarm(std::string alarmItem, oam::ALARMS alarmID = oam::ALARM_NONE);
/**
* @brief check Memory alarm
*/
void checkMemoryAlarm(std::string alarmItem, oam::ALARMS alarmID = oam::ALARM_NONE);
/**
* @brief check Swap alarm
*/
void checkSwapAlarm(std::string alarmItem, oam::ALARMS alarmID = oam::ALARM_NONE);
/**
* @brief check Swap action
*/
void checkSwapAction();
/**
* @brief output Proc Memory
*/
void outputProcMemory(bool);
/**
* @brief get CPU Data
*/
void getCPUdata();
/**
* @brief db health check
*/
int healthCheck(bool action = true);
/**
* @brief Check Active Alarm
*/
bool checkActiveAlarm(const int alarmid, const std::string moduleName, const std::string deviceName);
}; // end of class
} // end of namespace
#endif

View File

@ -2507,16 +2507,6 @@ void PrimitiveServer::start(Service *service)
fServerpool.invoke(ServerThread(oss.str(), this));
}
{
Oam oam;
try
{
oam.processInitComplete("PrimProc");
}
catch (...) {}
}
service->NotifyServiceStarted();
fServerpool.wait();

View File

@ -411,14 +411,6 @@ int ServicePrimProc::Child()
mlp->logMessage(errMsg);
cerr << errMsg << endl;
try
{
oam.processInitFailure();
}
catch (...)
{
}
NotifyServiceInitializationFailed();
return 2;
}

View File

@ -1,16 +0,0 @@
include_directories( ${ENGINE_COMMON_INCLUDES} )
########### next target ###############
set(ProcMgr_SRCS main.cpp processmanager.cpp ../utils/common/crashtrace.cpp)
add_executable(ProcMgr ${ProcMgr_SRCS})
target_compile_options(ProcMgr PRIVATE -Wno-unused-result)
target_link_libraries(ProcMgr ${ENGINE_LDFLAGS} cacheutils ${NETSNMP_LIBRARIES} ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS})
install(TARGETS ProcMgr DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,607 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/******************************************************************************************
* $Id: processmanager.h 2163 2013-04-04 18:40:54Z rdempsey $
*
******************************************************************************************/
#ifndef _PROCESSMANAGER_H_
#define _PROCESSMANAGER_H_
#include <string>
#include "liboamcpp.h"
#include "threadpool.h"
#include "socketclosed.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <sys/ioctl.h>
#include <linux/sockios.h>
#include <errno.h>
#include <netinet/in.h>
#if defined(__GLIBC__) && __GLIBC__ >=2 && __GLIBC_MINOR__ >= 1
#include <netpacket/packet.h>
#include <net/ethernet.h>
#else
#include <sys/types.h>
#include <netinet/if_ether.h>
#endif
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <sys/ioctl.h>
#include <linux/sockios.h>
#include <errno.h>
#include <netinet/in.h>
#if defined(__GLIBC__) && __GLIBC__ >=2 && __GLIBC_MINOR__ >= 1
#include <netpacket/packet.h>
#include <net/ethernet.h>
#else
#include <sys/types.h>
#include <netinet/if_ether.h>
#endif
#include <arpa/inet.h>
#include <ifaddrs.h>
void pingDeviceThread();
namespace processmanager
{
void* startSystemThread(oam::DeviceNetworkList* devicenetworklist);
void* stopSystemThread(oam::DeviceNetworkList* devicenetworklist);
void* startModuleThread(std::string* moduleName);
void* stopModuleThread(std::string* moduleName);
void* processMSG(messageqcpp::IOSocket* fIos);
/** @brief Timeset for Milleseconds
*/
#define TS_MS(x) ((x) * 1000000)
struct HeartBeatProc
{
std::string ModuleName; //!< Module Name
std::string ProcessName; //!< Process Name
int ID; //!< Heartbeat ID
bool receiveFlag; //!< Heartbeat indication flag
};
typedef std::list<HeartBeatProc> HeartBeatProcList;
typedef std::map<std::string, std::string> srvStateList;
const int MAX_ARGUMENTS = 10;
const std::string DEFAULT_LOG_FILE = "/var/log/mariadb/columnstore/ProcessManager.log";
/**
* parentFlag accessor
*/
class Configuration
{
public:
/**
* @brief Constructor
*/
Configuration();
/**
* Destructor
*/
~Configuration();
/**
* @brief Return the module opstate tag
*/
std::string getstateInfo(std::string moduleName);
/**
* moduleName accessor
*/
const std::string& moduleName() const
{
return flocalModuleName;
}
/**
* moduleType accessor
*/
const std::string& moduleType() const
{
return flocalModuleType;
}
/**
* moduleName accessor
*/
const uint16_t& moduleID() const
{
return flocalModuleID;
}
/**
* parentName accessor
*/
const std::string& OAMParentName() const
{
return fOAMParentModuleName;
}
/**
* parentFlag accessor
*/
const bool& OAMParentFlag() const
{
return fOAMParentModuleFlag;
}
/**
* ServerInstallType accessor
*/
const uint16_t& ServerInstallType() const
{
return fserverInstallType;
}
/**
* standbyName accessor
*/
const std::string& OAMStandbyName() const
{
return fOAMStandbyModuleName;
}
/**
* standbyParentFlag accessor
*/
const bool& OAMStandbyParentFlag() const
{
return fOAMStandbyModuleFlag;
}
/**
* parentFlag accessor
*/
private:
srvStateList stateInfoList;
std::string flocalModuleName;
std::string flocalModuleType;
uint16_t flocalModuleID;
std::string fOAMParentModuleName;
bool fOAMParentModuleFlag;
uint16_t fserverInstallType;
std::string fOAMStandbyModuleName;
bool fOAMStandbyModuleFlag;
};
class ProcessLog
{
public:
/**
* @brief Constructor
*/
ProcessLog();
/**
* @brief Destructor
*/
~ProcessLog();
/**
* @brief Write the message to the log
*/
void writeLog(const int lineNumber, const std::string logContent, const logging::LOG_TYPE logType = logging::LOG_TYPE_INFO);
/**
* @brief Write the message to the log
*/
void writeLog(const int lineNumber, const int logContent, const logging::LOG_TYPE logType = logging::LOG_TYPE_INFO);
/**
* @brief Compose a log data in the required format
*/
void setSysLogData();
/**
* @brief return the sysLogData
*/
std::string getSysLogData();
/**
* @brief log process status change into system log
*/
void writeSystemLog();
private:
std::ofstream PMLog;
std::string sysLogData;
};
class ProcessManager
{
public:
/**
* @brief Constructor
*/
ProcessManager(Configuration& config, ProcessLog& log);
/**
* @brief Default Destructor
*/
~ProcessManager();
/**
* @brief Process the received message
*/
// void processMSG(messageqcpp::IOSocket fIos, messageqcpp::ByteStream msg);
/**
*@brief send a request to the associated Process Monitor
*/
// void sendRequestToMonitor(ByteStream::byte target, ByteStream request);
/**
*@brief Build a request message
*/
messageqcpp::ByteStream buildRequestMessage(messageqcpp::ByteStream::byte requestID, messageqcpp::ByteStream::byte actionIndicator, std::string processName, bool manualFlag = true);
/**
*@brief Start all processes on the specified module
*/
int startModule(std::string target, messageqcpp::ByteStream::byte actionIndicator, uint16_t startType, bool systemStart = false);
/**
*@brief Stop all processes on the specified module
*/
int stopModule(std::string target, messageqcpp::ByteStream::byte actionIndicator, bool manualFlag, int timeout = 60 );
/**
*@brief power off the specified module
*/
int shutdownModule(std::string target, messageqcpp::ByteStream::byte actionIndicator, bool manualFlag, int timeout = 10 );
/**
*@brief Disable a specified module
*/
int disableModule(std::string target, bool manualFlag);
/**
*@brief reinit Processes trying to replace recycleProcess
*/
void reinitProcesses(std::string skipModule = "none");
/**
*@brief recycle Processes
*/
void recycleProcess(std::string module, bool enableModule = false);
/**
*@brief Enable a specified module
*/
int enableModule(std::string target, int state, bool failover = false);
/**
*@brief Enable a specified module
*/
int enableModuleStatus(std::string target);
void dbrmctl(std::string command);
/**
*@brief start all Mgr Controlled processes for a module
*/
void startMgrProcesses(std::string moduleName);
/**
*@brief stop process on a specific module
*/
int stopProcess(std::string moduleName, std::string processName, messageqcpp::ByteStream::byte actionIndicator, bool manualFlag, int timeout = 10);
/**
*@brief start process on a specific module
*/
int startProcess(std::string moduleName, std::string processName, messageqcpp::ByteStream::byte actionIndicator);
/**
*@brief restart process on a specific module
*/
int restartProcess(std::string moduleName, std::string processName, messageqcpp::ByteStream::byte actionIndicator, bool manualFlag);
/**
*@brief reinit process on a specific module
*/
int reinitProcess(std::string moduleName, std::string processName);
/**
*@brief set the state of the specified module
*/
void setModuleState(std::string moduleName, uint16_t state);
/**
*@brief set the state of the specified Ext device
*/
void setExtdeviceState(std::string extDeviceName, uint16_t state);
/**
*@brief set the state of the specified NIC
*/
void setNICState(std::string hostName, uint16_t state);
/**
*@brief set the state of the system
*/
void setSystemState(uint16_t state);
/**
*@brief set all processes running on module auto or manual offline
*/
void setProcessStates(std::string moduleName, uint16_t state, std::string processNameSkip = "");
/**
*@brief set the state of the specified process
*/
int setProcessState (std::string moduleName, std::string processName, uint16_t state, pid_t PID);
/**
*@brief updatelog on a specific module
*/
int updateLog (std::string action, std::string moduleName, std::string level);
/**
*@brief get log configuration on a specific module
*/
int getConfigLog (std::string moduleName);
/**
*@brief update process configuration
*/
int updateConfig (std::string moduleName);
/**
*@brief Build System Tables request
*/
int buildSystemTables(std::string moduleName);
/**
*@brief Stop a Process Type
*/
int stopProcessType(std::string processName, bool manualFlag = true );
/**
*@brief Start a Process Type
*/
int startProcessType(std::string processName);
/**
*@brief Restart a Process Type
*/
int restartProcessType(std::string processName, std::string skipModule = "none", bool manualFlag = true);
/**
*@brief ReInit a Process Type
*/
int reinitProcessType(std::string processName);
/**
*@brief Add Module
*/
int addModule(oam::DeviceNetworkList devicenetworklist, std::string password, bool storeHostnames,
bool manualFlag = true);
/**
*@brief Configure Module
*/
int configureModule(std::string moduleName);
/**
*@brief Reconfigure Module
*/
int reconfigureModule(oam::DeviceNetworkList devicenetworklist);
/**
*@brief Remove Module
*/
int removeModule(oam::DeviceNetworkList devicenetworklist, bool manualFlag = true);
/**
*@brief Check for simplex module run-type and start mate processes if needed
*/
void checkSimplexModule(std::string moduleName);
/**
*@brief update core on a specific module
*/
int updateCore (std::string action, std::string moduleName);
/**
*@brief update PMS Configuration
*/
int updatePMSconfig(bool check = false);
/**
*@brief update WorkerNode Configuration
*/
int updateWorkerNodeconfig();
/**
*@brief Clears all alarms related to a module
*/
void clearModuleAlarms(std::string moduleName);
/**
*@brief Clears all alarms related to a NIC hostName
*/
void clearNICAlarms(std::string hostName);
/**
*@brief Send Msg to Process Monitor
*/
std::string sendMsgProcMon1( std::string module, messageqcpp::ByteStream msg, int requestID );
/*
* Updates the Columnstore.xml file for DDL/DMLProc IPs during PM switchover
*/
int setPMProcIPs( std::string moduleName, std::string processName = oam::UnassignedName);
/*
* OAM Parent Module change-over
*/
int OAMParentModuleChange();
/** @brief find a new hot-standby module based on Process-Manager status, if one exist
*/
std::string getStandbyModule();
/** @brief set Standby Module info in Columnstore.xml
*/
bool setStandbyModule(std::string newStandbyModule, bool send = true);
/** @brief clear Standby Module info in Columnstore.xml
*/
bool clearStandbyModule();
int setEnableState(std::string target, std::string state);
/** @brief Distribute Calpont Config File to system modules
*/
int distributeConfigFile(std::string name, std::string file = "Columnstore.xml");
/** @brief Switch OAM Parent Module
*/
int switchParentOAMModule(std::string moduleName);
/** @brief get DBRM Data and send to requester
*/
int getDBRMData(messageqcpp::IOSocket fIos, std::string moduleName);
/** @brief remount the dbroot disk
*/
// int remountDbroots(std::string option);
/**
*@brief Send Msg to Process Monitor
*/
int sendMsgProcMon( std::string module, messageqcpp::ByteStream msg, int requestID, int timeout = 240 );
/** @brief get Alarm Data and send to requester
*/
int getAlarmData(messageqcpp::IOSocket fIos, int type, std::string date);
/**
*@brief Save BRM database
*/
void saveBRM(bool skipSession = false, bool clearshm = true);
/**
*@brief set query system state not ready
*/
void setQuerySystemState(bool set);
/** @brief stop by process type
*/
void stopProcessTypes(bool manualFlag = true);
/** @brief unmount a dbroot
*/
int unmountDBRoot(std::string dbrootID);
/** @brief mount a dbroot
*/
int mountDBRoot(std::string dbrootID);
/** @brief distribute fstab update message
*/
int updateFstab(std::string moduleName, std::string entry);
/** @brief Set MySQL Replication
*/
int setMySQLReplication(oam::DeviceNetworkList devicenetworklist, std::string masterModule = oam::UnassignedName, bool distributeDB = false, std::string password = oam::UnassignedName, bool enable = true, bool addModule = false);
/** @brief Gluster Assign dbroot to a module
*/
int glusterAssign(std::string moduleName, std::string dbroot);
/** @brief Gluster Unassign dbroot to a module
*/
int glusterUnassign(std::string moduleName, std::string dbroot);
/** @brief sync filesystem for snapshot backups
*/
int syncFsAll(std::string moduleName);
private:
Configuration& config;
ProcessLog& log;
/**
*@brief Create a /ect/module file for remote server
*/
bool createModuleFile(std::string remoteModuleName);
/**
*@brief pdate Extent Map section in Columnstore.xml
*/
bool updateExtentMap();
/*
* Make inittab to auto-launch ProcMon
*/
bool makeXMInittab(std::string moduleName, std::string systemID, std::string parentOAMModuleHostName);
/*
* setup External Module mount file
*/
bool setXMmount(std::string moduleName, std::string parentOAMModuleHostName, std::string parentOAMModuleIPAddr);
/** @brief send status updates to process monitor
*/
void sendStatusUpdate(messageqcpp::ByteStream obs, messageqcpp::ByteStream::byte returnRequestType);
/** @brief flush inode cache
*/
void flushInodeCache();
};
} //end of namespace
#endif // _PROCESSMANAGER_H_

View File

@ -1,16 +0,0 @@
include_directories( ${ENGINE_COMMON_INCLUDES} )
########### next target ###############
set(ProcMon_SRCS main.cpp processmonitor.cpp ../utils/common/crashtrace.cpp)
add_executable(ProcMon ${ProcMon_SRCS})
target_compile_options(ProcMon PRIVATE -Wno-unused-result)
target_link_libraries(ProcMon ${ENGINE_LDFLAGS} cacheutils ${NETSNMP_LIBRARIES} ${MARIADB_CLIENT_LIBS} ${ENGINE_EXEC_LIBS})
install(TARGETS ProcMon DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-engine)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,563 +0,0 @@
/* Copyright (C) 2014 InfiniDB, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***************************************************************************
* $Id: processmonitor.h 1993 2013-04-04 18:33:48Z rdempsey $
*
***************************************************************************/
#ifndef _PROCESSMONITOR_H_
#define _PROCESSMONITOR_H_
#include <string>
#include <sys/shm.h>
#include <sys/wait.h>
#include <errno.h>
#include "liboamcpp.h"
#include "shmkeys.h"
#include "alarmglobal.h"
#include "socketclosed.h"
namespace processmonitor
{
#define INIT_SUPPORT 0 // 0 = 'INIT -0' COMMAND COMPILED IN, 1 = 'INIT -0' COMMANDS COMPILED OUT
#define MAXARGUMENTS 15
#define MAXDEPENDANCY 6
/**
* @brief processStructure Process Config Structure
*/
typedef struct processStructure
{
std::string ProcessModuleType;
std::string ProcessName;
std::string ProcessLocation;
std::string ProcessArgs[MAXARGUMENTS];
time_t currentTime;
uint16_t launchID;
pid_t processID;
uint16_t state;
uint16_t BootLaunch;
uint16_t dieCounter;
std::string RunType;
std::string DepProcessName[MAXDEPENDANCY];
std::string DepModuleName[MAXDEPENDANCY];
std::string LogFile;
} processInfo;
typedef std::vector<processInfo> processList;
/**
* @brief shmProcessStatus Process Status Structure
*/
struct shmProcessStatus
{
pid_t ProcessID; //!< Process ID number
char StateChangeDate[24]; //!< Last time/date state change
uint16_t ProcessOpState; //!< Process Operational State
};
/**
* @brief processStatus Process Status Structure
*/
typedef struct processStatus
{
std::string ProcessName;
std::string ModuleName;
uint16_t tableIndex;
} processstatus;
typedef std::vector<processstatus> processStatusList;
/**
* @brief shmDeviceStatus Status Structure
*/
#define NAMESIZE 128
#define DATESIZE 24
struct shmDeviceStatus
{
char Name[NAMESIZE]; //!< Device Name
char StateChangeDate[DATESIZE]; //!< Last time/date state change
uint16_t OpState; //!< Device Operational State
};
/**
* @brief MonitorConfig class builds a list of process it starts
*
*/
class MonitorConfig
{
public:
/**
* @brief constructor
*
*/
MonitorConfig();
/**
* @brief destructor
*
*/
~MonitorConfig();
/**
* moduleName accessor
*/
const std::string& moduleName() const
{
return flocalModuleName;
}
/**
* moduleType accessor
*/
const std::string& moduleType() const
{
return flocalModuleType;
}
/**
* moduleName accessor
*/
const uint16_t& moduleID() const
{
return flocalModuleID;
}
/**
* parentName accessor
*/
const std::string& OAMParentName() const
{
return fOAMParentModuleName;
}
/**
* parentFlag accessor
*/
const bool& OAMParentFlag() const
{
return fOAMParentModuleFlag;
}
/**
* ServerInstallType accessor
*/
const uint16_t& ServerInstallType() const
{
return fserverInstallType;
}
/**
* StandbyName accessor
*/
const std::string& OAMStandbyName() const
{
return fOAMStandbyModuleName;
}
/**
* standbyParentFlag accessor
*/
const bool& OAMStandbyParentFlag() const
{
return fOAMStandbyModuleFlag;
}
/**
* SoftwareVersion accessor
*/
const std::string& SoftwareVersion() const
{
return fsoftwareVersion;
}
/**
* SoftwareRelease accessor
*/
const std::string& SoftwareRelease() const
{
return fsoftwareRelease;
}
/**
* Build a list of processes the monitor started
*/
void buildList(std::string ProcessModuleType,
std::string processName,
std::string ProcessLocation,
std::string arg_list[MAXARGUMENTS],
uint16_t launchID,
pid_t processID,
uint16_t state,
uint16_t BootLaunch,
std::string RunType,
std::string DepProcessName[MAXDEPENDANCY],
std::string DepModuleName[MAXDEPENDANCY],
std::string logFile);
/**
* return the process list
*/
processList* monitoredListPtr();
/**
* return the process ID
*/
void findProcessInfo (pid_t processID, processInfo& info);
/**
* @brief copy constructor
*
*/
MonitorConfig(const MonitorConfig& rhs);
/**
* @brief copy assignment operator
*
*/
MonitorConfig& operator=(const MonitorConfig& rhs);
private:
std::string flocalModuleName;
std::string flocalModuleType;
uint16_t flocalModuleID;
std::string fOAMParentModuleName;
bool fOAMParentModuleFlag;
uint16_t fserverInstallType;
std::string fOAMStandbyModuleName;
bool fOAMStandbyModuleFlag;
processList fmonitoredListPtr;
std::string fsoftwareVersion;
std::string fsoftwareRelease;
};
/**
* @brief MonitorLog class logs the activities between Process Monitor
* and its child processes for debugging purpose.
*/
class MonitorLog
{
public:
/**
* Constructor:open the log file for writing
*/
MonitorLog();
/**
* Destructor:close the log file
*/
~MonitorLog();
/**
* @brief Write the message to the log
*/
void writeLog(const int lineNumber, const std::string logContent, const logging::LOG_TYPE logType = logging::LOG_TYPE_INFO);
/**
* @brief Write the message to the log
*/
void writeLog(const int lineNumber, const int logContent, const logging::LOG_TYPE logType = logging::LOG_TYPE_INFO);
private:
std::ofstream logFile;
/**
* @brief copy constructor
*
*/
MonitorLog(const MonitorLog& rhs);
/**
* @brief copy assignment operator
*
*/
MonitorLog& operator=(const MonitorLog& rhs);
};
/**
* @brief ProcessMonitor class takes requests from Process Manager for
* starting, stopping, and restarting processes. It monitors the processes it started,
* logs its events, and restarts the died processes.
*/
class ProcessMonitor
{
public:
/**
* Constructor
*/
ProcessMonitor(MonitorConfig& config, MonitorLog& log);
/**
* Default Destructor
*/
~ProcessMonitor();
/**
* Start a process
*/
pid_t startProcess(std::string processModuleType, std::string processName, std::string processLocation,
std::string arg_list[MAXARGUMENTS], uint16_t launchID, uint16_t BootLaunch,
std::string RunType, std::string DepProcessName[MAXDEPENDANCY],
std::string DepModuleName[MAXDEPENDANCY], std::string LogFile, uint16_t startType,
uint16_t actIndicator = oam::FORCEFUL);
/**
* get Alarm Data and send to requester
*/
int getAlarmData(messageqcpp::IOSocket mq, int type, std::string date);
/**
* Stop a process
*/
int stopProcess(pid_t processID, std::string processName, std::string processLocation, int actionIndicator, bool manualFlag);
/**
* Re-init a process
*/
int reinitProcess(pid_t processID, std::string processName, int actionIndicator);
/**
* Stop all processes started by this monitor
*/
int stopAllProcess(int actionIndicator);
/**
* receive and process message
*/
void processMessage(messageqcpp::ByteStream msg, messageqcpp::IOSocket mq);
/**
* send message to the monitored process or the process manager
*/
int sendMessage(const std::string& toWho, const std::string& message);
/**
* check child process heart beat
*/
int checkHeartBeat(const std::string processName);
/**
* send a trap and log the process information
*/
void sendAlarm(std::string alarmItem, oam::ALARMS alarmID, int action);
/**
*@brief update process disk state
*/
bool updateProcessInfo(std::string processName, int state, pid_t pid);
/**
*@brief update log configuration
*/
int updateLog(std::string action, std::string level);
/**
*@brief get log configuration
*/
int getConfigLog();
/**
*@brief change Log File priviledges
*/
void changeModLog();
/**
*@brief check Power-On Test results
*/
void checkPowerOnResults();
/**
*@brief update Config
*/
int updateConfig();
/**
*@brief build System Tables
*/
int buildSystemTables();
/**
*@brief configure Module fucntionality
*/
int configureModule(std::string configureModuleName);
/**
*@brief reconfigure Module fucntionality
*/
int reconfigureModule(std::string reconfigureModuleName);
/**
*@brief check Single Process State
*/
int checkSpecialProcessState( std::string processName, std::string runType, std::string processModuleType );
/**
*@brief Check if Mate Module is Active
*/
int checkMateModuleState();
/**
*@brief Create the Calpont Data directories
*/
int createDataDirs(std::string cloud);
/**
*@brief Process Restarted, inform Process Mgr
*/
int processRestarted( std::string processName, bool manual = true );
/**
*@brief update Core Dump configuration
*/
int updateCore(std::string action);
/**
*@brief Remove XM ProcMon setup
*/
int removeXMProcMon();
/**
*@brief unmount from associated system
*/
int umountSystem();
/**
*@brief Runs DB sanity test
*/
int runStartupTest();
/**
*@brief Update Calpont Config File
*/
int updateConfigFile(messageqcpp::ByteStream msg);
int getDBRMdata(std::string *path);
/**
*@brief Send Msg to Process Monitor
*/
std::string sendMsgProcMon1( std::string module, messageqcpp::ByteStream msg, int requestID );
/**
*@brief check if module failover is needed due to a process outage
*/
void checkModuleFailover(std::string processName);
/**
*@brief run upgrade script
*/
int runUpgrade();
/**
*@brief change my.cnf
*/
int changeMyCnf(std::string type);
/**
*@brief run MariaDB Command Line script
*/
int runMariaDBCommandLine(std::string command);
/**
*@brief run Master Replication script
*/
int runMasterRep(std::string& masterLogFile, std::string& masterLogPos);
/**
*@brief run Master Distribution
*/
int runMasterDist(std::string& password, std::string& slaveModule);
/**
*@brief run Slave Replication script
*/
int runSlaveRep(std::string& masterLogFile, std::string& masterLogPos);
/**
*@brief run Disable Replication script
*/
int runDisableRep();
/**
*@brief Amazon Instance and IP check
*/
bool amazonIPCheck();
/**
*@brief UnMOunt any extra dbroots
*/
void unmountExtraDBroots();
/**
*@brief Calculate TotalUmMemory
*/
void calTotalUmMemory();
/**
*@brief Amazon Volume check
*/
bool amazonVolumeCheck(int dbrootID = 0);
/**
*@brief Check Data Mounts
*/
int checkDataMount();
/** @brief flush inode cache
*/
void flushInodeCache();
/** @brief glusterAssign
*/
int glusterAssign(std::string dbrootID);
/** @brief glusterUnassign
*/
int glusterUnassign(std::string dbrootID);
int syncFS();
/**
* return the process list
*/
// processStatusList* statusListPtr();
// processStatusList fstatusListPtr;
private:
/*need define copy ans assignment constructor */
MonitorConfig& config;
MonitorLog& log;
};
} //end of namespace
#endif // _PROCESSMONITOR_H_

View File

@ -6,7 +6,6 @@ add_subdirectory(getConfig)
add_subdirectory(cplogger)
add_subdirectory(clearShm)
add_subdirectory(setConfig)
add_subdirectory(configMgt)
add_subdirectory(viewtablelock)
add_subdirectory(cleartablelock)
add_subdirectory(ddlcleanup)

View File

@ -1,45 +0,0 @@
include_directories(${KDE4_INCLUDES} ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} )
########### next target ###############
set(brmtest_SRCS brmtest.cpp locks.cpp)
kde4_add_executable(brmtest ${brmtest_SRCS})
target_link_libraries(brmtest ${KDE4_KDECORE_LIBS} execplan joblist rowgroup dataconvert loggingcpp @boost_thread_lib@ brm messageqcpp rwlock configcpp xml2 joiner oamcpp snmpmanager @boost_filesystem_lib@ @boost_date_time_lib@ multicast funcexp)
install(TARGETS brmtest ${INSTALL_TARGETS_DEFAULT_ARGS})
########### install files ###############
#original Makefile.am contents follow:
## $Id: Makefile.am 333 2009-04-03 20:35:04Z rdempsey $
### Process this file with automake to produce Makefile.in
#
#AM_CPPFLAGS = $(idb_cppflags)
#AM_CFLAGS = $(idb_cflags)
#AM_CXXFLAGS = $(idb_cxxflags)
#AM_LDFLAGS = $(idb_ldflags)
#bin_PROGRAMS = brmtest
#brmtest_SOURCES = brmtest.cpp locks.cpp
#brmtest_CPPFLAGS = -I@prefix@/Calpont/include -I/usr/include/libxml2 $(AM_CPPFLAGS)
#brmtest_LDFLAGS = @idb_common_ldflags@ -lexecplan -ljoblist -lrowgroup -ldataconvert -lloggingcpp -l@boost_thread_lib@ -lbrm -lmessageqcpp -lrwlock -lconfigcpp -lxml2 -ljoiner \
#-loamcpp -lsnmpmanager -l@boost_filesystem_lib@ -l@boost_date_time_lib@ @netsnmp_libs@ -lmulticast -lfuncexp $(AM_LDFLAGS)
#
#test:
#
#coverage:
#
#leakcheck:
#
#docs:
#
#bootstrap: install-data-am
#

View File

@ -1,680 +0,0 @@
/*
* $Id: brmtest.cpp 1739 2012-03-22 12:57:59Z pleblanc $
*/
#include <iostream>
#include <vector>
#include <cassert>
#include <stdexcept>
#include <sstream>
using namespace std;
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "calpontsystemcatalog.h"
using namespace execplan;
#include "extentmap.h"
#include "blockresolutionmanager.h"
using namespace BRM;
#include "configcpp.h"
using namespace config;
extern int query_locks();
extern int reset_locks();
namespace
{
boost::shared_ptr<CalpontSystemCatalog> Cat;
void LBIDList(CalpontSystemCatalog::OID OID, ostringstream& cout_str)
{
LBIDRange_v LBIDRanges;
LBIDRange_v::size_type RangeCount;
ExtentMap em;
LBIDRange_v::size_type i;
LBIDRange LBIDR;
cout_str << "HWM = " << em.getHWM(OID) << endl;
em.lookup(OID, LBIDRanges);
RangeCount = LBIDRanges.size();
idbassert(RangeCount < 1000);
for (i = 0; i < RangeCount; i++)
{
LBIDR = LBIDRanges[i];
cout_str << LBIDR.start << " - " << (LBIDR.start + LBIDR.size - 1) << " (" << LBIDR.size << ')';
int64_t max = -1, min = -1;
int32_t seqNum = 0;
em.getMaxMin(LBIDR.start, max, min, seqNum);
cout_str << " min: " << min << ", max: " << max << ", seqNum: " << seqNum << endl;
}
cout_str << endl;
}
void doit(const CalpontSystemCatalog::TableColName& tcn, ostringstream& cout_str)
{
CalpontSystemCatalog::OID OID;
try
{
OID = Cat->columnRID(tcn).objnum;
}
catch (...)
{
cout_str << tcn.schema << '.' << tcn.table << '.' << tcn.column << ": OID not found" << endl;
return;
}
if (OID > 0)
{
CalpontSystemCatalog::OID ioid = Cat->lookupOID(tcn);
CalpontSystemCatalog::ColType CT = Cat->colType(ioid);
CalpontSystemCatalog::DictOID DOID = CT.ddn;
int DictOID = DOID.dictOID;
int ListOID = DOID.listOID;
int TreeOID = DOID.treeOID;
cout_str << tcn.schema << '.' << tcn.table << '.' << tcn.column << ": OID = " << OID << endl;
try
{
LBIDList(OID, cout_str);
}
catch (exception& ex)
{
cerr << ex.what() << endl;
}
if (DictOID > 0)
{
cout_str << tcn.schema << '.' << tcn.table << '.' << tcn.column << ": DictOID = " << DictOID << endl;
try
{
LBIDList(DictOID, cout_str);
}
catch (exception& ex)
{
cerr << ex.what() << endl;
}
}
if (ListOID > 0)
{
cout_str << tcn.schema << '.' << tcn.table << '.' << tcn.column << ": DictListOID = " << ListOID << endl;
try
{
LBIDList(ListOID, cout_str);
}
catch (exception& ex)
{
cerr << ex.what() << endl;
}
}
if (TreeOID > 0)
{
cout_str << tcn.schema << '.' << tcn.table << '.' << tcn.column << ": DictTreeOID = " << TreeOID << endl;
try
{
LBIDList(TreeOID, cout_str);
}
catch (exception& ex)
{
cerr << ex.what() << endl;
}
}
CalpontSystemCatalog::IndexOID IOID = Cat->lookupIndexNbr(tcn);
if (IOID.objnum > 0)
{
cout_str << tcn.schema << '.' << tcn.table << '.' << tcn.column << ": IndexOID = " << IOID.objnum << endl;
try
{
LBIDList(IOID.objnum, cout_str);
}
catch (exception& ex)
{
cerr << ex.what() << endl;
}
}
if (IOID.listOID > 0)
{
cout_str << tcn.schema << '.' << tcn.table << '.' << tcn.column << ": IndexLstOID = " << IOID.listOID << endl;
try
{
LBIDList(IOID.listOID, cout_str);
}
catch (exception& ex)
{
cerr << ex.what() << endl;
}
}
}
else
{
cout_str << tcn.schema << '.' << tcn.table << '.' << tcn.column << ": OID was zero!" << endl;
}
}
void usage(ostringstream& cout_str)
{
cout_str << "usage: brmtest [-hrts] [-l LBID] [-c schema]" << endl;
cout_str << "\t-h display this help" << endl;
cout_str << "\t-r reset brm locks" << endl;
cout_str << "\t-l LBID display info about LBID" << endl;
cout_str << "\t-t dump TPC-H tables" << endl;
cout_str << "\t-s don't dump system catalog" << endl;
cout_str << "\t-c schema seach for TPC-H tables in schema" << endl;
}
}
int main(int argc, char** argv)
{
int c;
bool rflg = false;
bool lflg = false;
bool tflg = false;
bool sflg = true;
bool qflg = false;
opterr = 0;
uint64_t lbid = 0;
ostringstream cout_str;
ostringstream cerr_str;
string schema("tpch");
while ((c = getopt(argc, argv, "hrl:tsc:q")) != EOF)
switch (c)
{
case 'r':
rflg = true;
break;
case 'l':
lflg = true;
lbid = strtoul(optarg, 0, 0);
break;
case 'h':
usage(cout_str);
cerr << cout_str.str() << endl;
exit(0);
break;
case 't':
tflg = true;
break;
case 's':
sflg = false;
break;
case 'c':
schema = optarg;
break;
case 'q':
qflg = true;
break;
default:
usage(cout_str);
cerr << cout_str.str() << endl;
exit(1);
break;
}
if (rflg)
{
reset_locks();
return 0;
}
if (query_locks() != 0)
{
cerr << "BRM is locked!" << endl;
return 1;
}
if (lflg)
{
BlockResolutionManager brm;
uint16_t ver = 0;
BRM::OID_t oid;
uint32_t fbo;
int rc;
rc = brm.lookup(lbid, ver, false, oid, fbo);
idbassert(rc == 0);
if (qflg)
cout << oid << endl;
else
cout << "LBID " << lbid << " is part of OID " << oid << " at FBO " << fbo << endl;
return 0;
}
//Now, close out all output so we don't get any debug from PG/RA
int fd;
::close(2);
::close(1);
//fd = open("./brmtest.out", O_WRONLY|O_CREAT|O_TRUNC, 0666);
fd = open("/dev/null", O_WRONLY);
idbassert(fd >= 0);
if (fd != 1) dup2(fd, 1);
//fd = open("./brmtest.err", O_WRONLY|O_CREAT|O_TRUNC, 0666);
fd = open("/dev/null", O_WRONLY);
idbassert(fd >= 0);
if (fd != 2) dup2(fd, 2);
Cat = CalpontSystemCatalog::makeCalpontSystemCatalog();
fd = ::open("/dev/tty", O_WRONLY);
idbassert(fd >= 0);
string status;
if (tflg)
{
const string region("region");
const string nation("nation");
const string customer("customer");
const string orders("orders");
const string supplier("supplier");
const string partsupp("partsupp");
const string lineitem("lineitem");
const string part("part");
status = "Reading REGION...\n";
::write(fd, status.c_str(), status.length());
doit(make_tcn(schema, region, "r_regionkey"), cout_str);
doit(make_tcn(schema, region, "r_name"), cout_str);
doit(make_tcn(schema, region, "r_comment"), cout_str);
status = "Reading NATION...\n";
::write(fd, status.c_str(), status.length());
doit(make_tcn(schema, nation, "n_nationkey"), cout_str);
doit(make_tcn(schema, nation, "n_name"), cout_str);
doit(make_tcn(schema, nation, "n_regionkey"), cout_str);
doit(make_tcn(schema, nation, "n_comment"), cout_str);
status = "Reading CUSTOMER...\n";
::write(fd, status.c_str(), status.length());
doit(make_tcn(schema, customer, "c_custkey"), cout_str);
doit(make_tcn(schema, customer, "c_name"), cout_str);
doit(make_tcn(schema, customer, "c_address"), cout_str);
doit(make_tcn(schema, customer, "c_nationkey"), cout_str);
doit(make_tcn(schema, customer, "c_phone"), cout_str);
doit(make_tcn(schema, customer, "c_acctbal"), cout_str);
doit(make_tcn(schema, customer, "c_mktsegment"), cout_str);
doit(make_tcn(schema, customer, "c_comment"), cout_str);
status = "Reading ORDERS...\n";
::write(fd, status.c_str(), status.length());
doit(make_tcn(schema, orders, "o_orderkey"), cout_str);
doit(make_tcn(schema, orders, "o_custkey"), cout_str);
doit(make_tcn(schema, orders, "o_orderstatus"), cout_str);
doit(make_tcn(schema, orders, "o_totalprice"), cout_str);
doit(make_tcn(schema, orders, "o_orderdate"), cout_str);
doit(make_tcn(schema, orders, "o_orderpriority"), cout_str);
doit(make_tcn(schema, orders, "o_clerk"), cout_str);
doit(make_tcn(schema, orders, "o_shippriority"), cout_str);
doit(make_tcn(schema, orders, "o_comment"), cout_str);
status = "Reading PART...\n";
::write(fd, status.c_str(), status.length());
doit(make_tcn(schema, part, "p_partkey"), cout_str);
doit(make_tcn(schema, part, "p_name"), cout_str);
doit(make_tcn(schema, part, "p_mfgr"), cout_str);
doit(make_tcn(schema, part, "p_brand"), cout_str);
doit(make_tcn(schema, part, "p_type"), cout_str);
doit(make_tcn(schema, part, "p_size"), cout_str);
doit(make_tcn(schema, part, "p_container"), cout_str);
doit(make_tcn(schema, part, "p_retailprice"), cout_str);
doit(make_tcn(schema, part, "p_comment"), cout_str);
status = "Reading SUPPLIER...\n";
::write(fd, status.c_str(), status.length());
doit(make_tcn(schema, supplier, "s_suppkey"), cout_str);
doit(make_tcn(schema, supplier, "s_name"), cout_str);
doit(make_tcn(schema, supplier, "s_address"), cout_str);
doit(make_tcn(schema, supplier, "s_nationkey"), cout_str);
doit(make_tcn(schema, supplier, "s_phone"), cout_str);
doit(make_tcn(schema, supplier, "s_acctbal"), cout_str);
doit(make_tcn(schema, supplier, "s_comment"), cout_str);
status = "Reading PARTSUPP...\n";
::write(fd, status.c_str(), status.length());
doit(make_tcn(schema, partsupp, "ps_partkey"), cout_str);
doit(make_tcn(schema, partsupp, "ps_suppkey"), cout_str);
doit(make_tcn(schema, partsupp, "ps_availqty"), cout_str);
doit(make_tcn(schema, partsupp, "ps_supplycost"), cout_str);
doit(make_tcn(schema, partsupp, "ps_comment"), cout_str);
status = "Reading LINEITEM...\n";
::write(fd, status.c_str(), status.length());
doit(make_tcn(schema, lineitem, "l_orderkey"), cout_str);
doit(make_tcn(schema, lineitem, "l_linenumber"), cout_str);
doit(make_tcn(schema, lineitem, "l_partkey"), cout_str);
doit(make_tcn(schema, lineitem, "l_suppkey"), cout_str);
doit(make_tcn(schema, lineitem, "l_quantity"), cout_str);
doit(make_tcn(schema, lineitem, "l_extendedprice"), cout_str);
doit(make_tcn(schema, lineitem, "l_discount"), cout_str);
doit(make_tcn(schema, lineitem, "l_tax"), cout_str);
doit(make_tcn(schema, lineitem, "l_returnflag"), cout_str);
doit(make_tcn(schema, lineitem, "l_linestatus"), cout_str);
doit(make_tcn(schema, lineitem, "l_shipdate"), cout_str);
doit(make_tcn(schema, lineitem, "l_commitdate"), cout_str);
doit(make_tcn(schema, lineitem, "l_receiptdate"), cout_str);
doit(make_tcn(schema, lineitem, "l_shipinstruct"), cout_str);
doit(make_tcn(schema, lineitem, "l_shipmode"), cout_str);
doit(make_tcn(schema, lineitem, "l_comment"), cout_str);
}
if (sflg)
{
status = "Reading CALPONTSYS...\n\n";
::write(fd, status.c_str(), status.length());
schema = CALPONT_SCHEMA;
string table = SYSCOLUMN_TABLE;
doit(make_tcn(schema, table, SCHEMA_COL), cout_str);
doit(make_tcn(schema, table, TABLENAME_COL), cout_str);
doit(make_tcn(schema, table, COLNAME_COL), cout_str);
///doit(make_tcn(schema, table, INDEXNAME_COL), cout_str);
///doit(make_tcn(schema, table, INDEXTYPE_COL), cout_str);
///doit(make_tcn(schema, table, MULTICOLFLAG_COL), cout_str);
doit(make_tcn(schema, table, OBJECTID_COL), cout_str);
doit(make_tcn(schema, table, DICTOID_COL), cout_str);
doit(make_tcn(schema, table, LISTOBJID_COL), cout_str);
doit(make_tcn(schema, table, TREEOBJID_COL), cout_str);
doit(make_tcn(schema, table, DATATYPE_COL), cout_str);
///doit(make_tcn(schema, table, COLUMNTYPE_COL), cout_str);
doit(make_tcn(schema, table, COLUMNLEN_COL), cout_str);
doit(make_tcn(schema, table, COLUMNPOS_COL), cout_str);
///doit(make_tcn(schema, table, CREATEDATE_COL), cout_str);
doit(make_tcn(schema, table, LASTUPDATE_COL), cout_str);
doit(make_tcn(schema, table, DEFAULTVAL_COL), cout_str);
doit(make_tcn(schema, table, NULLABLE_COL), cout_str);
doit(make_tcn(schema, table, SCALE_COL), cout_str);
doit(make_tcn(schema, table, PRECISION_COL), cout_str);
///doit(make_tcn(schema, table, NUMNULLS_COL), cout_str);
///doit(make_tcn(schema, table, NUMDISTINCTVAL_COL), cout_str);
///doit(make_tcn(schema, table, MINVAL_COL), cout_str);
///doit(make_tcn(schema, table, MAXVAL_COL), cout_str);
///doit(make_tcn(schema, table, DENSITY_COL), cout_str);
///doit(make_tcn(schema, table, AVGRECORDLEN_COL), cout_str);
///doit(make_tcn(schema, table, RECORDCOUNT_COL), cout_str);
///doit(make_tcn(schema, table, LASTANYLDATE_COL), cout_str);
///doit(make_tcn(schema, table, SAMPLESIZE_COL), cout_str);
///doit(make_tcn(schema, table, PROPERTY_COL), cout_str);
doit(make_tcn(schema, table, AUTOINC_COL), cout_str);
///doit(make_tcn(schema, table, DATANAME_COL), cout_str);
///doit(make_tcn(schema, table, CATEGORY_COL), cout_str);
///doit(make_tcn(schema, table, SIZE_COL), cout_str);
///doit(make_tcn(schema, table, DESC_COL), cout_str);
///doit(make_tcn(schema, table, INIT_COL), cout_str);
///doit(make_tcn(schema, table, NEXT_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTNAME_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTNUM_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTTYPE_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTPRIM_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTTEXT_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTSTATUS_COL), cout_str);
///doit(make_tcn(schema, table, TREELEVEL_COL), cout_str);
///doit(make_tcn(schema, table, LEAFCOUNT_COL), cout_str);
///doit(make_tcn(schema, table, DISTINCTKEYS_COL), cout_str);
///doit(make_tcn(schema, table, LEAFBLOCKS_COL), cout_str);
///doit(make_tcn(schema, table, AVGLEAFCOUNT_COL), cout_str);
///doit(make_tcn(schema, table, AVGDATABLOCK_COL), cout_str);
///doit(make_tcn(schema, table, CLUSTERFACTOR_COL), cout_str);
table = SYSTABLE_TABLE;
doit(make_tcn(schema, table, SCHEMA_COL), cout_str);
doit(make_tcn(schema, table, TABLENAME_COL), cout_str);
///doit(make_tcn(schema, table, COLNAME_COL), cout_str);
///doit(make_tcn(schema, table, INDEXNAME_COL), cout_str);
///doit(make_tcn(schema, table, INDEXTYPE_COL), cout_str);
///doit(make_tcn(schema, table, MULTICOLFLAG_COL), cout_str);
doit(make_tcn(schema, table, OBJECTID_COL), cout_str);
///doit(make_tcn(schema, table, DICTOID_COL), cout_str);
///doit(make_tcn(schema, table, LISTOBJID_COL), cout_str);
///doit(make_tcn(schema, table, TREEOBJID_COL), cout_str);
///doit(make_tcn(schema, table, DATATYPE_COL), cout_str);
///doit(make_tcn(schema, table, COLUMNTYPE_COL), cout_str);
///doit(make_tcn(schema, table, COLUMNLEN_COL), cout_str);
///doit(make_tcn(schema, table, COLUMNPOS_COL), cout_str);
doit(make_tcn(schema, table, CREATEDATE_COL), cout_str);
doit(make_tcn(schema, table, LASTUPDATE_COL), cout_str);
///doit(make_tcn(schema, table, DEFAULTVAL_COL), cout_str);
///doit(make_tcn(schema, table, NULLABLE_COL), cout_str);
///doit(make_tcn(schema, table, SCALE_COL), cout_str);
///doit(make_tcn(schema, table, PRECISION_COL), cout_str);
///doit(make_tcn(schema, table, NUMNULLS_COL), cout_str);
///doit(make_tcn(schema, table, NUMDISTINCTVAL_COL), cout_str);
///doit(make_tcn(schema, table, MINVAL_COL), cout_str);
///doit(make_tcn(schema, table, MAXVAL_COL), cout_str);
///doit(make_tcn(schema, table, DENSITY_COL), cout_str);
///doit(make_tcn(schema, table, AVGRECORDLEN_COL), cout_str);
///doit(make_tcn(schema, table, RECORDCOUNT_COL), cout_str);
///doit(make_tcn(schema, table, LASTANYLDATE_COL), cout_str);
///doit(make_tcn(schema, table, SAMPLESIZE_COL), cout_str);
///doit(make_tcn(schema, table, PROPERTY_COL), cout_str);
///doit(make_tcn(schema, table, AUTOINC_COL), cout_str);
///doit(make_tcn(schema, table, DATANAME_COL), cout_str);
///doit(make_tcn(schema, table, CATEGORY_COL), cout_str);
///doit(make_tcn(schema, table, SIZE_COL), cout_str);
///doit(make_tcn(schema, table, DESC_COL), cout_str);
doit(make_tcn(schema, table, INIT_COL), cout_str);
doit(make_tcn(schema, table, NEXT_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTNAME_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTNUM_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTTYPE_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTPRIM_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTTEXT_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTSTATUS_COL), cout_str);
///doit(make_tcn(schema, table, TREELEVEL_COL), cout_str);
///doit(make_tcn(schema, table, LEAFCOUNT_COL), cout_str);
///doit(make_tcn(schema, table, DISTINCTKEYS_COL), cout_str);
///doit(make_tcn(schema, table, LEAFBLOCKS_COL), cout_str);
///doit(make_tcn(schema, table, AVGLEAFCOUNT_COL), cout_str);
///doit(make_tcn(schema, table, AVGDATABLOCK_COL), cout_str);
///doit(make_tcn(schema, table, CLUSTERFACTOR_COL), cout_str);
table = SYSSCHEMA_TABLE;
///doit(make_tcn(schema, table, SCHEMA_COL), cout_str);
///doit(make_tcn(schema, table, TABLENAME_COL), cout_str);
///doit(make_tcn(schema, table, COLNAME_COL), cout_str);
///doit(make_tcn(schema, table, INDEXNAME_COL), cout_str);
///doit(make_tcn(schema, table, INDEXTYPE_COL), cout_str);
///doit(make_tcn(schema, table, MULTICOLFLAG_COL), cout_str);
///doit(make_tcn(schema, table, OBJECTID_COL), cout_str);
///doit(make_tcn(schema, table, DICTOID_COL), cout_str);
///doit(make_tcn(schema, table, LISTOBJID_COL), cout_str);
///doit(make_tcn(schema, table, TREEOBJID_COL), cout_str);
///doit(make_tcn(schema, table, DATATYPE_COL), cout_str);
///doit(make_tcn(schema, table, COLUMNTYPE_COL), cout_str);
///doit(make_tcn(schema, table, COLUMNLEN_COL), cout_str);
///doit(make_tcn(schema, table, COLUMNPOS_COL), cout_str);
///doit(make_tcn(schema, table, CREATEDATE_COL), cout_str);
///doit(make_tcn(schema, table, LASTUPDATE_COL), cout_str);
///doit(make_tcn(schema, table, DEFAULTVAL_COL), cout_str);
///doit(make_tcn(schema, table, NULLABLE_COL), cout_str);
///doit(make_tcn(schema, table, SCALE_COL), cout_str);
///doit(make_tcn(schema, table, PRECISION_COL), cout_str);
///doit(make_tcn(schema, table, NUMNULLS_COL), cout_str);
///doit(make_tcn(schema, table, NUMDISTINCTVAL_COL), cout_str);
///doit(make_tcn(schema, table, MINVAL_COL), cout_str);
///doit(make_tcn(schema, table, MAXVAL_COL), cout_str);
///doit(make_tcn(schema, table, DENSITY_COL), cout_str);
///doit(make_tcn(schema, table, AVGRECORDLEN_COL), cout_str);
///doit(make_tcn(schema, table, RECORDCOUNT_COL), cout_str);
///doit(make_tcn(schema, table, LASTANYLDATE_COL), cout_str);
///doit(make_tcn(schema, table, SAMPLESIZE_COL), cout_str);
///doit(make_tcn(schema, table, PROPERTY_COL), cout_str);
///doit(make_tcn(schema, table, AUTOINC_COL), cout_str);
///doit(make_tcn(schema, table, DATANAME_COL), cout_str);
///doit(make_tcn(schema, table, CATEGORY_COL), cout_str);
///doit(make_tcn(schema, table, SIZE_COL), cout_str);
///doit(make_tcn(schema, table, DESC_COL), cout_str);
///doit(make_tcn(schema, table, INIT_COL), cout_str);
///doit(make_tcn(schema, table, NEXT_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTNAME_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTNUM_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTTYPE_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTPRIM_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTTEXT_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTSTATUS_COL), cout_str);
///doit(make_tcn(schema, table, TREELEVEL_COL), cout_str);
///doit(make_tcn(schema, table, LEAFCOUNT_COL), cout_str);
///doit(make_tcn(schema, table, DISTINCTKEYS_COL), cout_str);
///doit(make_tcn(schema, table, LEAFBLOCKS_COL), cout_str);
///doit(make_tcn(schema, table, AVGLEAFCOUNT_COL), cout_str);
///doit(make_tcn(schema, table, AVGDATABLOCK_COL), cout_str);
///doit(make_tcn(schema, table, CLUSTERFACTOR_COL), cout_str);
table = SYSINDEX_TABLE;
doit(make_tcn(schema, table, SCHEMA_COL), cout_str);
doit(make_tcn(schema, table, TABLENAME_COL), cout_str);
///doit(make_tcn(schema, table, COLNAME_COL), cout_str);
doit(make_tcn(schema, table, INDEXNAME_COL), cout_str);
doit(make_tcn(schema, table, INDEXTYPE_COL), cout_str);
doit(make_tcn(schema, table, MULTICOLFLAG_COL), cout_str);
///doit(make_tcn(schema, table, OBJECTID_COL), cout_str);
///doit(make_tcn(schema, table, DICTOID_COL), cout_str);
doit(make_tcn(schema, table, LISTOBJID_COL), cout_str);
doit(make_tcn(schema, table, TREEOBJID_COL), cout_str);
///doit(make_tcn(schema, table, DATATYPE_COL), cout_str);
///doit(make_tcn(schema, table, COLUMNTYPE_COL), cout_str);
///doit(make_tcn(schema, table, COLUMNLEN_COL), cout_str);
///doit(make_tcn(schema, table, COLUMNPOS_COL), cout_str);
doit(make_tcn(schema, table, CREATEDATE_COL), cout_str);
doit(make_tcn(schema, table, LASTUPDATE_COL), cout_str);
///doit(make_tcn(schema, table, DEFAULTVAL_COL), cout_str);
///doit(make_tcn(schema, table, NULLABLE_COL), cout_str);
///doit(make_tcn(schema, table, SCALE_COL), cout_str);
///doit(make_tcn(schema, table, PRECISION_COL), cout_str);
///doit(make_tcn(schema, table, NUMNULLS_COL), cout_str);
///doit(make_tcn(schema, table, NUMDISTINCTVAL_COL), cout_str);
///doit(make_tcn(schema, table, MINVAL_COL), cout_str);
///doit(make_tcn(schema, table, MAXVAL_COL), cout_str);
///doit(make_tcn(schema, table, DENSITY_COL), cout_str);
///doit(make_tcn(schema, table, AVGRECORDLEN_COL), cout_str);
doit(make_tcn(schema, table, RECORDCOUNT_COL), cout_str);
doit(make_tcn(schema, table, LASTANYLDATE_COL), cout_str);
doit(make_tcn(schema, table, SAMPLESIZE_COL), cout_str);
///doit(make_tcn(schema, table, PROPERTY_COL), cout_str);
///doit(make_tcn(schema, table, AUTOINC_COL), cout_str);
///doit(make_tcn(schema, table, DATANAME_COL), cout_str);
///doit(make_tcn(schema, table, CATEGORY_COL), cout_str);
///doit(make_tcn(schema, table, SIZE_COL), cout_str);
///doit(make_tcn(schema, table, DESC_COL), cout_str);
///doit(make_tcn(schema, table, INIT_COL), cout_str);
///doit(make_tcn(schema, table, NEXT_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTNAME_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTNUM_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTTYPE_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTPRIM_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTTEXT_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTSTATUS_COL), cout_str);
doit(make_tcn(schema, table, TREELEVEL_COL), cout_str);
doit(make_tcn(schema, table, LEAFCOUNT_COL), cout_str);
doit(make_tcn(schema, table, DISTINCTKEYS_COL), cout_str);
doit(make_tcn(schema, table, LEAFBLOCKS_COL), cout_str);
doit(make_tcn(schema, table, AVGLEAFCOUNT_COL), cout_str);
doit(make_tcn(schema, table, AVGDATABLOCK_COL), cout_str);
doit(make_tcn(schema, table, CLUSTERFACTOR_COL), cout_str);
table = SYSINDEXCOL_TABLE;
doit(make_tcn(schema, table, SCHEMA_COL), cout_str);
doit(make_tcn(schema, table, TABLENAME_COL), cout_str);
doit(make_tcn(schema, table, COLNAME_COL), cout_str);
doit(make_tcn(schema, table, INDEXNAME_COL), cout_str);
///doit(make_tcn(schema, table, INDEXTYPE_COL), cout_str);
///doit(make_tcn(schema, table, MULTICOLFLAG_COL), cout_str);
///doit(make_tcn(schema, table, OBJECTID_COL), cout_str);
///doit(make_tcn(schema, table, DICTOID_COL), cout_str);
///doit(make_tcn(schema, table, LISTOBJID_COL), cout_str);
///doit(make_tcn(schema, table, TREEOBJID_COL), cout_str);
///doit(make_tcn(schema, table, DATATYPE_COL), cout_str);
///doit(make_tcn(schema, table, COLUMNTYPE_COL), cout_str);
///doit(make_tcn(schema, table, COLUMNLEN_COL), cout_str);
doit(make_tcn(schema, table, COLUMNPOS_COL), cout_str);
///doit(make_tcn(schema, table, CREATEDATE_COL), cout_str);
///doit(make_tcn(schema, table, LASTUPDATE_COL), cout_str);
///doit(make_tcn(schema, table, DEFAULTVAL_COL), cout_str);
///doit(make_tcn(schema, table, NULLABLE_COL), cout_str);
///doit(make_tcn(schema, table, SCALE_COL), cout_str);
///doit(make_tcn(schema, table, PRECISION_COL), cout_str);
///doit(make_tcn(schema, table, NUMNULLS_COL), cout_str);
///doit(make_tcn(schema, table, NUMDISTINCTVAL_COL), cout_str);
///doit(make_tcn(schema, table, MINVAL_COL), cout_str);
///doit(make_tcn(schema, table, MAXVAL_COL), cout_str);
///doit(make_tcn(schema, table, DENSITY_COL), cout_str);
///doit(make_tcn(schema, table, AVGRECORDLEN_COL), cout_str);
///doit(make_tcn(schema, table, RECORDCOUNT_COL), cout_str);
///doit(make_tcn(schema, table, LASTANYLDATE_COL), cout_str);
///doit(make_tcn(schema, table, SAMPLESIZE_COL), cout_str);
///doit(make_tcn(schema, table, PROPERTY_COL), cout_str);
///doit(make_tcn(schema, table, AUTOINC_COL), cout_str);
///doit(make_tcn(schema, table, DATANAME_COL), cout_str);
///doit(make_tcn(schema, table, CATEGORY_COL), cout_str);
///doit(make_tcn(schema, table, SIZE_COL), cout_str);
///doit(make_tcn(schema, table, DESC_COL), cout_str);
///doit(make_tcn(schema, table, INIT_COL), cout_str);
///doit(make_tcn(schema, table, NEXT_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTNAME_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTNUM_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTTYPE_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTPRIM_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTTEXT_COL), cout_str);
///doit(make_tcn(schema, table, CONSTRAINTSTATUS_COL), cout_str);
///doit(make_tcn(schema, table, TREELEVEL_COL), cout_str);
///doit(make_tcn(schema, table, LEAFCOUNT_COL), cout_str);
///doit(make_tcn(schema, table, DISTINCTKEYS_COL), cout_str);
///doit(make_tcn(schema, table, LEAFBLOCKS_COL), cout_str);
///doit(make_tcn(schema, table, AVGLEAFCOUNT_COL), cout_str);
///doit(make_tcn(schema, table, AVGDATABLOCK_COL), cout_str);
///doit(make_tcn(schema, table, CLUSTERFACTOR_COL), cout_str);
}
cout_str << ends;
::write(fd, cout_str.str().c_str(), cout_str.str().length());
return 0;
}

Some files were not shown because too many files have changed in this diff Show More