Ndbclustermon formatting changes
Fixed indentation, bracket alignment and other minor things.
This commit is contained in:
@ -33,26 +33,26 @@
|
|||||||
|
|
||||||
#include <mysqlmon.h>
|
#include <mysqlmon.h>
|
||||||
|
|
||||||
static void monitorMain(void *);
|
static void monitorMain(void *);
|
||||||
|
|
||||||
static char *version_str = "V2.1.0";
|
static char *version_str = "V2.1.0";
|
||||||
|
|
||||||
MODULE_INFO info = {
|
MODULE_INFO info = {
|
||||||
MODULE_API_MONITOR,
|
MODULE_API_MONITOR,
|
||||||
MODULE_BETA_RELEASE,
|
MODULE_BETA_RELEASE,
|
||||||
MONITOR_VERSION,
|
MONITOR_VERSION,
|
||||||
"A MySQL cluster SQL node monitor"
|
"A MySQL cluster SQL node monitor"
|
||||||
};
|
};
|
||||||
|
|
||||||
static void *startMonitor(void *,void*);
|
static void *startMonitor(void *, void*);
|
||||||
static void stopMonitor(void *);
|
static void stopMonitor(void *);
|
||||||
static void diagnostics(DCB *, void *);
|
static void diagnostics(DCB *, void *);
|
||||||
bool isNdbEvent(monitor_event_t event);
|
bool isNdbEvent(monitor_event_t event);
|
||||||
|
|
||||||
static MONITOR_OBJECT MyObject = {
|
static MONITOR_OBJECT MyObject = {
|
||||||
startMonitor,
|
startMonitor,
|
||||||
stopMonitor,
|
stopMonitor,
|
||||||
diagnostics
|
diagnostics
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,7 +63,7 @@ static MONITOR_OBJECT MyObject = {
|
|||||||
char *
|
char *
|
||||||
version()
|
version()
|
||||||
{
|
{
|
||||||
return version_str;
|
return version_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,10 +73,10 @@ version()
|
|||||||
void
|
void
|
||||||
ModuleInit()
|
ModuleInit()
|
||||||
{
|
{
|
||||||
LOGIF(LM, (skygw_log_write(
|
LOGIF(LM, (skygw_log_write(
|
||||||
LOGFILE_MESSAGE,
|
LOGFILE_MESSAGE,
|
||||||
"Initialise the MySQL Cluster Monitor module %s.\n",
|
"Initialise the MySQL Cluster Monitor module %s.\n",
|
||||||
version_str)));
|
version_str)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,7 +90,7 @@ ModuleInit()
|
|||||||
MONITOR_OBJECT *
|
MONITOR_OBJECT *
|
||||||
GetModuleObject()
|
GetModuleObject()
|
||||||
{
|
{
|
||||||
return &MyObject;
|
return &MyObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,65 +100,72 @@ GetModuleObject()
|
|||||||
*
|
*
|
||||||
* @return A handle to use when interacting with the monitor
|
* @return A handle to use when interacting with the monitor
|
||||||
*/
|
*/
|
||||||
static void *
|
static void *
|
||||||
startMonitor(void *arg,void* opt)
|
startMonitor(void *arg, void* opt)
|
||||||
{
|
{
|
||||||
MONITOR* mon = (MONITOR*)arg;
|
MONITOR* mon = (MONITOR*) arg;
|
||||||
MYSQL_MONITOR *handle = mon->handle;
|
MYSQL_MONITOR *handle = mon->handle;
|
||||||
CONFIG_PARAMETER* params = (CONFIG_PARAMETER*)opt;
|
CONFIG_PARAMETER* params = (CONFIG_PARAMETER*) opt;
|
||||||
bool have_events = false,script_error = false;
|
bool have_events = false, script_error = false;
|
||||||
|
|
||||||
if (handle != NULL)
|
if (handle != NULL)
|
||||||
{
|
{
|
||||||
handle->shutdown = 0;
|
handle->shutdown = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((handle = (MYSQL_MONITOR *)malloc(sizeof(MYSQL_MONITOR))) == NULL)
|
if ((handle = (MYSQL_MONITOR *) malloc(sizeof(MYSQL_MONITOR))) == NULL)
|
||||||
return NULL;
|
|
||||||
handle->shutdown = 0;
|
|
||||||
handle->id = MONITOR_DEFAULT_ID;
|
|
||||||
handle->script = NULL;
|
|
||||||
handle->master = NULL;
|
|
||||||
memset(handle->events,false,sizeof(handle->events));
|
|
||||||
spinlock_init(&handle->lock);
|
|
||||||
}
|
|
||||||
while(params)
|
|
||||||
{
|
|
||||||
if(!strcmp(params->name,"script"))
|
|
||||||
{
|
|
||||||
if (externcmd_can_execute(params->value))
|
|
||||||
{
|
{
|
||||||
free(handle->script);
|
return NULL;
|
||||||
handle->script = strdup(params->value);
|
|
||||||
}
|
}
|
||||||
else
|
handle->shutdown = 0;
|
||||||
{
|
handle->id = MONITOR_DEFAULT_ID;
|
||||||
script_error = true;
|
handle->script = NULL;
|
||||||
}
|
handle->master = NULL;
|
||||||
}
|
memset(handle->events, false, sizeof(handle->events));
|
||||||
else if(!strcmp(params->name,"events"))
|
spinlock_init(&handle->lock);
|
||||||
{
|
|
||||||
if(mon_parse_event_string((bool*)&handle->events,sizeof(handle->events),params->value) != 0)
|
|
||||||
script_error = true;
|
|
||||||
else
|
|
||||||
have_events = true;
|
|
||||||
}
|
|
||||||
params = params->next;
|
|
||||||
}
|
}
|
||||||
if(script_error)
|
while (params)
|
||||||
{
|
{
|
||||||
skygw_log_write(LE,"Error: Errors were found in the script configuration parameters "
|
if (!strcmp(params->name, "script"))
|
||||||
"for the monitor '%s'. The script will not be used.",mon->name);
|
{
|
||||||
free(handle->script);
|
if (externcmd_can_execute(params->value))
|
||||||
handle->script = NULL;
|
{
|
||||||
|
free(handle->script);
|
||||||
|
handle->script = strdup(params->value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
script_error = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!strcmp(params->name, "events"))
|
||||||
|
{
|
||||||
|
if (mon_parse_event_string((bool*) &handle->events,
|
||||||
|
sizeof(handle->events), params->value) != 0)
|
||||||
|
{
|
||||||
|
script_error = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
have_events = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
params = params->next;
|
||||||
|
}
|
||||||
|
if (script_error)
|
||||||
|
{
|
||||||
|
skygw_log_write(LE, "Error: Errors were found in the script configuration parameters "
|
||||||
|
"for the monitor '%s'. The script will not be used.", mon->name);
|
||||||
|
free(handle->script);
|
||||||
|
handle->script = NULL;
|
||||||
}
|
}
|
||||||
/** If no specific events are given, enable them all */
|
/** If no specific events are given, enable them all */
|
||||||
if(!have_events)
|
if (!have_events)
|
||||||
{
|
{
|
||||||
memset(handle->events,true,sizeof(handle->events));
|
memset(handle->events, true, sizeof(handle->events));
|
||||||
}
|
}
|
||||||
handle->tid = (THREAD)thread_start(monitorMain, mon);
|
handle->tid = (THREAD) thread_start(monitorMain, mon);
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,14 +174,14 @@ startMonitor(void *arg,void* opt)
|
|||||||
*
|
*
|
||||||
* @param arg Handle on thr running monior
|
* @param arg Handle on thr running monior
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
stopMonitor(void *arg)
|
stopMonitor(void *arg)
|
||||||
{
|
{
|
||||||
MONITOR* mon = (MONITOR*)arg;
|
MONITOR* mon = (MONITOR*) arg;
|
||||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)mon->handle;
|
MYSQL_MONITOR *handle = (MYSQL_MONITOR *) mon->handle;
|
||||||
|
|
||||||
handle->shutdown = 1;
|
handle->shutdown = 1;
|
||||||
thread_wait((void *)handle->tid);
|
thread_wait((void *) handle->tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -187,38 +194,38 @@ static void
|
|||||||
diagnostics(DCB *dcb, void *arg)
|
diagnostics(DCB *dcb, void *arg)
|
||||||
{
|
{
|
||||||
MONITOR* mon = arg;
|
MONITOR* mon = arg;
|
||||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)mon->handle;
|
MYSQL_MONITOR *handle = (MYSQL_MONITOR *) mon->handle;
|
||||||
MONITOR_SERVERS *db;
|
MONITOR_SERVERS *db;
|
||||||
char *sep;
|
char *sep;
|
||||||
|
|
||||||
switch (handle->status)
|
switch (handle->status)
|
||||||
{
|
{
|
||||||
case MONITOR_RUNNING:
|
case MONITOR_RUNNING:
|
||||||
dcb_printf(dcb, "\tMonitor running\n");
|
dcb_printf(dcb, "\tMonitor running\n");
|
||||||
break;
|
break;
|
||||||
case MONITOR_STOPPING:
|
case MONITOR_STOPPING:
|
||||||
dcb_printf(dcb, "\tMonitor stopping\n");
|
dcb_printf(dcb, "\tMonitor stopping\n");
|
||||||
break;
|
break;
|
||||||
case MONITOR_STOPPED:
|
case MONITOR_STOPPED:
|
||||||
dcb_printf(dcb, "\tMonitor stopped\n");
|
dcb_printf(dcb, "\tMonitor stopped\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcb_printf(dcb,"\tSampling interval:\t%lu milliseconds\n", mon->interval);
|
dcb_printf(dcb, "\tSampling interval:\t%lu milliseconds\n", mon->interval);
|
||||||
dcb_printf(dcb,"\tConnect Timeout:\t%i seconds\n", mon->connect_timeout);
|
dcb_printf(dcb, "\tConnect Timeout:\t%i seconds\n", mon->connect_timeout);
|
||||||
dcb_printf(dcb,"\tRead Timeout:\t\t%i seconds\n", mon->read_timeout);
|
dcb_printf(dcb, "\tRead Timeout:\t\t%i seconds\n", mon->read_timeout);
|
||||||
dcb_printf(dcb,"\tWrite Timeout:\t\t%i seconds\n", mon->write_timeout);
|
dcb_printf(dcb, "\tWrite Timeout:\t\t%i seconds\n", mon->write_timeout);
|
||||||
dcb_printf(dcb, "\tMonitored servers: ");
|
dcb_printf(dcb, "\tMonitored servers: ");
|
||||||
|
|
||||||
db = mon->databases;
|
db = mon->databases;
|
||||||
sep = "";
|
sep = "";
|
||||||
while (db)
|
while (db)
|
||||||
{
|
{
|
||||||
dcb_printf(dcb, "%s%s:%d", sep, db->server->name, db->server->port);
|
dcb_printf(dcb, "%s%s:%d", sep, db->server->name, db->server->port);
|
||||||
sep = ", ";
|
sep = ", ";
|
||||||
db = db->next;
|
db = db->next;
|
||||||
}
|
}
|
||||||
dcb_printf(dcb, "\n");
|
dcb_printf(dcb, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -227,16 +234,18 @@ char *sep;
|
|||||||
* @param database The database to probe
|
* @param database The database to probe
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
monitorDatabase(MONITOR_SERVERS *database, char *defaultUser, char *defaultPasswd, MONITOR *mon)
|
monitorDatabase(MONITOR_SERVERS *database, char *defaultUser, char *defaultPasswd, MONITOR *mon)
|
||||||
{
|
{
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
int isjoined = 0;
|
int isjoined = 0;
|
||||||
char *server_string;
|
char *server_string;
|
||||||
|
|
||||||
/* Don't even probe server flagged as in maintenance */
|
/* Don't even probe server flagged as in maintenance */
|
||||||
if (SERVER_IN_MAINT(database->server))
|
if (SERVER_IN_MAINT(database->server))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
connect_result_t rval = mon_connect_to_db(mon, database);
|
connect_result_t rval = mon_connect_to_db(mon, database);
|
||||||
if (rval != MONITOR_CONN_OK)
|
if (rval != MONITOR_CONN_OK)
|
||||||
@ -258,69 +267,72 @@ char *server_string;
|
|||||||
}
|
}
|
||||||
|
|
||||||
server_clear_status(database->server, SERVER_AUTH_ERROR);
|
server_clear_status(database->server, SERVER_AUTH_ERROR);
|
||||||
/* If we get this far then we have a working connection */
|
/* If we get this far then we have a working connection */
|
||||||
server_set_status(database->server, SERVER_RUNNING);
|
server_set_status(database->server, SERVER_RUNNING);
|
||||||
|
|
||||||
/* get server version string */
|
/* get server version string */
|
||||||
server_string = (char *)mysql_get_server_info(database->con);
|
server_string = (char *) mysql_get_server_info(database->con);
|
||||||
if (server_string)
|
if (server_string)
|
||||||
{
|
{
|
||||||
server_set_version_string(database->server, server_string);
|
server_set_version_string(database->server, server_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the the SQL node is able to contact one or more data nodes */
|
/* Check if the the SQL node is able to contact one or more data nodes */
|
||||||
if (mysql_query(database->con, "SHOW STATUS LIKE 'Ndb_number_of_ready_data_nodes'") == 0
|
if (mysql_query(database->con, "SHOW STATUS LIKE 'Ndb_number_of_ready_data_nodes'") == 0
|
||||||
&& (result = mysql_store_result(database->con)) != NULL)
|
&& (result = mysql_store_result(database->con)) != NULL)
|
||||||
{
|
{
|
||||||
if(mysql_field_count(database->con) < 2)
|
if (mysql_field_count(database->con) < 2)
|
||||||
{
|
{
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
skygw_log_write(LE,"Error: Unexpected result for \"SHOW STATUS LIKE 'Ndb_number_of_ready_data_nodes'\". Expected 2 columns."
|
skygw_log_write(LE, "Error: Unexpected result for \"SHOW STATUS LIKE 'Ndb_number_of_ready_data_nodes'\". Expected 2 columns."
|
||||||
" MySQL Version: %s",version_str);
|
" MySQL Version: %s", version_str);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((row = mysql_fetch_row(result)))
|
while ((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
if (atoi(row[1]) > 0)
|
if (atoi(row[1]) > 0)
|
||||||
isjoined = 1;
|
isjoined = 1;
|
||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check the the SQL node id in the MySQL cluster */
|
/* Check the the SQL node id in the MySQL cluster */
|
||||||
if (mysql_query(database->con, "SHOW STATUS LIKE 'Ndb_cluster_node_id'") == 0
|
if (mysql_query(database->con, "SHOW STATUS LIKE 'Ndb_cluster_node_id'") == 0
|
||||||
&& (result = mysql_store_result(database->con)) != NULL)
|
&& (result = mysql_store_result(database->con)) != NULL)
|
||||||
{
|
{
|
||||||
if(mysql_field_count(database->con) < 2)
|
if (mysql_field_count(database->con) < 2)
|
||||||
{
|
{
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
skygw_log_write(LE,"Error: Unexpected result for \"SHOW STATUS LIKE 'Ndb_cluster_node_id'\". Expected 2 columns."
|
skygw_log_write(LE, "Error: Unexpected result for \"SHOW STATUS LIKE 'Ndb_cluster_node_id'\". Expected 2 columns."
|
||||||
" MySQL Version: %s",version_str);
|
" MySQL Version: %s", version_str);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long cluster_node_id = -1;
|
long cluster_node_id = -1;
|
||||||
while ((row = mysql_fetch_row(result)))
|
while ((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
cluster_node_id = strtol(row[1], NULL, 10);
|
cluster_node_id = strtol(row[1], NULL, 10);
|
||||||
if ((errno == ERANGE && (cluster_node_id == LONG_MAX
|
if ((errno == ERANGE && (cluster_node_id == LONG_MAX
|
||||||
|| cluster_node_id == LONG_MIN)) || (errno != 0 && cluster_node_id == 0))
|
|| cluster_node_id == LONG_MIN)) || (errno != 0 && cluster_node_id == 0))
|
||||||
{
|
{
|
||||||
cluster_node_id = -1;
|
cluster_node_id = -1;
|
||||||
}
|
}
|
||||||
database->server->node_id = cluster_node_id;
|
database->server->node_id = cluster_node_id;
|
||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isjoined) {
|
if (isjoined)
|
||||||
server_set_status(database->server, SERVER_NDB);
|
{
|
||||||
database->server->depth = 0;
|
server_set_status(database->server, SERVER_NDB);
|
||||||
} else {
|
database->server->depth = 0;
|
||||||
server_clear_status(database->server, SERVER_NDB);
|
}
|
||||||
database->server->depth = -1;
|
else
|
||||||
}
|
{
|
||||||
|
server_clear_status(database->server, SERVER_NDB);
|
||||||
|
database->server->depth = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -332,114 +344,114 @@ static void
|
|||||||
monitorMain(void *arg)
|
monitorMain(void *arg)
|
||||||
{
|
{
|
||||||
MONITOR* mon = arg;
|
MONITOR* mon = arg;
|
||||||
MYSQL_MONITOR *handle;
|
MYSQL_MONITOR *handle;
|
||||||
MONITOR_SERVERS *ptr;
|
MONITOR_SERVERS *ptr;
|
||||||
size_t nrounds = 0;
|
size_t nrounds = 0;
|
||||||
|
|
||||||
spinlock_acquire(&mon->lock);
|
spinlock_acquire(&mon->lock);
|
||||||
handle = (MYSQL_MONITOR *)mon->handle;
|
handle = (MYSQL_MONITOR *) mon->handle;
|
||||||
spinlock_release(&mon->lock);
|
spinlock_release(&mon->lock);
|
||||||
|
|
||||||
if (mysql_thread_init())
|
if (mysql_thread_init())
|
||||||
{
|
{
|
||||||
LOGIF(LE, (skygw_log_write_flush(
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
"Fatal : mysql_thread_init failed in monitor "
|
"Fatal : mysql_thread_init failed in monitor "
|
||||||
"module. Exiting.\n")));
|
"module. Exiting.\n")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
handle->status = MONITOR_RUNNING;
|
handle->status = MONITOR_RUNNING;
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
if (handle->shutdown)
|
|
||||||
{
|
|
||||||
handle->status = MONITOR_STOPPING;
|
|
||||||
mysql_thread_end();
|
|
||||||
handle->status = MONITOR_STOPPED;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Wait base interval */
|
while (1)
|
||||||
thread_millisleep(MON_BASE_INTERVAL_MS);
|
{
|
||||||
/**
|
if (handle->shutdown)
|
||||||
* Calculate how far away the monitor interval is from its full
|
{
|
||||||
* cycle and if monitor interval time further than the base
|
handle->status = MONITOR_STOPPING;
|
||||||
* interval, then skip monitoring checks. Excluding the first
|
mysql_thread_end();
|
||||||
* round.
|
handle->status = MONITOR_STOPPED;
|
||||||
*/
|
return;
|
||||||
if (nrounds != 0 &&
|
}
|
||||||
((nrounds*MON_BASE_INTERVAL_MS)%mon->interval) >=
|
|
||||||
MON_BASE_INTERVAL_MS)
|
|
||||||
{
|
|
||||||
nrounds += 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
nrounds += 1;
|
|
||||||
ptr = mon->databases;
|
|
||||||
|
|
||||||
while (ptr)
|
/** Wait base interval */
|
||||||
{
|
thread_millisleep(MON_BASE_INTERVAL_MS);
|
||||||
ptr->mon_prev_status = ptr->server->status;
|
/**
|
||||||
monitorDatabase(ptr, mon->user, mon->password,mon);
|
* Calculate how far away the monitor interval is from its full
|
||||||
|
* cycle and if monitor interval time further than the base
|
||||||
|
* interval, then skip monitoring checks. Excluding the first
|
||||||
|
* round.
|
||||||
|
*/
|
||||||
|
if (nrounds != 0 &&
|
||||||
|
((nrounds * MON_BASE_INTERVAL_MS) % mon->interval) >=
|
||||||
|
MON_BASE_INTERVAL_MS)
|
||||||
|
{
|
||||||
|
nrounds += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
nrounds += 1;
|
||||||
|
ptr = mon->databases;
|
||||||
|
|
||||||
if (ptr->server->status != ptr->mon_prev_status ||
|
while (ptr)
|
||||||
SERVER_IS_DOWN(ptr->server))
|
{
|
||||||
{
|
ptr->mon_prev_status = ptr->server->status;
|
||||||
LOGIF(LD, (skygw_log_write_flush(
|
monitorDatabase(ptr, mon->user, mon->password, mon);
|
||||||
LOGFILE_DEBUG,
|
|
||||||
"Backend server %s:%d state : %s",
|
|
||||||
ptr->server->name,
|
|
||||||
ptr->server->port,
|
|
||||||
STRSRVSTATUS(ptr->server))));
|
|
||||||
}
|
|
||||||
|
|
||||||
ptr = ptr->next;
|
if (ptr->server->status != ptr->mon_prev_status ||
|
||||||
}
|
SERVER_IS_DOWN(ptr->server))
|
||||||
|
{
|
||||||
|
LOGIF(LD, (skygw_log_write_flush(
|
||||||
|
LOGFILE_DEBUG,
|
||||||
|
"Backend server %s:%d state : %s",
|
||||||
|
ptr->server->name,
|
||||||
|
ptr->server->port,
|
||||||
|
STRSRVSTATUS(ptr->server))));
|
||||||
|
}
|
||||||
|
|
||||||
ptr = mon->databases;
|
ptr = ptr->next;
|
||||||
monitor_event_t evtype;
|
}
|
||||||
|
|
||||||
while(ptr)
|
ptr = mon->databases;
|
||||||
{
|
monitor_event_t evtype;
|
||||||
/** Execute monitor script if a server state has changed */
|
|
||||||
if(mon_status_changed(ptr))
|
while (ptr)
|
||||||
{
|
{
|
||||||
evtype = mon_get_event_type(ptr);
|
/** Execute monitor script if a server state has changed */
|
||||||
if(isNdbEvent(evtype))
|
if (mon_status_changed(ptr))
|
||||||
{
|
{
|
||||||
skygw_log_write(LOGFILE_TRACE,"Server changed state: %s[%s:%u]: %s",
|
evtype = mon_get_event_type(ptr);
|
||||||
ptr->server->unique_name,
|
if (isNdbEvent(evtype))
|
||||||
ptr->server->name,ptr->server->port,
|
{
|
||||||
mon_get_event_name(ptr));
|
skygw_log_write(LOGFILE_TRACE, "Server changed state: %s[%s:%u]: %s",
|
||||||
if(handle->script && handle->events[evtype])
|
ptr->server->unique_name,
|
||||||
{
|
ptr->server->name, ptr->server->port,
|
||||||
monitor_launch_script(mon,ptr,handle->script);
|
mon_get_event_name(ptr));
|
||||||
}
|
if (handle->script && handle->events[evtype])
|
||||||
}
|
{
|
||||||
}
|
monitor_launch_script(mon, ptr, handle->script);
|
||||||
ptr = ptr->next;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ptr = ptr->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static monitor_event_t ndb_events[] = {
|
static monitor_event_t ndb_events[] = {
|
||||||
MASTER_DOWN_EVENT,
|
MASTER_DOWN_EVENT,
|
||||||
MASTER_UP_EVENT,
|
MASTER_UP_EVENT,
|
||||||
SLAVE_DOWN_EVENT,
|
SLAVE_DOWN_EVENT,
|
||||||
SLAVE_UP_EVENT,
|
SLAVE_UP_EVENT,
|
||||||
SERVER_DOWN_EVENT,
|
SERVER_DOWN_EVENT,
|
||||||
SERVER_UP_EVENT,
|
SERVER_UP_EVENT,
|
||||||
NDB_UP_EVENT,
|
NDB_UP_EVENT,
|
||||||
NDB_DOWN_EVENT,
|
NDB_DOWN_EVENT,
|
||||||
LOST_MASTER_EVENT,
|
LOST_MASTER_EVENT,
|
||||||
LOST_SLAVE_EVENT,
|
LOST_SLAVE_EVENT,
|
||||||
LOST_NDB_EVENT,
|
LOST_NDB_EVENT,
|
||||||
NEW_MASTER_EVENT,
|
NEW_MASTER_EVENT,
|
||||||
NEW_SLAVE_EVENT,
|
NEW_SLAVE_EVENT,
|
||||||
NEW_NDB_EVENT,
|
NEW_NDB_EVENT,
|
||||||
MAX_MONITOR_EVENT
|
MAX_MONITOR_EVENT
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -450,10 +462,10 @@ static monitor_event_t ndb_events[] = {
|
|||||||
bool isNdbEvent(monitor_event_t event)
|
bool isNdbEvent(monitor_event_t event)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i = 0;ndb_events[i] != MAX_MONITOR_EVENT;i++)
|
for (i = 0; ndb_events[i] != MAX_MONITOR_EVENT; i++)
|
||||||
{
|
{
|
||||||
if(event == ndb_events[i])
|
if (event == ndb_events[i])
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user