Added ndbclustermon and mmmon headers.
This commit is contained in:
@ -141,6 +141,7 @@ int externcmd_execute(EXTERNCMD* cmd)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
cmd->child = pid;
|
||||||
cmd->n_exec++;
|
cmd->n_exec++;
|
||||||
LOGIF(LD,skygw_log_write(LD,"[monitor_exec_cmd] Forked child process %d : %s.",pid,cmd));
|
LOGIF(LD,skygw_log_write(LD,"[monitor_exec_cmd] Forked child process %d : %s.",pid,cmd));
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
typedef struct extern_cmd_t{
|
typedef struct extern_cmd_t{
|
||||||
char* parameters[MAXSCALE_EXTCMD_ARG_MAX]; /*< Command arguments */
|
char* parameters[MAXSCALE_EXTCMD_ARG_MAX]; /*< Command arguments */
|
||||||
int n_exec; /*< Number of times executed */
|
int n_exec; /*< Number of times executed */
|
||||||
|
pid_t child; /*< PID of the child process */
|
||||||
}EXTERNCMD;
|
}EXTERNCMD;
|
||||||
|
|
||||||
EXTERNCMD* externcmd_allocate(char* argstr);
|
EXTERNCMD* externcmd_allocate(char* argstr);
|
||||||
|
@ -6,11 +6,11 @@ add_library(galeramon SHARED galeramon.c monitor_common.c)
|
|||||||
target_link_libraries(galeramon log_manager utils)
|
target_link_libraries(galeramon log_manager utils)
|
||||||
install(TARGETS galeramon DESTINATION modules)
|
install(TARGETS galeramon DESTINATION modules)
|
||||||
|
|
||||||
add_library(ndbclustermon SHARED ndbcluster_mon.c monitor_common.c)
|
add_library(ndbclustermon SHARED ndbclustermon.c monitor_common.c)
|
||||||
target_link_libraries(ndbclustermon log_manager utils)
|
target_link_libraries(ndbclustermon log_manager utils)
|
||||||
install(TARGETS ndbclustermon DESTINATION modules)
|
install(TARGETS ndbclustermon DESTINATION modules)
|
||||||
if(BUILD_MMMON)
|
if(BUILD_MMMON)
|
||||||
add_library(mmmon SHARED mm_mon.c monitor_common.c)
|
add_library(mmmon SHARED mmmon.c monitor_common.c)
|
||||||
target_link_libraries(mmmon log_manager utils)
|
target_link_libraries(mmmon log_manager utils)
|
||||||
install(TARGETS mmmon DESTINATION modules)
|
install(TARGETS mmmon DESTINATION modules)
|
||||||
endif()
|
endif()
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
* 10/11/14 Massimiliano Pinto Added setNetworkTimeout for connect,read,write
|
* 10/11/14 Massimiliano Pinto Added setNetworkTimeout for connect,read,write
|
||||||
* 20/04/15 Guillaume Lefranc Added availableWhenDonor feature
|
* 20/04/15 Guillaume Lefranc Added availableWhenDonor feature
|
||||||
* 22/04/15 Martin Brampton Addition of disableMasterRoleSetting
|
* 22/04/15 Martin Brampton Addition of disableMasterRoleSetting
|
||||||
|
* 08/05/15 Markus Makela Addition of launchable scripts
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
|
@ -56,7 +56,6 @@ typedef struct {
|
|||||||
int shutdown; /**< Flag to shutdown the monitor thread */
|
int shutdown; /**< Flag to shutdown the monitor thread */
|
||||||
int status; /**< Monitor status */
|
int status; /**< Monitor status */
|
||||||
unsigned long id; /**< Monitor ID */
|
unsigned long id; /**< Monitor ID */
|
||||||
int detectStaleMaster; /**< Monitor flag for MySQL replication Stale Master detection */
|
|
||||||
int disableMasterFailback; /**< Monitor flag for Galera Cluster Master failback */
|
int disableMasterFailback; /**< Monitor flag for Galera Cluster Master failback */
|
||||||
int availableWhenDonor; /**< Monitor flag for Galera Cluster Donor availability */
|
int availableWhenDonor; /**< Monitor flag for Galera Cluster Donor availability */
|
||||||
int disableMasterRoleSetting; /**< Monitor flag to disable setting master role */
|
int disableMasterRoleSetting; /**< Monitor flag to disable setting master role */
|
||||||
|
@ -17,19 +17,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file mysql_mon.c - A MySQL Multi Muster cluster monitor
|
* @file mm_mon.c - A Multi-Master Multi Muster cluster monitor
|
||||||
*
|
*
|
||||||
* @verbatim
|
* @verbatim
|
||||||
* Revision History
|
* Revision History
|
||||||
*
|
*
|
||||||
* Date Who Description
|
* Date Who Description
|
||||||
* 08/09/14 Massimiliano Pinto Initial implementation
|
* 08/09/14 Massimiliano Pinto Initial implementation
|
||||||
|
* 08/05/15 Markus Makela Addition of launchable scripts
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <mysqlmon.h>
|
#include <mmmon.h>
|
||||||
|
|
||||||
/** Defined in log_manager.cc */
|
/** Defined in log_manager.cc */
|
||||||
extern int lm_enabled_logfiles_bitmask;
|
extern int lm_enabled_logfiles_bitmask;
|
||||||
@ -44,7 +45,7 @@ MODULE_INFO info = {
|
|||||||
MODULE_API_MONITOR,
|
MODULE_API_MONITOR,
|
||||||
MODULE_BETA_RELEASE,
|
MODULE_BETA_RELEASE,
|
||||||
MONITOR_VERSION,
|
MONITOR_VERSION,
|
||||||
"A MySQL Multi Master monitor"
|
"A Multi-Master Multi Master monitor"
|
||||||
};
|
};
|
||||||
|
|
||||||
static void *startMonitor(void *,void*);
|
static void *startMonitor(void *,void*);
|
||||||
@ -79,7 +80,7 @@ ModuleInit()
|
|||||||
{
|
{
|
||||||
LOGIF(LM, (skygw_log_write(
|
LOGIF(LM, (skygw_log_write(
|
||||||
LOGFILE_MESSAGE,
|
LOGFILE_MESSAGE,
|
||||||
"Initialise the MySQL Monitor module %s.",
|
"Initialise the Multi-Master Monitor module %s.",
|
||||||
version_str)));
|
version_str)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +110,7 @@ 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;
|
MM_MONITOR *handle = mon->handle;
|
||||||
CONFIG_PARAMETER* params = (CONFIG_PARAMETER*)opt;
|
CONFIG_PARAMETER* params = (CONFIG_PARAMETER*)opt;
|
||||||
if (handle)
|
if (handle)
|
||||||
{
|
{
|
||||||
@ -117,12 +118,10 @@ startMonitor(void *arg,void* opt)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((handle = (MYSQL_MONITOR *)malloc(sizeof(MYSQL_MONITOR))) == NULL)
|
if ((handle = (MM_MONITOR *)malloc(sizeof(MM_MONITOR))) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
handle->shutdown = 0;
|
handle->shutdown = 0;
|
||||||
handle->id = MONITOR_DEFAULT_ID;
|
handle->id = MONITOR_DEFAULT_ID;
|
||||||
handle->replicationHeartbeat = 0;
|
|
||||||
handle->detectStaleMaster = 0;
|
|
||||||
handle->master = NULL;
|
handle->master = NULL;
|
||||||
spinlock_init(&handle->lock);
|
spinlock_init(&handle->lock);
|
||||||
}
|
}
|
||||||
@ -157,7 +156,7 @@ startMonitor(void *arg,void* opt)
|
|||||||
static void
|
static void
|
||||||
stopMonitor(void *arg)
|
stopMonitor(void *arg)
|
||||||
{
|
{
|
||||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
MM_MONITOR *handle = (MM_MONITOR *)arg;
|
||||||
|
|
||||||
handle->shutdown = 1;
|
handle->shutdown = 1;
|
||||||
thread_wait((void *)handle->tid);
|
thread_wait((void *)handle->tid);
|
||||||
@ -172,7 +171,7 @@ MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
|||||||
static void diagnostics(DCB *dcb, void *arg)
|
static void diagnostics(DCB *dcb, void *arg)
|
||||||
{
|
{
|
||||||
MONITOR* mon = (MONITOR*)arg;
|
MONITOR* mon = (MONITOR*)arg;
|
||||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)mon->handle;
|
MM_MONITOR *handle = (MM_MONITOR *)mon->handle;
|
||||||
MONITOR_SERVERS *db;
|
MONITOR_SERVERS *db;
|
||||||
char *sep;
|
char *sep;
|
||||||
|
|
||||||
@ -217,7 +216,7 @@ char *sep;
|
|||||||
static void
|
static void
|
||||||
monitorDatabase(MONITOR* mon, MONITOR_SERVERS *database)
|
monitorDatabase(MONITOR* mon, MONITOR_SERVERS *database)
|
||||||
{
|
{
|
||||||
MYSQL_MONITOR *handle = mon->handle;
|
MM_MONITOR *handle = mon->handle;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
int isslave = 0;
|
int isslave = 0;
|
||||||
@ -240,7 +239,7 @@ char *server_string;
|
|||||||
if (SERVER_IN_MAINT(database->server))
|
if (SERVER_IN_MAINT(database->server))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/** Store prevous status */
|
/** Store previous status */
|
||||||
database->mon_prev_status = database->server->status;
|
database->mon_prev_status = database->server->status;
|
||||||
|
|
||||||
if (database->con == NULL || mysql_ping(database->con) != 0)
|
if (database->con == NULL || mysql_ping(database->con) != 0)
|
||||||
@ -473,7 +472,7 @@ static void
|
|||||||
monitorMain(void *arg)
|
monitorMain(void *arg)
|
||||||
{
|
{
|
||||||
MONITOR* mon = (MONITOR*)arg;
|
MONITOR* mon = (MONITOR*)arg;
|
||||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)mon->handle;
|
MM_MONITOR *handle = (MM_MONITOR *)mon->handle;
|
||||||
MONITOR_SERVERS *ptr;
|
MONITOR_SERVERS *ptr;
|
||||||
int detect_stale_master = handle->detectStaleMaster;
|
int detect_stale_master = handle->detectStaleMaster;
|
||||||
MONITOR_SERVERS *root_master;
|
MONITOR_SERVERS *root_master;
|
||||||
@ -612,70 +611,10 @@ static void
|
|||||||
detectStaleMaster(void *arg, int enable)
|
detectStaleMaster(void *arg, int enable)
|
||||||
{
|
{
|
||||||
MONITOR* mon = (MONITOR*)arg;
|
MONITOR* mon = (MONITOR*)arg;
|
||||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)mon->handle;
|
MM_MONITOR *handle = (MM_MONITOR *)mon->handle;
|
||||||
memcpy(&handle->detectStaleMaster, &enable, sizeof(int));
|
memcpy(&handle->detectStaleMaster, &enable, sizeof(int));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool mon_status_changed(
|
|
||||||
MONITOR_SERVERS* mon_srv)
|
|
||||||
{
|
|
||||||
bool succp;
|
|
||||||
|
|
||||||
if (mon_srv->mon_prev_status != mon_srv->server->status)
|
|
||||||
{
|
|
||||||
succp = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
succp = false;
|
|
||||||
}
|
|
||||||
return succp;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool mon_print_fail_status(
|
|
||||||
MONITOR_SERVERS* mon_srv)
|
|
||||||
{
|
|
||||||
bool succp;
|
|
||||||
int errcount = mon_srv->mon_err_count;
|
|
||||||
uint8_t modval;
|
|
||||||
|
|
||||||
modval = 1<<(MIN(errcount/10, 7));
|
|
||||||
|
|
||||||
if (SERVER_IS_DOWN(mon_srv->server) && errcount%modval == 0)
|
|
||||||
{
|
|
||||||
succp = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
succp = false;
|
|
||||||
}
|
|
||||||
return succp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set a pending status bit in the monior server
|
|
||||||
*
|
|
||||||
* @param server The server to update
|
|
||||||
* @param bit The bit to clear for the server
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
monitor_set_pending_status(MONITOR_SERVERS *ptr, int bit)
|
|
||||||
{
|
|
||||||
ptr->pending_status |= bit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear a pending status bit in the monior server
|
|
||||||
*
|
|
||||||
* @param server The server to update
|
|
||||||
* @param bit The bit to clear for the server
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
monitor_clear_pending_status(MONITOR_SERVERS *ptr, int bit)
|
|
||||||
{
|
|
||||||
ptr->pending_status &= ~bit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******
|
/*******
|
||||||
* This function returns the master server
|
* This function returns the master server
|
||||||
* from a set of MySQL Multi Master monitored servers
|
* from a set of MySQL Multi Master monitored servers
|
||||||
@ -687,7 +626,7 @@ monitor_clear_pending_status(MONITOR_SERVERS *ptr, int bit)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static MONITOR_SERVERS *get_current_master(MONITOR *mon) {
|
static MONITOR_SERVERS *get_current_master(MONITOR *mon) {
|
||||||
MYSQL_MONITOR* handle = mon->handle;
|
MM_MONITOR* handle = mon->handle;
|
||||||
MONITOR_SERVERS *ptr;
|
MONITOR_SERVERS *ptr;
|
||||||
|
|
||||||
ptr = mon->databases;
|
ptr = mon->databases;
|
51
server/modules/monitor/mmmon.h
Normal file
51
server/modules/monitor/mmmon.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#ifndef _MMMON_H
|
||||||
|
#define _MMMON_H
|
||||||
|
/*
|
||||||
|
* This file is distributed as part of the MariaDB Corporation MaxScale. It 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.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Copyright MariaDB Corporation Ab 2015
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <monitor.h>
|
||||||
|
#include <spinlock.h>
|
||||||
|
#include <thread.h>
|
||||||
|
#include <mysql.h>
|
||||||
|
#include <mysqld_error.h>
|
||||||
|
#include <skygw_utils.h>
|
||||||
|
#include <log_manager.h>
|
||||||
|
#include <secrets.h>
|
||||||
|
#include <dcb.h>
|
||||||
|
#include <modinfo.h>
|
||||||
|
#include <maxconfig.h>
|
||||||
|
#include <monitor_common.h>
|
||||||
|
#include <mon_exec.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The handle for an instance of a Multi-Master Monitor module
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
SPINLOCK lock; /**< The monitor spinlock */
|
||||||
|
pthread_t tid; /**< id of monitor thread */
|
||||||
|
int shutdown; /**< Flag to shutdown the monitor thread */
|
||||||
|
int status; /**< Monitor status */
|
||||||
|
unsigned long id; /**< Monitor ID */
|
||||||
|
int detectStaleMaster; /**< Monitor flag for Stale Master detection */
|
||||||
|
MONITOR_SERVERS *master; /**< Master server for Master/Slave replication */
|
||||||
|
char* script; /*< Script to call when state changes occur on servers */
|
||||||
|
} MM_MONITOR;
|
||||||
|
|
||||||
|
#endif
|
@ -49,7 +49,7 @@
|
|||||||
* 07/11/14 Massimiliano Pinto Addition of NetworkTimeout: connect, read, write
|
* 07/11/14 Massimiliano Pinto Addition of NetworkTimeout: connect, read, write
|
||||||
* 20/04/15 Guillaume Lefranc Addition of availableWhenDonor
|
* 20/04/15 Guillaume Lefranc Addition of availableWhenDonor
|
||||||
* 22/04/15 Martin Brampton Addition of disableMasterRoleSetting
|
* 22/04/15 Martin Brampton Addition of disableMasterRoleSetting
|
||||||
* 07/05/15 Markus Makela Addition of command execution on Master server failure
|
* 07/05/15 Markus Makela Addition of command execution on Master server failure
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
* Date Who Description
|
* Date Who Description
|
||||||
* 25/07/14 Massimiliano Pinto Initial implementation
|
* 25/07/14 Massimiliano Pinto Initial implementation
|
||||||
* 10/11/14 Massimiliano Pinto Added setNetworkTimeout for connect,read,write
|
* 10/11/14 Massimiliano Pinto Added setNetworkTimeout for connect,read,write
|
||||||
|
* 08/05/15 Markus Makela Addition of launchable scripts
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
55
server/modules/monitor/ndbclustermon.h
Normal file
55
server/modules/monitor/ndbclustermon.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#ifndef _MYSQLMON_H
|
||||||
|
#define _MYSQLMON_H
|
||||||
|
/*
|
||||||
|
* This file is distributed as part of the MariaDB Corporation MaxScale. It 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.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Copyright MariaDB Corporation Ab 2013-2014
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <monitor.h>
|
||||||
|
#include <spinlock.h>
|
||||||
|
#include <thread.h>
|
||||||
|
#include <mysql.h>
|
||||||
|
#include <mysqld_error.h>
|
||||||
|
#include <skygw_utils.h>
|
||||||
|
#include <log_manager.h>
|
||||||
|
#include <secrets.h>
|
||||||
|
#include <dcb.h>
|
||||||
|
#include <modinfo.h>
|
||||||
|
#include <maxconfig.h>
|
||||||
|
#include <monitor_common.h>
|
||||||
|
#include <mon_exec.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file ndbclustermon.h - The NDB Cluster monitor
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The handle for an instance of a NDB Cluster Monitor module
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
SPINLOCK lock; /**< The monitor spinlock */
|
||||||
|
pthread_t tid; /**< id of monitor thread */
|
||||||
|
int shutdown; /**< Flag to shutdown the monitor thread */
|
||||||
|
int status; /**< Monitor status */
|
||||||
|
unsigned long id; /**< Monitor ID */
|
||||||
|
MONITOR_SERVERS *master; /**< Master server for MySQL Master/Slave replication */
|
||||||
|
char* script; /*< Script to call when state changes occur on servers */
|
||||||
|
} MYSQL_MONITOR;
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user