Loading ndb/include/logger/Logger.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ public: /** The log levels. NOTE: Could not use the name LogLevel since * it caused conflicts with another class. */ enum LoggerLevel {LL_OFF, LL_DEBUG, LL_INFO, LL_WARNING, LL_ERROR, enum LoggerLevel {LL_ON, LL_DEBUG, LL_INFO, LL_WARNING, LL_ERROR, LL_CRITICAL, LL_ALERT, LL_ALL}; /** Loading ndb/include/mgmapi/mgmapi.h +12 −2 Original line number Diff line number Diff line Loading @@ -244,7 +244,9 @@ extern "C" { * Log severities (used to filter the cluster log) */ enum ndb_mgm_clusterlog_level { NDB_MGM_CLUSTERLOG_OFF = 0, /*< Cluster log off*/ NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL = -1, /* must range from 0 and up, indexes into an array */ NDB_MGM_CLUSTERLOG_ON = 0, /*< Cluster log on*/ NDB_MGM_CLUSTERLOG_DEBUG = 1, /*< Used in NDB Cluster *< developement */ Loading @@ -264,7 +266,8 @@ extern "C" { *< corrected immediately, *< such as a corrupted system */ NDB_MGM_CLUSTERLOG_ALL = 7 /*< All severities on*/ /* must be next number, works as bound in loop */ NDB_MGM_CLUSTERLOG_ALL = 7 /*< All severities */ }; /** Loading Loading @@ -580,11 +583,13 @@ extern "C" { * * @param handle NDB management handle. * @param level A cluster log level to filter. * @param enable set 1=enable 0=disable * @param reply Reply message. * @return -1 on error. */ int ndb_mgm_filter_clusterlog(NdbMgmHandle handle, enum ndb_mgm_clusterlog_level level, int enable, struct ndb_mgm_reply* reply); /** Loading Loading @@ -620,6 +625,11 @@ extern "C" { int level, struct ndb_mgm_reply* reply); ndb_mgm_clusterlog_level ndb_mgm_match_clusterlog_level(const char * name); const char * ndb_mgm_get_clusterlog_level_string(enum ndb_mgm_clusterlog_level level); /** * Set log category and levels for the Node * Loading ndb/src/common/logger/Logger.cpp +13 −4 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ // // PUBLIC // const char* Logger::LoggerLevelNames[] = { "OFF ", const char* Logger::LoggerLevelNames[] = { "ON ", "DEBUG ", "INFO ", "WARNING ", Loading @@ -46,7 +46,9 @@ Logger::Logger() : m_pSyslogHandler(NULL) { m_pHandlerList = new LogHandlerList(); m_logLevels[LL_INFO] = true; disable(LL_ALL); enable(LL_ON); enable(LL_INFO); } Logger::~Logger() Loading Loading @@ -227,6 +229,13 @@ Logger::removeAllHandlers() bool Logger::isEnable(LoggerLevel logLevel) const { if (logLevel == LL_ALL) { for (unsigned i = 1; i < MAX_LOG_LEVELS; i++) if (!m_logLevels[i]) return false; return true; } return m_logLevels[logLevel]; } Loading @@ -235,7 +244,7 @@ Logger::enable(LoggerLevel logLevel) { if (logLevel == LL_ALL) { for (unsigned i = 1; i < MAX_LOG_LEVELS; i++) for (unsigned i = 0; i < MAX_LOG_LEVELS; i++) { m_logLevels[i] = true; } Loading Loading @@ -337,7 +346,7 @@ Logger::debug(const char* pMsg, ...) const void Logger::log(LoggerLevel logLevel, const char* pMsg, va_list ap) const { if (m_logLevels[LL_OFF] == false && m_logLevels[logLevel]) if (m_logLevels[LL_ON] && m_logLevels[logLevel]) { LogHandler* pHandler = NULL; while ( (pHandler = m_pHandlerList->next()) != NULL) Loading ndb/src/mgmapi/mgmapi.cpp +64 −15 Original line number Diff line number Diff line Loading @@ -914,21 +914,67 @@ ndb_mgm_restart(NdbMgmHandle handle, int no_of_nodes, const int *node_list) return ndb_mgm_restart2(handle, no_of_nodes, node_list, 0, 0, 0); } static const char *clusterlog_level_names[]= { "enabled", "debug", "info", "warning", "error", "critical", "alert" }; struct ndb_mgm_clusterlog_levels { const char* name; enum ndb_mgm_clusterlog_level level; } clusterlog_levels[] = { { clusterlog_level_names[0], NDB_MGM_CLUSTERLOG_ON }, { clusterlog_level_names[1], NDB_MGM_CLUSTERLOG_DEBUG }, { clusterlog_level_names[2], NDB_MGM_CLUSTERLOG_INFO }, { clusterlog_level_names[3], NDB_MGM_CLUSTERLOG_WARNING }, { clusterlog_level_names[4], NDB_MGM_CLUSTERLOG_ERROR }, { clusterlog_level_names[5], NDB_MGM_CLUSTERLOG_CRITICAL }, { clusterlog_level_names[6], NDB_MGM_CLUSTERLOG_ALERT }, { "all", NDB_MGM_CLUSTERLOG_ALL }, { 0, NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL }, }; extern "C" ndb_mgm_clusterlog_level ndb_mgm_match_clusterlog_level(const char * name) { if(name == 0) return NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL; for(int i = 0; clusterlog_levels[i].name !=0 ; i++) if(strcasecmp(name, clusterlog_levels[i].name) == 0) return clusterlog_levels[i].level; return NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL; } extern "C" const char * ndb_mgm_get_clusterlog_level_string(enum ndb_mgm_clusterlog_level level) { int i= (int)level; if (i >= 0 && i < (int)NDB_MGM_CLUSTERLOG_ALL) return clusterlog_level_names[i]; for(i = (int)NDB_MGM_CLUSTERLOG_ALL; clusterlog_levels[i].name != 0; i++) if(clusterlog_levels[i].level == level) return clusterlog_levels[i].name; return 0; } extern "C" unsigned int * ndb_mgm_get_logfilter(NdbMgmHandle handle) { SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_get_logfilter"); static Uint32 enabled[7] = {0,0,0,0,0,0,0}; static Uint32 enabled[(int)NDB_MGM_CLUSTERLOG_ALL] = {0,0,0,0,0,0,0}; const ParserRow<ParserDummy> getinfo_reply[] = { MGM_CMD("clusterlog", NULL, ""), MGM_ARG("enabled", Int, Mandatory, ""), MGM_ARG("debug", Int, Mandatory, ""), MGM_ARG("info", Int, Mandatory, ""), MGM_ARG("warning", Int, Mandatory, ""), MGM_ARG("error", Int, Mandatory, ""), MGM_ARG("critical", Int, Mandatory, ""), MGM_ARG("alert", Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[0], Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[1], Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[2], Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[3], Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[4], Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[5], Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[6], Int, Mandatory, ""), }; CHECK_HANDLE(handle, NULL); CHECK_CONNECTED(handle, NULL); Loading @@ -938,10 +984,8 @@ ndb_mgm_get_logfilter(NdbMgmHandle handle) reply = ndb_mgm_call(handle, getinfo_reply, "get info clusterlog", &args); CHECK_REPLY(reply, NULL); const char *names[] = { "enabled", "debug", "info", "warning", "error", "critical", "alert" }; for(int i=0; i < 7; i++) { reply->get(names[i], &enabled[i]); for(int i=0; i < (int)NDB_MGM_CLUSTERLOG_ALL; i++) { reply->get(clusterlog_level_names[i], &enabled[i]); } return enabled; } Loading @@ -950,6 +994,7 @@ extern "C" int ndb_mgm_filter_clusterlog(NdbMgmHandle handle, enum ndb_mgm_clusterlog_level level, int enable, struct ndb_mgm_reply* /*reply*/) { SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_filter_clusterlog"); Loading @@ -964,6 +1009,7 @@ ndb_mgm_filter_clusterlog(NdbMgmHandle handle, Properties args; args.put("level", level); args.put("enable", enable); const Properties *reply; reply = ndb_mgm_call(handle, filter_reply, "set logfilter", &args); Loading @@ -971,11 +1017,14 @@ ndb_mgm_filter_clusterlog(NdbMgmHandle handle, BaseString result; reply->get("result", result); if(strcmp(result.c_str(), "1") == 0) { if (strcmp(result.c_str(), "1") == 0) retval = 1; else if (strcmp(result.c_str(), "0") == 0) retval = 0; } else { else { SET_ERROR(handle, EINVAL, result.c_str()); retval = -1; } delete reply; return retval; Loading ndb/src/mgmclient/CommandInterpreter.cpp +145 −159 Original line number Diff line number Diff line Loading @@ -264,9 +264,9 @@ static const char* helpText = "START BACKUP Start backup\n" "ABORT BACKUP <backup id> Abort backup\n" "SHUTDOWN Shutdown all processes in cluster and quit\n" "CLUSTERLOG ON Enable Cluster logging\n" "CLUSTERLOG OFF Disable Cluster logging\n" "CLUSTERLOG FILTER <severity> Toggle severity filter on/off\n" "CLUSTERLOG ON [<severity>] ... Enable Cluster logging\n" "CLUSTERLOG OFF [<severity>] ... Disable Cluster logging\n" "CLUSTERLOG TOGGLE [<severity>] ... Toggle severity filter on/off\n" "CLUSTERLOG INFO Print cluster log information\n" "<id> START Start DB node (started with -n)\n" "<id> RESTART [-n] [-i] Restart DB node\n" Loading Loading @@ -666,11 +666,9 @@ CommandInterpreter::analyseAfterFirstToken(int processId, if(processId == -1){ executeForAll(command, fun, allAfterSecondToken); } else { if(strcasecmp(command, "STATUS") != 0) ndbout_c("Executing %s on node %d.", command, processId); (this->*fun)(processId, allAfterSecondToken, false); ndbout << endl; } ndbout << endl; } /** Loading Loading @@ -733,12 +731,8 @@ CommandInterpreter::executeForAll(const char * cmd, ExecuteFunction fun, return; } NdbAutoPtr<char> ap1((char*)cl); while(get_next_nodeid(cl, &nodeId, NDB_MGM_NODE_TYPE_NDB)) { if(strcasecmp(cmd, "STATUS") != 0) ndbout_c("Executing %s on node %d.", cmd, nodeId); while(get_next_nodeid(cl, &nodeId, NDB_MGM_NODE_TYPE_NDB)) (this->*fun)(nodeId, allAfterSecondToken, true); ndbout << endl; } // while } } Loading Loading @@ -1137,30 +1131,93 @@ CommandInterpreter::executeConnect(char* parameters) void CommandInterpreter::executeClusterLog(char* parameters) { DBUG_ENTER("CommandInterpreter::executeClusterLog"); int i; if (parameters != 0 && strlen(parameters) != 0) { if (emptyString(parameters)) { ndbout << "Missing argument." << endl; DBUG_VOID_RETURN; } enum ndb_mgm_clusterlog_level severity = NDB_MGM_CLUSTERLOG_ALL; int isOk = true; char name[12]; bool noArgs = false; char * tmpString = my_strdup(parameters,MYF(MY_WME)); My_auto_ptr<char> ap1(tmpString); char * tmpPtr = 0; char * item = strtok_r(tmpString, " ", &tmpPtr); int enable; Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv); if(enabled == NULL) { ndbout << "Couldn't get status" << endl; printError(); DBUG_VOID_RETURN; } /******************** * CLUSTERLOG FILTER * CLUSTERLOG INFO ********************/ if (strcasecmp(item, "FILTER") == 0) { if (strcasecmp(item, "INFO") == 0) { DBUG_PRINT("info",("INFO")); if(enabled[0] == 0) { ndbout << "Cluster logging is disabled." << endl; DBUG_VOID_RETURN; } #if 0 for(i = 0; i<7;i++) printf("enabled[%d] = %d\n", i, enabled[i]); #endif ndbout << "Severities enabled: "; for(i = 1; i < (int)NDB_MGM_CLUSTERLOG_ALL; i++) { const char *str= ndb_mgm_get_clusterlog_level_string((ndb_mgm_clusterlog_level)i); if (str == 0) { DBUG_ASSERT(false); continue; } if(enabled[i]) ndbout << BaseString(str).ndb_toupper() << " "; } ndbout << endl; DBUG_VOID_RETURN; } else if (strcasecmp(item, "FILTER") == 0 || strcasecmp(item, "TOGGLE") == 0) { DBUG_PRINT("info",("TOGGLE")); enable= -1; } else if (strcasecmp(item, "OFF") == 0) { DBUG_PRINT("info",("OFF")); enable= 0; } else if (strcasecmp(item, "ON") == 0) { DBUG_PRINT("info",("ON")); enable= 1; } else { ndbout << "Invalid argument." << endl; DBUG_VOID_RETURN; } int res_enable; item = strtok_r(NULL, " ", &tmpPtr); if (item == NULL) { noArgs = true; res_enable= ndb_mgm_filter_clusterlog(m_mgmsrv, NDB_MGM_CLUSTERLOG_ON, enable, NULL); if (res_enable < 0) { ndbout << "Couldn't set filter" << endl; printError(); DBUG_VOID_RETURN; } ndbout << "Cluster logging is " << (res_enable ? "enabled.":"disabled") << endl; DBUG_VOID_RETURN; } while (item != NULL) { snprintf(name, sizeof(name), item); do { severity= NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL; if (strcasecmp(item, "ALL") == 0) { severity = NDB_MGM_CLUSTERLOG_ALL; } else if (strcasecmp(item, "ALERT") == 0) { Loading @@ -1175,106 +1232,29 @@ CommandInterpreter::executeClusterLog(char* parameters) severity = NDB_MGM_CLUSTERLOG_INFO; } else if (strcasecmp(item, "DEBUG") == 0) { severity = NDB_MGM_CLUSTERLOG_DEBUG; } else if (strcasecmp(item, "OFF") == 0) { severity = NDB_MGM_CLUSTERLOG_OFF; } else { isOk = false; } item = strtok_r(NULL, " ", &tmpPtr); } // while(item != NULL){ if (noArgs) { ndbout << "Missing argument(s)." << endl; } else if (isOk) { if(ndb_mgm_filter_clusterlog(m_mgmsrv, severity, NULL)) { if(strcasecmp(name, "ALL") == 0) { ndbout << "All severities levels enabled." << endl; } else if(strcasecmp(name, "OFF") == 0) { ndbout << "Cluster logging enabled." << endl; } else { ndbout << name << " events disabled." << endl; } } else { if(strcasecmp(name, "ALL") == 0) { ndbout << "All severities levels disabled." << endl; } else if(strcasecmp(name, "OFF") == 0) { ndbout << "Cluster logging disabled." << endl; } else { ndbout << name << " events enabled." << endl; } } } else { ndbout << "Invalid severity level." << endl; } /******************** * CLUSTERLOG INFO ********************/ } else if (strcasecmp(item, "INFO") == 0) { Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv); if(enabled == NULL) { ndbout << "Couldn't get status" << endl; printError(); return; } const char* names[] = {"ENABLED", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL", "ALERT"}; if(enabled[0]) ndbout << "Cluster logging is disabled." << endl; for(i = 0; i<7;i++) printf("enabled[%d] = %d\n", i, enabled[i]); ndbout << "Severities enabled: "; for(i = 1; i < 7; i++) { if(enabled[i]) ndbout << names[i] << " "; } ndbout << endl; /******************** * CLUSTERLOG OFF ********************/ } else if (strcasecmp(item, "OFF") == 0) { Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv); if(enabled == NULL) { ndbout << "Couldn't get status" << endl; printError(); return; } else if (strcasecmp(item, "OFF") == 0 || strcasecmp(item, "ON") == 0) { if (enable < 0) // only makes sense with toggle severity = NDB_MGM_CLUSTERLOG_ON; } if(!enabled[0]) { ndb_mgm_filter_clusterlog(m_mgmsrv, NDB_MGM_CLUSTERLOG_OFF, NULL); ndbout << "Cluster logging is disabled." << endl; } else { ndbout << "Cluster logging is already disabled." << endl; if (severity == NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL) { ndbout << "Invalid severity level: " << item << endl; DBUG_VOID_RETURN; } /******************** * CLUSTERLOG ON ********************/ } else if (strcasecmp(item, "ON") == 0) { Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv); if(enabled == NULL) { ndbout << "Could not get status" << endl; res_enable = ndb_mgm_filter_clusterlog(m_mgmsrv, severity, enable, NULL); if (res_enable < 0) { ndbout << "Couldn't set filter" << endl; printError(); return; DBUG_VOID_RETURN; } if(enabled[0]) { ndb_mgm_filter_clusterlog(m_mgmsrv, NDB_MGM_CLUSTERLOG_OFF, NULL); ndbout << "Cluster logging is enabled." << endl; } else { ndbout << "Cluster logging is already enabled." << endl; ndbout << item << " " << (res_enable ? "enabled":"disabled") << endl; } } else { ndbout << "Invalid argument." << endl; } item = strtok_r(NULL, " ", &tmpPtr); } while(item != NULL); } else { ndbout << "Missing argument." << endl; } DBUG_VOID_RETURN; } //***************************************************************************** Loading Loading @@ -1404,7 +1384,7 @@ CommandInterpreter::executeRestart(int processId, const char* parameters, if(all) ndbout << "NDB Cluster is being restarted." << endl; else ndbout_c("Database node %d is being restarted.", processId); ndbout_c("Node %d is being restarted.", processId); } } Loading Loading @@ -1451,7 +1431,7 @@ CommandInterpreter::executeStatus(int processId, const char* parameters, bool all) { if (! emptyString(parameters)) { ndbout << "No parameters expected to this command." << endl; ndbout_c("No parameters expected to this command."); return; } Loading Loading @@ -1495,6 +1475,8 @@ CommandInterpreter::executeStatus(int processId, getMajor(version) , getMinor(version), getBuild(version)); else ndbout << endl; } Loading @@ -1506,7 +1488,10 @@ CommandInterpreter::executeLogLevel(int processId, const char* parameters, bool all) { (void) all; if (emptyString(parameters)) { ndbout << "Expected argument" << endl; return; } BaseString tmp(parameters); Vector<BaseString> spec; tmp.split(spec, "="); Loading @@ -1532,6 +1517,8 @@ CommandInterpreter::executeLogLevel(int processId, const char* parameters, return; } ndbout << "Executing LOGLEVEL on node " << processId << flush; struct ndb_mgm_reply reply; int result; result = ndb_mgm_set_loglevel_node(m_mgmsrv, Loading @@ -1541,11 +1528,10 @@ CommandInterpreter::executeLogLevel(int processId, const char* parameters, &reply); if (result < 0) { ndbout_c("Executing LOGLEVEL on node %d failed.", processId); ndbout_c(" failed."); printError(); } else { ndbout << "Executing LOGLEVEL on node " << processId << " OK!" << endl; ndbout_c(" OK!"); } } Loading Loading @@ -1840,36 +1826,36 @@ CommandInterpreter::executeEventReporting(int processId, spec[0].trim().ndb_toupper(); int category = ndb_mgm_match_event_category(spec[0].c_str()); if(category == NDB_MGM_ILLEGAL_EVENT_CATEGORY){ category = atoi(spec[0].c_str()); if(category < NDB_MGM_MIN_EVENT_CATEGORY || if(!convert(spec[0].c_str(), category) || category < NDB_MGM_MIN_EVENT_CATEGORY || category > NDB_MGM_MAX_EVENT_CATEGORY){ ndbout << "Unknown category: \"" << spec[0].c_str() << "\"" << endl; return; } } int level = atoi(spec[1].c_str()); if(level < 0 || level > 15){ int level; if (!convert(spec[1].c_str(),level)) { ndbout << "Invalid level: " << spec[1].c_str() << endl; return; } ndbout << "Executing CLUSTERLOG on node " << processId << flush; struct ndb_mgm_reply reply; int result; result = ndb_mgm_set_loglevel_clusterlog(m_mgmsrv, processId, // fast fix - pekka processId, (ndb_mgm_event_category)category, level, &reply); if (result != 0) { ndbout_c("Executing CLUSTERLOG on node %d failed", processId); ndbout_c(" failed."); printError(); } else { ndbout << "Executing CLUSTERLOG on node " << processId << " OK!" << endl; ndbout_c(" OK!"); } } Loading Loading
ndb/include/logger/Logger.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ public: /** The log levels. NOTE: Could not use the name LogLevel since * it caused conflicts with another class. */ enum LoggerLevel {LL_OFF, LL_DEBUG, LL_INFO, LL_WARNING, LL_ERROR, enum LoggerLevel {LL_ON, LL_DEBUG, LL_INFO, LL_WARNING, LL_ERROR, LL_CRITICAL, LL_ALERT, LL_ALL}; /** Loading
ndb/include/mgmapi/mgmapi.h +12 −2 Original line number Diff line number Diff line Loading @@ -244,7 +244,9 @@ extern "C" { * Log severities (used to filter the cluster log) */ enum ndb_mgm_clusterlog_level { NDB_MGM_CLUSTERLOG_OFF = 0, /*< Cluster log off*/ NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL = -1, /* must range from 0 and up, indexes into an array */ NDB_MGM_CLUSTERLOG_ON = 0, /*< Cluster log on*/ NDB_MGM_CLUSTERLOG_DEBUG = 1, /*< Used in NDB Cluster *< developement */ Loading @@ -264,7 +266,8 @@ extern "C" { *< corrected immediately, *< such as a corrupted system */ NDB_MGM_CLUSTERLOG_ALL = 7 /*< All severities on*/ /* must be next number, works as bound in loop */ NDB_MGM_CLUSTERLOG_ALL = 7 /*< All severities */ }; /** Loading Loading @@ -580,11 +583,13 @@ extern "C" { * * @param handle NDB management handle. * @param level A cluster log level to filter. * @param enable set 1=enable 0=disable * @param reply Reply message. * @return -1 on error. */ int ndb_mgm_filter_clusterlog(NdbMgmHandle handle, enum ndb_mgm_clusterlog_level level, int enable, struct ndb_mgm_reply* reply); /** Loading Loading @@ -620,6 +625,11 @@ extern "C" { int level, struct ndb_mgm_reply* reply); ndb_mgm_clusterlog_level ndb_mgm_match_clusterlog_level(const char * name); const char * ndb_mgm_get_clusterlog_level_string(enum ndb_mgm_clusterlog_level level); /** * Set log category and levels for the Node * Loading
ndb/src/common/logger/Logger.cpp +13 −4 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ // // PUBLIC // const char* Logger::LoggerLevelNames[] = { "OFF ", const char* Logger::LoggerLevelNames[] = { "ON ", "DEBUG ", "INFO ", "WARNING ", Loading @@ -46,7 +46,9 @@ Logger::Logger() : m_pSyslogHandler(NULL) { m_pHandlerList = new LogHandlerList(); m_logLevels[LL_INFO] = true; disable(LL_ALL); enable(LL_ON); enable(LL_INFO); } Logger::~Logger() Loading Loading @@ -227,6 +229,13 @@ Logger::removeAllHandlers() bool Logger::isEnable(LoggerLevel logLevel) const { if (logLevel == LL_ALL) { for (unsigned i = 1; i < MAX_LOG_LEVELS; i++) if (!m_logLevels[i]) return false; return true; } return m_logLevels[logLevel]; } Loading @@ -235,7 +244,7 @@ Logger::enable(LoggerLevel logLevel) { if (logLevel == LL_ALL) { for (unsigned i = 1; i < MAX_LOG_LEVELS; i++) for (unsigned i = 0; i < MAX_LOG_LEVELS; i++) { m_logLevels[i] = true; } Loading Loading @@ -337,7 +346,7 @@ Logger::debug(const char* pMsg, ...) const void Logger::log(LoggerLevel logLevel, const char* pMsg, va_list ap) const { if (m_logLevels[LL_OFF] == false && m_logLevels[logLevel]) if (m_logLevels[LL_ON] && m_logLevels[logLevel]) { LogHandler* pHandler = NULL; while ( (pHandler = m_pHandlerList->next()) != NULL) Loading
ndb/src/mgmapi/mgmapi.cpp +64 −15 Original line number Diff line number Diff line Loading @@ -914,21 +914,67 @@ ndb_mgm_restart(NdbMgmHandle handle, int no_of_nodes, const int *node_list) return ndb_mgm_restart2(handle, no_of_nodes, node_list, 0, 0, 0); } static const char *clusterlog_level_names[]= { "enabled", "debug", "info", "warning", "error", "critical", "alert" }; struct ndb_mgm_clusterlog_levels { const char* name; enum ndb_mgm_clusterlog_level level; } clusterlog_levels[] = { { clusterlog_level_names[0], NDB_MGM_CLUSTERLOG_ON }, { clusterlog_level_names[1], NDB_MGM_CLUSTERLOG_DEBUG }, { clusterlog_level_names[2], NDB_MGM_CLUSTERLOG_INFO }, { clusterlog_level_names[3], NDB_MGM_CLUSTERLOG_WARNING }, { clusterlog_level_names[4], NDB_MGM_CLUSTERLOG_ERROR }, { clusterlog_level_names[5], NDB_MGM_CLUSTERLOG_CRITICAL }, { clusterlog_level_names[6], NDB_MGM_CLUSTERLOG_ALERT }, { "all", NDB_MGM_CLUSTERLOG_ALL }, { 0, NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL }, }; extern "C" ndb_mgm_clusterlog_level ndb_mgm_match_clusterlog_level(const char * name) { if(name == 0) return NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL; for(int i = 0; clusterlog_levels[i].name !=0 ; i++) if(strcasecmp(name, clusterlog_levels[i].name) == 0) return clusterlog_levels[i].level; return NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL; } extern "C" const char * ndb_mgm_get_clusterlog_level_string(enum ndb_mgm_clusterlog_level level) { int i= (int)level; if (i >= 0 && i < (int)NDB_MGM_CLUSTERLOG_ALL) return clusterlog_level_names[i]; for(i = (int)NDB_MGM_CLUSTERLOG_ALL; clusterlog_levels[i].name != 0; i++) if(clusterlog_levels[i].level == level) return clusterlog_levels[i].name; return 0; } extern "C" unsigned int * ndb_mgm_get_logfilter(NdbMgmHandle handle) { SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_get_logfilter"); static Uint32 enabled[7] = {0,0,0,0,0,0,0}; static Uint32 enabled[(int)NDB_MGM_CLUSTERLOG_ALL] = {0,0,0,0,0,0,0}; const ParserRow<ParserDummy> getinfo_reply[] = { MGM_CMD("clusterlog", NULL, ""), MGM_ARG("enabled", Int, Mandatory, ""), MGM_ARG("debug", Int, Mandatory, ""), MGM_ARG("info", Int, Mandatory, ""), MGM_ARG("warning", Int, Mandatory, ""), MGM_ARG("error", Int, Mandatory, ""), MGM_ARG("critical", Int, Mandatory, ""), MGM_ARG("alert", Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[0], Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[1], Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[2], Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[3], Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[4], Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[5], Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[6], Int, Mandatory, ""), }; CHECK_HANDLE(handle, NULL); CHECK_CONNECTED(handle, NULL); Loading @@ -938,10 +984,8 @@ ndb_mgm_get_logfilter(NdbMgmHandle handle) reply = ndb_mgm_call(handle, getinfo_reply, "get info clusterlog", &args); CHECK_REPLY(reply, NULL); const char *names[] = { "enabled", "debug", "info", "warning", "error", "critical", "alert" }; for(int i=0; i < 7; i++) { reply->get(names[i], &enabled[i]); for(int i=0; i < (int)NDB_MGM_CLUSTERLOG_ALL; i++) { reply->get(clusterlog_level_names[i], &enabled[i]); } return enabled; } Loading @@ -950,6 +994,7 @@ extern "C" int ndb_mgm_filter_clusterlog(NdbMgmHandle handle, enum ndb_mgm_clusterlog_level level, int enable, struct ndb_mgm_reply* /*reply*/) { SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_filter_clusterlog"); Loading @@ -964,6 +1009,7 @@ ndb_mgm_filter_clusterlog(NdbMgmHandle handle, Properties args; args.put("level", level); args.put("enable", enable); const Properties *reply; reply = ndb_mgm_call(handle, filter_reply, "set logfilter", &args); Loading @@ -971,11 +1017,14 @@ ndb_mgm_filter_clusterlog(NdbMgmHandle handle, BaseString result; reply->get("result", result); if(strcmp(result.c_str(), "1") == 0) { if (strcmp(result.c_str(), "1") == 0) retval = 1; else if (strcmp(result.c_str(), "0") == 0) retval = 0; } else { else { SET_ERROR(handle, EINVAL, result.c_str()); retval = -1; } delete reply; return retval; Loading
ndb/src/mgmclient/CommandInterpreter.cpp +145 −159 Original line number Diff line number Diff line Loading @@ -264,9 +264,9 @@ static const char* helpText = "START BACKUP Start backup\n" "ABORT BACKUP <backup id> Abort backup\n" "SHUTDOWN Shutdown all processes in cluster and quit\n" "CLUSTERLOG ON Enable Cluster logging\n" "CLUSTERLOG OFF Disable Cluster logging\n" "CLUSTERLOG FILTER <severity> Toggle severity filter on/off\n" "CLUSTERLOG ON [<severity>] ... Enable Cluster logging\n" "CLUSTERLOG OFF [<severity>] ... Disable Cluster logging\n" "CLUSTERLOG TOGGLE [<severity>] ... Toggle severity filter on/off\n" "CLUSTERLOG INFO Print cluster log information\n" "<id> START Start DB node (started with -n)\n" "<id> RESTART [-n] [-i] Restart DB node\n" Loading Loading @@ -666,11 +666,9 @@ CommandInterpreter::analyseAfterFirstToken(int processId, if(processId == -1){ executeForAll(command, fun, allAfterSecondToken); } else { if(strcasecmp(command, "STATUS") != 0) ndbout_c("Executing %s on node %d.", command, processId); (this->*fun)(processId, allAfterSecondToken, false); ndbout << endl; } ndbout << endl; } /** Loading Loading @@ -733,12 +731,8 @@ CommandInterpreter::executeForAll(const char * cmd, ExecuteFunction fun, return; } NdbAutoPtr<char> ap1((char*)cl); while(get_next_nodeid(cl, &nodeId, NDB_MGM_NODE_TYPE_NDB)) { if(strcasecmp(cmd, "STATUS") != 0) ndbout_c("Executing %s on node %d.", cmd, nodeId); while(get_next_nodeid(cl, &nodeId, NDB_MGM_NODE_TYPE_NDB)) (this->*fun)(nodeId, allAfterSecondToken, true); ndbout << endl; } // while } } Loading Loading @@ -1137,30 +1131,93 @@ CommandInterpreter::executeConnect(char* parameters) void CommandInterpreter::executeClusterLog(char* parameters) { DBUG_ENTER("CommandInterpreter::executeClusterLog"); int i; if (parameters != 0 && strlen(parameters) != 0) { if (emptyString(parameters)) { ndbout << "Missing argument." << endl; DBUG_VOID_RETURN; } enum ndb_mgm_clusterlog_level severity = NDB_MGM_CLUSTERLOG_ALL; int isOk = true; char name[12]; bool noArgs = false; char * tmpString = my_strdup(parameters,MYF(MY_WME)); My_auto_ptr<char> ap1(tmpString); char * tmpPtr = 0; char * item = strtok_r(tmpString, " ", &tmpPtr); int enable; Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv); if(enabled == NULL) { ndbout << "Couldn't get status" << endl; printError(); DBUG_VOID_RETURN; } /******************** * CLUSTERLOG FILTER * CLUSTERLOG INFO ********************/ if (strcasecmp(item, "FILTER") == 0) { if (strcasecmp(item, "INFO") == 0) { DBUG_PRINT("info",("INFO")); if(enabled[0] == 0) { ndbout << "Cluster logging is disabled." << endl; DBUG_VOID_RETURN; } #if 0 for(i = 0; i<7;i++) printf("enabled[%d] = %d\n", i, enabled[i]); #endif ndbout << "Severities enabled: "; for(i = 1; i < (int)NDB_MGM_CLUSTERLOG_ALL; i++) { const char *str= ndb_mgm_get_clusterlog_level_string((ndb_mgm_clusterlog_level)i); if (str == 0) { DBUG_ASSERT(false); continue; } if(enabled[i]) ndbout << BaseString(str).ndb_toupper() << " "; } ndbout << endl; DBUG_VOID_RETURN; } else if (strcasecmp(item, "FILTER") == 0 || strcasecmp(item, "TOGGLE") == 0) { DBUG_PRINT("info",("TOGGLE")); enable= -1; } else if (strcasecmp(item, "OFF") == 0) { DBUG_PRINT("info",("OFF")); enable= 0; } else if (strcasecmp(item, "ON") == 0) { DBUG_PRINT("info",("ON")); enable= 1; } else { ndbout << "Invalid argument." << endl; DBUG_VOID_RETURN; } int res_enable; item = strtok_r(NULL, " ", &tmpPtr); if (item == NULL) { noArgs = true; res_enable= ndb_mgm_filter_clusterlog(m_mgmsrv, NDB_MGM_CLUSTERLOG_ON, enable, NULL); if (res_enable < 0) { ndbout << "Couldn't set filter" << endl; printError(); DBUG_VOID_RETURN; } ndbout << "Cluster logging is " << (res_enable ? "enabled.":"disabled") << endl; DBUG_VOID_RETURN; } while (item != NULL) { snprintf(name, sizeof(name), item); do { severity= NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL; if (strcasecmp(item, "ALL") == 0) { severity = NDB_MGM_CLUSTERLOG_ALL; } else if (strcasecmp(item, "ALERT") == 0) { Loading @@ -1175,106 +1232,29 @@ CommandInterpreter::executeClusterLog(char* parameters) severity = NDB_MGM_CLUSTERLOG_INFO; } else if (strcasecmp(item, "DEBUG") == 0) { severity = NDB_MGM_CLUSTERLOG_DEBUG; } else if (strcasecmp(item, "OFF") == 0) { severity = NDB_MGM_CLUSTERLOG_OFF; } else { isOk = false; } item = strtok_r(NULL, " ", &tmpPtr); } // while(item != NULL){ if (noArgs) { ndbout << "Missing argument(s)." << endl; } else if (isOk) { if(ndb_mgm_filter_clusterlog(m_mgmsrv, severity, NULL)) { if(strcasecmp(name, "ALL") == 0) { ndbout << "All severities levels enabled." << endl; } else if(strcasecmp(name, "OFF") == 0) { ndbout << "Cluster logging enabled." << endl; } else { ndbout << name << " events disabled." << endl; } } else { if(strcasecmp(name, "ALL") == 0) { ndbout << "All severities levels disabled." << endl; } else if(strcasecmp(name, "OFF") == 0) { ndbout << "Cluster logging disabled." << endl; } else { ndbout << name << " events enabled." << endl; } } } else { ndbout << "Invalid severity level." << endl; } /******************** * CLUSTERLOG INFO ********************/ } else if (strcasecmp(item, "INFO") == 0) { Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv); if(enabled == NULL) { ndbout << "Couldn't get status" << endl; printError(); return; } const char* names[] = {"ENABLED", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL", "ALERT"}; if(enabled[0]) ndbout << "Cluster logging is disabled." << endl; for(i = 0; i<7;i++) printf("enabled[%d] = %d\n", i, enabled[i]); ndbout << "Severities enabled: "; for(i = 1; i < 7; i++) { if(enabled[i]) ndbout << names[i] << " "; } ndbout << endl; /******************** * CLUSTERLOG OFF ********************/ } else if (strcasecmp(item, "OFF") == 0) { Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv); if(enabled == NULL) { ndbout << "Couldn't get status" << endl; printError(); return; } else if (strcasecmp(item, "OFF") == 0 || strcasecmp(item, "ON") == 0) { if (enable < 0) // only makes sense with toggle severity = NDB_MGM_CLUSTERLOG_ON; } if(!enabled[0]) { ndb_mgm_filter_clusterlog(m_mgmsrv, NDB_MGM_CLUSTERLOG_OFF, NULL); ndbout << "Cluster logging is disabled." << endl; } else { ndbout << "Cluster logging is already disabled." << endl; if (severity == NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL) { ndbout << "Invalid severity level: " << item << endl; DBUG_VOID_RETURN; } /******************** * CLUSTERLOG ON ********************/ } else if (strcasecmp(item, "ON") == 0) { Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv); if(enabled == NULL) { ndbout << "Could not get status" << endl; res_enable = ndb_mgm_filter_clusterlog(m_mgmsrv, severity, enable, NULL); if (res_enable < 0) { ndbout << "Couldn't set filter" << endl; printError(); return; DBUG_VOID_RETURN; } if(enabled[0]) { ndb_mgm_filter_clusterlog(m_mgmsrv, NDB_MGM_CLUSTERLOG_OFF, NULL); ndbout << "Cluster logging is enabled." << endl; } else { ndbout << "Cluster logging is already enabled." << endl; ndbout << item << " " << (res_enable ? "enabled":"disabled") << endl; } } else { ndbout << "Invalid argument." << endl; } item = strtok_r(NULL, " ", &tmpPtr); } while(item != NULL); } else { ndbout << "Missing argument." << endl; } DBUG_VOID_RETURN; } //***************************************************************************** Loading Loading @@ -1404,7 +1384,7 @@ CommandInterpreter::executeRestart(int processId, const char* parameters, if(all) ndbout << "NDB Cluster is being restarted." << endl; else ndbout_c("Database node %d is being restarted.", processId); ndbout_c("Node %d is being restarted.", processId); } } Loading Loading @@ -1451,7 +1431,7 @@ CommandInterpreter::executeStatus(int processId, const char* parameters, bool all) { if (! emptyString(parameters)) { ndbout << "No parameters expected to this command." << endl; ndbout_c("No parameters expected to this command."); return; } Loading Loading @@ -1495,6 +1475,8 @@ CommandInterpreter::executeStatus(int processId, getMajor(version) , getMinor(version), getBuild(version)); else ndbout << endl; } Loading @@ -1506,7 +1488,10 @@ CommandInterpreter::executeLogLevel(int processId, const char* parameters, bool all) { (void) all; if (emptyString(parameters)) { ndbout << "Expected argument" << endl; return; } BaseString tmp(parameters); Vector<BaseString> spec; tmp.split(spec, "="); Loading @@ -1532,6 +1517,8 @@ CommandInterpreter::executeLogLevel(int processId, const char* parameters, return; } ndbout << "Executing LOGLEVEL on node " << processId << flush; struct ndb_mgm_reply reply; int result; result = ndb_mgm_set_loglevel_node(m_mgmsrv, Loading @@ -1541,11 +1528,10 @@ CommandInterpreter::executeLogLevel(int processId, const char* parameters, &reply); if (result < 0) { ndbout_c("Executing LOGLEVEL on node %d failed.", processId); ndbout_c(" failed."); printError(); } else { ndbout << "Executing LOGLEVEL on node " << processId << " OK!" << endl; ndbout_c(" OK!"); } } Loading Loading @@ -1840,36 +1826,36 @@ CommandInterpreter::executeEventReporting(int processId, spec[0].trim().ndb_toupper(); int category = ndb_mgm_match_event_category(spec[0].c_str()); if(category == NDB_MGM_ILLEGAL_EVENT_CATEGORY){ category = atoi(spec[0].c_str()); if(category < NDB_MGM_MIN_EVENT_CATEGORY || if(!convert(spec[0].c_str(), category) || category < NDB_MGM_MIN_EVENT_CATEGORY || category > NDB_MGM_MAX_EVENT_CATEGORY){ ndbout << "Unknown category: \"" << spec[0].c_str() << "\"" << endl; return; } } int level = atoi(spec[1].c_str()); if(level < 0 || level > 15){ int level; if (!convert(spec[1].c_str(),level)) { ndbout << "Invalid level: " << spec[1].c_str() << endl; return; } ndbout << "Executing CLUSTERLOG on node " << processId << flush; struct ndb_mgm_reply reply; int result; result = ndb_mgm_set_loglevel_clusterlog(m_mgmsrv, processId, // fast fix - pekka processId, (ndb_mgm_event_category)category, level, &reply); if (result != 0) { ndbout_c("Executing CLUSTERLOG on node %d failed", processId); ndbout_c(" failed."); printError(); } else { ndbout << "Executing CLUSTERLOG on node " << processId << " OK!" << endl; ndbout_c(" OK!"); } } Loading