Merge branch 'develop' into MXS-329-develop-20151111
This commit is contained in:
@ -154,32 +154,15 @@ startMonitor(void *arg,void* opt)
|
||||
handle->use_priority = config_truth_value(params->value);
|
||||
else if(!strcmp(params->name,"script"))
|
||||
{
|
||||
if(handle->script)
|
||||
{
|
||||
free(handle->script);
|
||||
handle->script = NULL;
|
||||
}
|
||||
|
||||
if(access(params->value,X_OK) == 0)
|
||||
{
|
||||
handle->script = strdup(params->value);
|
||||
}
|
||||
else
|
||||
{
|
||||
script_error = true;
|
||||
if(access(params->value,F_OK) == 0)
|
||||
{
|
||||
skygw_log_write(LE,
|
||||
"Error: The file cannot be executed: %s",
|
||||
params->value);
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LE,
|
||||
"Error: The file cannot be found: %s",
|
||||
params->value);
|
||||
}
|
||||
}
|
||||
if (externcmd_can_execute(params->value))
|
||||
{
|
||||
free(handle->script);
|
||||
handle->script = strdup(params->value);
|
||||
}
|
||||
else
|
||||
{
|
||||
script_error = true;
|
||||
}
|
||||
}
|
||||
else if(!strcmp(params->name,"events"))
|
||||
{
|
||||
@ -327,11 +310,10 @@ char *server_string;
|
||||
|
||||
/* get server version string */
|
||||
server_string = (char *)mysql_get_server_info(database->con);
|
||||
if (server_string) {
|
||||
database->server->server_string = realloc(database->server->server_string, strlen(server_string)+1);
|
||||
if (database->server->server_string)
|
||||
strcpy(database->server->server_string, server_string);
|
||||
}
|
||||
if (server_string)
|
||||
{
|
||||
server_set_version_string(database->server, server_string);
|
||||
}
|
||||
|
||||
/* Check if the the Galera FSM shows this node is joined to the cluster */
|
||||
if (mysql_query(database->con, "SHOW STATUS LIKE 'wsrep_local_state'") == 0
|
||||
|
@ -136,31 +136,15 @@ startMonitor(void *arg,void* opt)
|
||||
}
|
||||
else if(!strcmp(params->name,"script"))
|
||||
{
|
||||
if(handle->script)
|
||||
{
|
||||
free(handle->script);
|
||||
}
|
||||
if(access(params->value,X_OK) == 0)
|
||||
{
|
||||
handle->script = strdup(params->value);
|
||||
}
|
||||
else
|
||||
{
|
||||
script_error = true;
|
||||
if(access(params->value,F_OK) == 0)
|
||||
{
|
||||
skygw_log_write(LE,
|
||||
"Error: The file cannot be executed: %s",
|
||||
params->value);
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LE,
|
||||
"Error: The file cannot be found: %s",
|
||||
params->value);
|
||||
}
|
||||
handle->script = NULL;
|
||||
}
|
||||
if (externcmd_can_execute(params->value))
|
||||
{
|
||||
free(handle->script);
|
||||
handle->script = strdup(params->value);
|
||||
}
|
||||
else
|
||||
{
|
||||
script_error = true;
|
||||
}
|
||||
}
|
||||
else if(!strcmp(params->name,"events"))
|
||||
{
|
||||
@ -312,11 +296,10 @@ char *server_string;
|
||||
|
||||
/* get server version string */
|
||||
server_string = (char *)mysql_get_server_info(database->con);
|
||||
if (server_string) {
|
||||
database->server->server_string = realloc(database->server->server_string, strlen(server_string)+1);
|
||||
if (database->server->server_string)
|
||||
strcpy(database->server->server_string, server_string);
|
||||
}
|
||||
if (server_string)
|
||||
{
|
||||
server_set_version_string(database->server, server_string);
|
||||
}
|
||||
|
||||
/* get server_id form current node */
|
||||
if (mysql_query(database->con, "SELECT @@server_id") == 0
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <monitor_common.h>
|
||||
#include <maxscale_pcre2.h>
|
||||
|
||||
monitor_event_t mon_name_to_event(char* tok);
|
||||
|
||||
@ -225,23 +226,32 @@ case NEW_DONOR_EVENT:
|
||||
|
||||
}
|
||||
|
||||
void mon_append_node_names(MONITOR_SERVERS* start,char* str, int len)
|
||||
/**
|
||||
* Create a list of running servers
|
||||
* @param start Monitored servers
|
||||
* @param dest Destination where the string is formed
|
||||
* @param len Length of @c dest
|
||||
*/
|
||||
void mon_append_node_names(MONITOR_SERVERS* start, char* dest, int len)
|
||||
{
|
||||
MONITOR_SERVERS* ptr = start;
|
||||
bool first = true;
|
||||
int slen = strlen(str);
|
||||
char arr[256];
|
||||
while(ptr && slen < len)
|
||||
int slen = strlen(dest);
|
||||
char arr[MAX_SERVER_NAME_LEN + 32]; // Some extra space for port
|
||||
while (ptr && slen < len)
|
||||
{
|
||||
if(!first)
|
||||
{
|
||||
strncat(str,",",len);
|
||||
}
|
||||
first = false;
|
||||
sprintf(arr,"%s:%d",ptr->server->name,ptr->server->port);
|
||||
strncat(str,arr,len);
|
||||
ptr = ptr->next;
|
||||
slen = strlen(str);
|
||||
if(SERVER_IS_RUNNING(ptr->server))
|
||||
{
|
||||
if (!first)
|
||||
{
|
||||
strncat(dest, ",", len);
|
||||
}
|
||||
first = false;
|
||||
snprintf(arr, sizeof(arr), "%s:%d", ptr->server->name, ptr->server->port);
|
||||
strncat(dest, arr, len);
|
||||
slen = strlen(dest);
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,23 +312,26 @@ bool mon_print_fail_status(
|
||||
*/
|
||||
void monitor_launch_script(MONITOR* mon, MONITOR_SERVERS* ptr, char* script)
|
||||
{
|
||||
char argstr[PATH_MAX + MON_ARG_MAX + 1];
|
||||
EXTERNCMD* cmd;
|
||||
char nodelist[PATH_MAX + MON_ARG_MAX + 1] = {'\0'};
|
||||
char event[strlen(mon_get_event_name(ptr))];
|
||||
char initiator[strlen(ptr->server->name) + 24]; // Extra space for port
|
||||
|
||||
snprintf(argstr, PATH_MAX + MON_ARG_MAX,
|
||||
"%s --event=%s --initiator=%s:%d --nodelist=",
|
||||
script,
|
||||
mon_get_event_name(ptr),
|
||||
ptr->server->name,
|
||||
ptr->server->port);
|
||||
snprintf(initiator, sizeof(initiator), "%s:%d", ptr->server->name, ptr->server->port);
|
||||
snprintf(event, sizeof(event), "%s", mon_get_event_name(ptr));
|
||||
mon_append_node_names(mon->databases, nodelist, PATH_MAX + MON_ARG_MAX);
|
||||
|
||||
mon_append_node_names(mon->databases, argstr, PATH_MAX + MON_ARG_MAX);
|
||||
if ((cmd = externcmd_allocate(argstr)) == NULL)
|
||||
EXTERNCMD* cmd = externcmd_allocate(script);
|
||||
|
||||
if (cmd == NULL)
|
||||
{
|
||||
skygw_log_write(LE, "Failed to initialize script: %s", script);
|
||||
return;
|
||||
}
|
||||
|
||||
externcmd_substitute_arg(cmd, "[$]INITIATOR", initiator);
|
||||
externcmd_substitute_arg(cmd, "[$]EVENT", event);
|
||||
externcmd_substitute_arg(cmd, "[$]NODELIST", nodelist);
|
||||
|
||||
if (externcmd_execute(cmd))
|
||||
{
|
||||
skygw_log_write(LOGFILE_ERROR,
|
||||
|
@ -168,32 +168,18 @@ startMonitor(void *arg, void* opt)
|
||||
handle->detectStaleMaster = config_truth_value(params->value);
|
||||
else if(!strcmp(params->name,"detect_replication_lag"))
|
||||
handle->replicationHeartbeat = config_truth_value(params->value);
|
||||
else if(!strcmp(params->name,"script"))
|
||||
{
|
||||
if(handle->script)
|
||||
free(handle->script);
|
||||
if(access(params->value,X_OK) == 0)
|
||||
{
|
||||
handle->script = strdup(params->value);
|
||||
}
|
||||
else
|
||||
{
|
||||
script_error = true;
|
||||
if(access(params->value,F_OK) == 0)
|
||||
{
|
||||
skygw_log_write(LE,
|
||||
"Error: The file cannot be executed: %s",
|
||||
params->value);
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LE,
|
||||
"Error: The file cannot be found: %s",
|
||||
params->value);
|
||||
}
|
||||
handle->script = NULL;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(params->name, "script"))
|
||||
{
|
||||
if (externcmd_can_execute(params->value))
|
||||
{
|
||||
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)
|
||||
@ -659,10 +645,9 @@ monitorDatabase(MONITOR *mon, MONITOR_SERVERS *database)
|
||||
|
||||
/* get server version string */
|
||||
server_string = (char *)mysql_get_server_info(database->con);
|
||||
if (server_string) {
|
||||
database->server->server_string = realloc(database->server->server_string, strlen(server_string)+1);
|
||||
if (database->server->server_string)
|
||||
strcpy(database->server->server_string, server_string);
|
||||
if (server_string)
|
||||
{
|
||||
server_set_version_string(database->server, server_string);
|
||||
}
|
||||
|
||||
/* get server_id form current node */
|
||||
|
@ -127,29 +127,15 @@ startMonitor(void *arg,void* opt)
|
||||
{
|
||||
if(!strcmp(params->name,"script"))
|
||||
{
|
||||
if(handle->script)
|
||||
free(handle->script);
|
||||
if(access(params->value,X_OK) == 0)
|
||||
{
|
||||
handle->script = strdup(params->value);
|
||||
}
|
||||
else
|
||||
{
|
||||
script_error = true;
|
||||
if(access(params->value,F_OK) == 0)
|
||||
{
|
||||
skygw_log_write(LE,
|
||||
"Error: The file cannot be executed: %s",
|
||||
params->value);
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LE,
|
||||
"Error: The file cannot be found: %s",
|
||||
params->value);
|
||||
}
|
||||
handle->script = NULL;
|
||||
}
|
||||
if (externcmd_can_execute(params->value))
|
||||
{
|
||||
free(handle->script);
|
||||
handle->script = strdup(params->value);
|
||||
}
|
||||
else
|
||||
{
|
||||
script_error = true;
|
||||
}
|
||||
}
|
||||
else if(!strcmp(params->name,"events"))
|
||||
{
|
||||
@ -277,11 +263,10 @@ char *server_string;
|
||||
|
||||
/* get server version string */
|
||||
server_string = (char *)mysql_get_server_info(database->con);
|
||||
if (server_string) {
|
||||
database->server->server_string = realloc(database->server->server_string, strlen(server_string)+1);
|
||||
if (database->server->server_string)
|
||||
strcpy(database->server->server_string, server_string);
|
||||
}
|
||||
if (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 */
|
||||
if (mysql_query(database->con, "SHOW STATUS LIKE 'Ndb_number_of_ready_data_nodes'") == 0
|
||||
|
Reference in New Issue
Block a user