First tests.
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
add_library(mysqlmon SHARED mysql_mon.c)
|
add_library(mysqlmon SHARED mysql_mon.c mon_exec.c)
|
||||||
target_link_libraries(mysqlmon log_manager utils)
|
target_link_libraries(mysqlmon log_manager utils)
|
||||||
install(TARGETS mysqlmon DESTINATION modules)
|
install(TARGETS mysqlmon DESTINATION modules)
|
||||||
|
|
||||||
|
38
server/modules/monitor/mon_exec.c
Normal file
38
server/modules/monitor/mon_exec.c
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#include <mon_exec.h>
|
||||||
|
|
||||||
|
/** Defined in log_manager.cc */
|
||||||
|
extern int lm_enabled_logfiles_bitmask;
|
||||||
|
extern size_t log_ses_count[];
|
||||||
|
extern __thread log_info_t tls_log_info;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Execute a command in a separate process.
|
||||||
|
*@param cmd Command to execute
|
||||||
|
*@return 0 on success, -1 on error.
|
||||||
|
*/
|
||||||
|
int monitor_exec_cmd(char* cmd)
|
||||||
|
{
|
||||||
|
int rval = 0;
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
pid = fork();
|
||||||
|
|
||||||
|
if(pid < 0)
|
||||||
|
{
|
||||||
|
skygw_log_write(LOGFILE_ERROR,"Error: Failed to execute command '%s', fork failed: [%d] %s",
|
||||||
|
cmd,errno,strerror(errno));
|
||||||
|
rval = -1;
|
||||||
|
}
|
||||||
|
else if(pid == 0)
|
||||||
|
{
|
||||||
|
/** Child process, execute command */
|
||||||
|
execl(cmd,cmd,NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOGIF(LD,skygw_log_write(LD,"[monitor_exec_cmd] Forked child process %d : %s.",pid,cmd));
|
||||||
|
}
|
||||||
|
|
||||||
|
return rval;
|
||||||
|
|
||||||
|
}
|
13
server/modules/monitor/mon_exec.h
Normal file
13
server/modules/monitor/mon_exec.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef MON_EXEC_HG
|
||||||
|
#define MON_EXEC_HG
|
||||||
|
|
||||||
|
#include <mon_exec.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <skygw_utils.h>
|
||||||
|
#include <log_manager.h>
|
||||||
|
|
||||||
|
int monitor_exec_cmd(char* cmd);
|
||||||
|
|
||||||
|
#endif
|
@ -64,6 +64,7 @@
|
|||||||
#include <dcb.h>
|
#include <dcb.h>
|
||||||
#include <modinfo.h>
|
#include <modinfo.h>
|
||||||
#include <maxconfig.h>
|
#include <maxconfig.h>
|
||||||
|
#include <mon_exec.h>
|
||||||
|
|
||||||
/** Defined in log_manager.cc */
|
/** Defined in log_manager.cc */
|
||||||
extern int lm_enabled_logfiles_bitmask;
|
extern int lm_enabled_logfiles_bitmask;
|
||||||
@ -184,6 +185,7 @@ CONFIG_PARAMETER* params = (CONFIG_PARAMETER*)opt;
|
|||||||
handle->connect_timeout=DEFAULT_CONNECT_TIMEOUT;
|
handle->connect_timeout=DEFAULT_CONNECT_TIMEOUT;
|
||||||
handle->read_timeout=DEFAULT_READ_TIMEOUT;
|
handle->read_timeout=DEFAULT_READ_TIMEOUT;
|
||||||
handle->write_timeout=DEFAULT_WRITE_TIMEOUT;
|
handle->write_timeout=DEFAULT_WRITE_TIMEOUT;
|
||||||
|
handle->script = NULL;
|
||||||
spinlock_init(&handle->lock);
|
spinlock_init(&handle->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,6 +195,8 @@ CONFIG_PARAMETER* params = (CONFIG_PARAMETER*)opt;
|
|||||||
handle->detectStaleMaster = config_truth_value(params->value);
|
handle->detectStaleMaster = config_truth_value(params->value);
|
||||||
else if(!strcmp(params->name,"detect_replication_lag"))
|
else if(!strcmp(params->name,"detect_replication_lag"))
|
||||||
handle->replicationHeartbeat = config_truth_value(params->value);
|
handle->replicationHeartbeat = config_truth_value(params->value);
|
||||||
|
else if(!strcmp(params->name,"script"))
|
||||||
|
handle->script = strdup(params->value);
|
||||||
params = params->next;
|
params = params->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -696,7 +700,15 @@ int log_no_master = 1;
|
|||||||
!(SERVER_IS_IN_CLUSTER(ptr->server)))
|
!(SERVER_IS_IN_CLUSTER(ptr->server)))
|
||||||
{
|
{
|
||||||
dcb_call_foreach(ptr->server,DCB_REASON_NOT_RESPONDING);
|
dcb_call_foreach(ptr->server,DCB_REASON_NOT_RESPONDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if(handle->script)
|
||||||
|
{
|
||||||
|
if(monitor_exec_cmd(handle->script))
|
||||||
|
skygw_log_write(LOGFILE_ERROR,"Error: Failed to execute command '%s' on server state change.",handle->script);
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mon_status_changed(ptr))
|
if (mon_status_changed(ptr))
|
||||||
|
@ -77,6 +77,7 @@ typedef struct {
|
|||||||
int write_timeout; /**< Timeout in seconds for each attempt to write to the server.
|
int write_timeout; /**< Timeout in seconds for each attempt to write to the server.
|
||||||
* There are retries and the total effective timeout value is two times the option value.
|
* There are retries and the total effective timeout value is two times the option value.
|
||||||
*/
|
*/
|
||||||
|
char *script;0
|
||||||
} MYSQL_MONITOR;
|
} MYSQL_MONITOR;
|
||||||
|
|
||||||
#define MONITOR_RUNNING 1
|
#define MONITOR_RUNNING 1
|
||||||
|
@ -6,13 +6,13 @@ add_library(MySQLBackend SHARED mysql_backend.c mysql_common.c)
|
|||||||
target_link_libraries(MySQLBackend log_manager utils)
|
target_link_libraries(MySQLBackend log_manager utils)
|
||||||
install(TARGETS MySQLBackend DESTINATION modules)
|
install(TARGETS MySQLBackend DESTINATION modules)
|
||||||
|
|
||||||
add_library(mongoclient SHARED mongo_client.c mysql_common.c)
|
add_library(plainclient SHARED plainclient.c mysql_common.c)
|
||||||
target_link_libraries(mongoclient log_manager utils)
|
target_link_libraries(plainclient log_manager utils)
|
||||||
install(TARGETS mongoclient DESTINATION modules)
|
install(TARGETS plainclient DESTINATION modules)
|
||||||
|
|
||||||
add_library(mongobackend SHARED mongo_backend.c mysql_common.c)
|
add_library(plainbackend SHARED plainbackend.c mysql_common.c)
|
||||||
target_link_libraries(mongobackend log_manager utils)
|
target_link_libraries(plainbackend log_manager utils)
|
||||||
install(TARGETS mongobackend DESTINATION modules)
|
install(TARGETS plainbackend DESTINATION modules)
|
||||||
|
|
||||||
|
|
||||||
add_library(telnetd SHARED telnetd.c)
|
add_library(telnetd SHARED telnetd.c)
|
||||||
|
Reference in New Issue
Block a user