Removed unused variables from monitors.
This commit is contained in:
@ -1,16 +1,16 @@
|
||||
add_library(mysqlmon SHARED mysql_mon.c)
|
||||
add_library(mysqlmon SHARED mysql_mon.c monitor_common.c)
|
||||
target_link_libraries(mysqlmon log_manager utils)
|
||||
install(TARGETS mysqlmon DESTINATION modules)
|
||||
|
||||
add_library(galeramon SHARED galeramon.c)
|
||||
add_library(galeramon SHARED galeramon.c monitor_common.c)
|
||||
target_link_libraries(galeramon log_manager utils)
|
||||
install(TARGETS galeramon DESTINATION modules)
|
||||
|
||||
add_library(ndbclustermon SHARED ndbcluster_mon.c)
|
||||
add_library(ndbclustermon SHARED ndbcluster_mon.c monitor_common.c)
|
||||
target_link_libraries(ndbclustermon log_manager utils)
|
||||
install(TARGETS ndbclustermon DESTINATION modules)
|
||||
if(BUILD_MMMON)
|
||||
add_library(mmmon SHARED mm_mon.c)
|
||||
add_library(mmmon SHARED mm_mon.c monitor_common.c)
|
||||
target_link_libraries(mmmon log_manager utils)
|
||||
install(TARGETS mmmon DESTINATION modules)
|
||||
endif()
|
||||
|
@ -38,20 +38,8 @@
|
||||
* @endverbatim
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <monitor.h>
|
||||
|
||||
#include <galeramon.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>
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
|
@ -18,9 +18,22 @@
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <monitor.h>
|
||||
#include <monitor_common.h>
|
||||
#include <spinlock.h>
|
||||
#include <mon_exec.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>
|
||||
|
||||
/**
|
||||
* @file galeramon.h - The Galera cluster monitor
|
||||
|
@ -28,20 +28,9 @@
|
||||
* @endverbatim
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <monitor.h>
|
||||
|
||||
#include <mysqlmon.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>
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
extern size_t log_ses_count[];
|
||||
|
115
server/modules/monitor/monitor_common.c
Normal file
115
server/modules/monitor/monitor_common.c
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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-2015
|
||||
*/
|
||||
|
||||
#include <monitor_common.h>
|
||||
|
||||
/**
|
||||
* Set a pending status bit in the monitor server
|
||||
*
|
||||
* @param server The server to update
|
||||
* @param bit The bit to clear for the server
|
||||
*/
|
||||
void monitor_set_pending_status(MONITOR_SERVERS *ptr, int bit)
|
||||
{
|
||||
ptr->pending_status |= bit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear a pending status bit in the monitor server
|
||||
*
|
||||
* @param server The server to update
|
||||
* @param bit The bit to clear for the server
|
||||
*/
|
||||
void monitor_clear_pending_status(MONITOR_SERVERS *ptr, int bit)
|
||||
{
|
||||
ptr->pending_status &= ~bit;
|
||||
}
|
||||
|
||||
char* mon_get_event_type(MONITOR_SERVERS* node)
|
||||
{
|
||||
unsigned int prev = node->mon_prev_status;
|
||||
|
||||
if((prev & (SERVER_MASTER|SERVER_RUNNING)) == (SERVER_MASTER|SERVER_RUNNING) &&
|
||||
SERVER_IS_DOWN(node->server))
|
||||
{
|
||||
return "master_down";
|
||||
}
|
||||
if((prev & (SERVER_RUNNING)) == 0 &&
|
||||
SERVER_IS_RUNNING(node->server) && SERVER_IS_MASTER(node->server))
|
||||
{
|
||||
return "master_up";
|
||||
}
|
||||
if((prev & (SERVER_SLAVE|SERVER_RUNNING)) == (SERVER_SLAVE|SERVER_RUNNING) &&
|
||||
SERVER_IS_DOWN(node->server))
|
||||
{
|
||||
return "slave_down";
|
||||
}
|
||||
if((prev & (SERVER_RUNNING)) == 0 &&
|
||||
SERVER_IS_RUNNING(node->server) && SERVER_IS_SLAVE(node->server))
|
||||
{
|
||||
return "slave_up";
|
||||
}
|
||||
if((prev & (SERVER_RUNNING)) == SERVER_RUNNING &&
|
||||
SERVER_IS_RUNNING(node->server) && SERVER_IS_MASTER(node->server))
|
||||
{
|
||||
return "new_master";
|
||||
}
|
||||
if((prev & (SERVER_RUNNING)) == SERVER_RUNNING &&
|
||||
SERVER_IS_RUNNING(node->server) && SERVER_IS_SLAVE(node->server))
|
||||
{
|
||||
return "new_slave";
|
||||
}
|
||||
if((prev & (SERVER_RUNNING|SERVER_MASTER)) == (SERVER_RUNNING|SERVER_MASTER) &&
|
||||
SERVER_IS_RUNNING(node->server) && !SERVER_IS_MASTER(node->server))
|
||||
{
|
||||
return "lost_master";
|
||||
}
|
||||
if((prev & (SERVER_RUNNING|SERVER_SLAVE)) == (SERVER_RUNNING|SERVER_SLAVE) &&
|
||||
SERVER_IS_RUNNING(node->server) && !SERVER_IS_SLAVE(node->server))
|
||||
{
|
||||
return "lost_slave";
|
||||
}
|
||||
if((prev & SERVER_RUNNING) == 0 &&
|
||||
SERVER_IS_RUNNING(node->server))
|
||||
{
|
||||
return "server_up";
|
||||
}
|
||||
if((prev & SERVER_RUNNING) == SERVER_RUNNING &&
|
||||
SERVER_IS_DOWN(node->server))
|
||||
{
|
||||
return "server_down";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
void mon_append_node_names(MONITOR_SERVERS* start,char* str, int len)
|
||||
{
|
||||
MONITOR_SERVERS* ptr = start;
|
||||
bool first = true;
|
||||
|
||||
while(ptr)
|
||||
{
|
||||
if(!first)
|
||||
{
|
||||
strncat(str,",",len);
|
||||
}
|
||||
first = false;
|
||||
strncat(str,ptr->server->unique_name,len);
|
||||
ptr = ptr->next;
|
||||
}
|
||||
}
|
@ -15,20 +15,24 @@
|
||||
* 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
|
||||
* Copyright MariaDB Corporation Ab 2013-2015
|
||||
*/
|
||||
|
||||
#include <server.h>
|
||||
#include <mysql.h>
|
||||
|
||||
#include <monitor.h>
|
||||
/**
|
||||
* @file monitor_common.h - The generic monitor structures all monitors use
|
||||
*
|
||||
* Revision History
|
||||
*
|
||||
* Date Who Description
|
||||
* 07/05/15 Markus Makela Initial Implementation of galeramon.h
|
||||
* 07/05/15 Markus Makela Initial Implementation
|
||||
* @endverbatim
|
||||
*/
|
||||
|
||||
void mon_append_node_names(MONITOR_SERVERS* start,char* str, int len);
|
||||
char* mon_get_event_type(MONITOR_SERVERS* node);
|
||||
void monitor_clear_pending_status(MONITOR_SERVERS *ptr, int bit);
|
||||
void monitor_set_pending_status(MONITOR_SERVERS *ptr, int bit);
|
||||
#endif
|
@ -51,21 +51,9 @@
|
||||
* @endverbatim
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <monitor.h>
|
||||
|
||||
#include <mysqlmon.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 <mon_exec.h>
|
||||
|
||||
|
||||
#define MON_ARG_MAX 8192
|
||||
|
||||
@ -97,10 +85,6 @@ static MONITOR_SERVERS *get_replication_tree(MONITOR *, int);
|
||||
static void set_master_heartbeat(MYSQL_MONITOR *, MONITOR_SERVERS *);
|
||||
static void set_slave_heartbeat(MONITOR *, MONITOR_SERVERS *);
|
||||
static int add_slave_to_master(long *, int, long);
|
||||
static void monitor_set_pending_status(MONITOR_SERVERS *, int);
|
||||
static void monitor_clear_pending_status(MONITOR_SERVERS *, int);
|
||||
char* mon_get_event_type(MONITOR_SERVERS*);
|
||||
void mon_append_node_names(MONITOR_SERVERS*,char*,int);
|
||||
|
||||
static MONITOR_OBJECT MyObject = {
|
||||
startMonitor,
|
||||
@ -1259,101 +1243,3 @@ static int add_slave_to_master(long *slaves_list, int list_size, long node_id) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
char* mon_get_event_type(MONITOR_SERVERS* node)
|
||||
{
|
||||
unsigned int prev = node->mon_prev_status;
|
||||
|
||||
if((prev & (SERVER_MASTER|SERVER_RUNNING)) == (SERVER_MASTER|SERVER_RUNNING) &&
|
||||
SERVER_IS_DOWN(node->server))
|
||||
{
|
||||
return "master_down";
|
||||
}
|
||||
if((prev & (SERVER_RUNNING)) == 0 &&
|
||||
SERVER_IS_RUNNING(node->server) && SERVER_IS_MASTER(node->server))
|
||||
{
|
||||
return "master_up";
|
||||
}
|
||||
if((prev & (SERVER_SLAVE|SERVER_RUNNING)) == (SERVER_SLAVE|SERVER_RUNNING) &&
|
||||
SERVER_IS_DOWN(node->server))
|
||||
{
|
||||
return "slave_down";
|
||||
}
|
||||
if((prev & (SERVER_RUNNING)) == 0 &&
|
||||
SERVER_IS_RUNNING(node->server) && SERVER_IS_SLAVE(node->server))
|
||||
{
|
||||
return "slave_up";
|
||||
}
|
||||
if((prev & (SERVER_RUNNING)) == SERVER_RUNNING &&
|
||||
SERVER_IS_RUNNING(node->server) && SERVER_IS_MASTER(node->server))
|
||||
{
|
||||
return "new_master";
|
||||
}
|
||||
if((prev & (SERVER_RUNNING)) == SERVER_RUNNING &&
|
||||
SERVER_IS_RUNNING(node->server) && SERVER_IS_SLAVE(node->server))
|
||||
{
|
||||
return "new_slave";
|
||||
}
|
||||
if((prev & (SERVER_RUNNING|SERVER_MASTER)) == (SERVER_RUNNING|SERVER_MASTER) &&
|
||||
SERVER_IS_RUNNING(node->server) && !SERVER_IS_MASTER(node->server))
|
||||
{
|
||||
return "lost_master";
|
||||
}
|
||||
if((prev & (SERVER_RUNNING|SERVER_SLAVE)) == (SERVER_RUNNING|SERVER_SLAVE) &&
|
||||
SERVER_IS_RUNNING(node->server) && !SERVER_IS_SLAVE(node->server))
|
||||
{
|
||||
return "lost_slave";
|
||||
}
|
||||
if((prev & SERVER_RUNNING) == 0 &&
|
||||
SERVER_IS_RUNNING(node->server))
|
||||
{
|
||||
return "server_up";
|
||||
}
|
||||
if((prev & SERVER_RUNNING) == SERVER_RUNNING &&
|
||||
SERVER_IS_DOWN(node->server))
|
||||
{
|
||||
return "server_down";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
void mon_append_node_names(MONITOR_SERVERS* start,char* str, int len)
|
||||
{
|
||||
MONITOR_SERVERS* ptr = start;
|
||||
bool first = true;
|
||||
|
||||
while(ptr)
|
||||
{
|
||||
if(!first)
|
||||
{
|
||||
strncat(str,",",len);
|
||||
}
|
||||
first = false;
|
||||
strncat(str,ptr->server->unique_name,len);
|
||||
ptr = ptr->next;
|
||||
}
|
||||
}
|
@ -17,8 +17,20 @@
|
||||
*
|
||||
* 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>
|
||||
/**
|
||||
|
@ -29,20 +29,9 @@
|
||||
* @endverbatim
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <monitor.h>
|
||||
|
||||
#include <mysqlmon.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>
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
extern size_t log_ses_count[];
|
||||
@ -207,10 +196,8 @@ monitorDatabase(MONITOR_SERVERS *database, char *defaultUser, char *defaultPassw
|
||||
MYSQL_MONITOR* handle = mon->handle;
|
||||
MYSQL_ROW row;
|
||||
MYSQL_RES *result;
|
||||
int num_fields;
|
||||
int isjoined = 0;
|
||||
char *uname = defaultUser, *passwd = defaultPasswd;
|
||||
unsigned long int server_version = 0;
|
||||
char *server_string;
|
||||
|
||||
if (database->server->monuser != NULL)
|
||||
@ -228,7 +215,6 @@ char *server_string;
|
||||
if (database->con == NULL || mysql_ping(database->con) != 0)
|
||||
{
|
||||
char *dpwd = decryptPassword(passwd);
|
||||
int rc;
|
||||
int connect_timeout = mon->connect_timeout;
|
||||
int read_timeout = mon->read_timeout;
|
||||
int write_timeout = mon->write_timeout;
|
||||
@ -237,9 +223,9 @@ char *server_string;
|
||||
mysql_close(database->con);
|
||||
database->con = mysql_init(NULL);
|
||||
|
||||
rc = mysql_options(database->con, MYSQL_OPT_CONNECT_TIMEOUT, (void *)&connect_timeout);
|
||||
rc = mysql_options(database->con, MYSQL_OPT_READ_TIMEOUT, (void *)&read_timeout);
|
||||
rc = mysql_options(database->con, MYSQL_OPT_WRITE_TIMEOUT, (void *)&write_timeout);
|
||||
mysql_options(database->con, MYSQL_OPT_CONNECT_TIMEOUT, (void *)&connect_timeout);
|
||||
mysql_options(database->con, MYSQL_OPT_READ_TIMEOUT, (void *)&read_timeout);
|
||||
mysql_options(database->con, MYSQL_OPT_WRITE_TIMEOUT, (void *)&write_timeout);
|
||||
|
||||
if (mysql_real_connect(database->con, database->server->name,
|
||||
uname, dpwd, NULL, database->server->port, NULL, 0) == NULL)
|
||||
@ -270,9 +256,6 @@ char *server_string;
|
||||
/* If we get this far then we have a working connection */
|
||||
server_set_status(database->server, SERVER_RUNNING);
|
||||
|
||||
/* get server version from current server */
|
||||
server_version = mysql_get_server_version(database->con);
|
||||
|
||||
/* get server version string */
|
||||
server_string = (char *)mysql_get_server_info(database->con);
|
||||
if (server_string) {
|
||||
@ -285,7 +268,6 @@ char *server_string;
|
||||
if (mysql_query(database->con, "SHOW STATUS LIKE 'Ndb_number_of_ready_data_nodes'") == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
num_fields = mysql_num_fields(result);
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
if (atoi(row[1]) > 0)
|
||||
@ -299,7 +281,6 @@ char *server_string;
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
long cluster_node_id = -1;
|
||||
num_fields = mysql_num_fields(result);
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
cluster_node_id = strtol(row[1], NULL, 10);
|
||||
@ -333,7 +314,6 @@ monitorMain(void *arg)
|
||||
MONITOR* mon = arg;
|
||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)mon->handle;
|
||||
MONITOR_SERVERS *ptr;
|
||||
long master_id;
|
||||
size_t nrounds = 0;
|
||||
|
||||
if (mysql_thread_init())
|
||||
@ -372,7 +352,6 @@ size_t nrounds = 0;
|
||||
continue;
|
||||
}
|
||||
nrounds += 1;
|
||||
master_id = -1;
|
||||
ptr = mon->databases;
|
||||
|
||||
while (ptr)
|
||||
|
Reference in New Issue
Block a user