Added routines for interval and defaultId (MySQL)
Added routines for interval and defaultId (MySQL)
This commit is contained in:
@ -22,8 +22,10 @@
|
|||||||
* @verbatim
|
* @verbatim
|
||||||
* Revision History
|
* Revision History
|
||||||
*
|
*
|
||||||
* Date Who Description
|
* Date Who Description
|
||||||
* 08/07/13 Mark Riddoch Initial implementation
|
* 08/07/13 Mark Riddoch Initial implementation
|
||||||
|
* 23/05/14 Massimiliano Pinto Addition of monitor_interval parameter
|
||||||
|
* and monitor id
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -220,3 +222,32 @@ MONITOR *ptr;
|
|||||||
spinlock_release(&monLock);
|
spinlock_release(&monLock);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the id of the monitor.
|
||||||
|
*
|
||||||
|
* @param mon The monitor instance
|
||||||
|
* @param id The id for the monitor
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
monitorSetId(MONITOR *mon, unsigned long id)
|
||||||
|
{
|
||||||
|
if (mon->module->defaultId != NULL) {
|
||||||
|
mon->module->defaultId(mon->handle, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the monitor sampling interval.
|
||||||
|
*
|
||||||
|
* @param mon The monitor instance
|
||||||
|
* @param interval The sampling interval in milliseconds
|
||||||
|
*/
|
||||||
|
monitorSetInterval (MONITOR *mon, unsigned long interval)
|
||||||
|
{
|
||||||
|
if (mon->module->setInterval != NULL) {
|
||||||
|
mon->module->setInterval(mon->handle, interval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -26,10 +26,11 @@
|
|||||||
* @verbatim
|
* @verbatim
|
||||||
* Revision History
|
* Revision History
|
||||||
*
|
*
|
||||||
* Date Who Description
|
* Date Who Description
|
||||||
* 07/07/13 Mark Riddoch Initial implementation
|
* 07/07/13 Mark Riddoch Initial implementation
|
||||||
* 25/07/13 Mark Riddoch Addition of diagnotics
|
* 25/07/13 Mark Riddoch Addition of diagnotics
|
||||||
* 23/05/14 Mark Riddoch Addition of routine to find monitors by name
|
* 23/05/14 Mark Riddoch Addition of routine to find monitors by name
|
||||||
|
* 23/05/14 Massimiliano Pinto Addition of defaultId and setInterval
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -66,6 +67,8 @@ typedef struct {
|
|||||||
void (*unregisterServer)(void *, SERVER *);
|
void (*unregisterServer)(void *, SERVER *);
|
||||||
void (*defaultUser)(void *, char *, char *);
|
void (*defaultUser)(void *, char *, char *);
|
||||||
void (*diagnostics)(DCB *, void *);
|
void (*diagnostics)(DCB *, void *);
|
||||||
|
void (*setInterval)(void *, unsigned long);
|
||||||
|
void (*defaultId)(void *, unsigned long);
|
||||||
} MONITOR_OBJECT;
|
} MONITOR_OBJECT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -26,6 +26,8 @@
|
|||||||
* 22/07/13 Mark Riddoch Initial implementation
|
* 22/07/13 Mark Riddoch Initial implementation
|
||||||
* 21/05/14 Massimiliano Pinto Monitor sets a master server
|
* 21/05/14 Massimiliano Pinto Monitor sets a master server
|
||||||
* that has the lowest value of wsrep_local_index
|
* that has the lowest value of wsrep_local_index
|
||||||
|
* 23/05/14 Massimiliano Pinto Added 1 configuration option (setInterval).
|
||||||
|
* Interval is printed in diagnostics.
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -47,7 +49,7 @@ extern int lm_enabled_logfiles_bitmask;
|
|||||||
|
|
||||||
static void monitorMain(void *);
|
static void monitorMain(void *);
|
||||||
|
|
||||||
static char *version_str = "V1.1.0";
|
static char *version_str = "V1.1.1";
|
||||||
|
|
||||||
static void *startMonitor(void *);
|
static void *startMonitor(void *);
|
||||||
static void stopMonitor(void *);
|
static void stopMonitor(void *);
|
||||||
@ -55,8 +57,9 @@ static void registerServer(void *, SERVER *);
|
|||||||
static void unregisterServer(void *, SERVER *);
|
static void unregisterServer(void *, SERVER *);
|
||||||
static void defaultUsers(void *, char *, char *);
|
static void defaultUsers(void *, char *, char *);
|
||||||
static void diagnostics(DCB *, void *);
|
static void diagnostics(DCB *, void *);
|
||||||
|
static void setInterval(void *, unsigned long);
|
||||||
|
|
||||||
static MONITOR_OBJECT MyObject = { startMonitor, stopMonitor, registerServer, unregisterServer, defaultUsers, diagnostics };
|
static MONITOR_OBJECT MyObject = { startMonitor, stopMonitor, registerServer, unregisterServer, defaultUsers, diagnostics, setInterval, NULL };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the mandatory version entry point
|
* Implementation of the mandatory version entry point
|
||||||
@ -121,6 +124,8 @@ MYSQL_MONITOR *handle;
|
|||||||
handle->shutdown = 0;
|
handle->shutdown = 0;
|
||||||
handle->defaultUser = NULL;
|
handle->defaultUser = NULL;
|
||||||
handle->defaultPasswd = NULL;
|
handle->defaultPasswd = NULL;
|
||||||
|
handle->id = MONITOR_DEFAULT_ID;
|
||||||
|
handle->interval = MONITOR_INTERVAL;
|
||||||
spinlock_init(&handle->lock);
|
spinlock_init(&handle->lock);
|
||||||
}
|
}
|
||||||
handle->tid = (THREAD)thread_start(monitorMain, handle);
|
handle->tid = (THREAD)thread_start(monitorMain, handle);
|
||||||
@ -434,6 +439,19 @@ long master_id;
|
|||||||
|
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
thread_millisleep(MONITOR_INTERVAL);
|
thread_millisleep(handle->interval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the monitor sampling interval.
|
||||||
|
*
|
||||||
|
* @param arg The handle allocated by startMonitor
|
||||||
|
* @param interval The interval to set in monitor struct, in milliseconds
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
setInterval(void *arg, unsigned long interval)
|
||||||
|
{
|
||||||
|
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
||||||
|
memcpy(&handle->interval, &interval, sizeof(unsigned long));
|
||||||
|
}
|
||||||
|
|||||||
@ -30,6 +30,8 @@
|
|||||||
* diagnostic interface
|
* diagnostic interface
|
||||||
* 20/05/14 Massimiliano Pinto Addition of support for MariadDB multimaster replication setup.
|
* 20/05/14 Massimiliano Pinto Addition of support for MariadDB multimaster replication setup.
|
||||||
* New server field version_string is updated.
|
* New server field version_string is updated.
|
||||||
|
* 28/05/14 Massimiliano Pinto Added set Id and configuration options (setInverval)
|
||||||
|
* Parameters are now printed in diagnostics
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -51,7 +53,7 @@ extern int lm_enabled_logfiles_bitmask;
|
|||||||
|
|
||||||
static void monitorMain(void *);
|
static void monitorMain(void *);
|
||||||
|
|
||||||
static char *version_str = "V1.1.0";
|
static char *version_str = "V1.1.1";
|
||||||
|
|
||||||
static void *startMonitor(void *);
|
static void *startMonitor(void *);
|
||||||
static void stopMonitor(void *);
|
static void stopMonitor(void *);
|
||||||
@ -59,8 +61,10 @@ static void registerServer(void *, SERVER *);
|
|||||||
static void unregisterServer(void *, SERVER *);
|
static void unregisterServer(void *, SERVER *);
|
||||||
static void defaultUser(void *, char *, char *);
|
static void defaultUser(void *, char *, char *);
|
||||||
static void diagnostics(DCB *, void *);
|
static void diagnostics(DCB *, void *);
|
||||||
|
static void setInterval(void *, unsigned long);
|
||||||
|
static void defaultId(void *, unsigned long);
|
||||||
|
|
||||||
static MONITOR_OBJECT MyObject = { startMonitor, stopMonitor, registerServer, unregisterServer, defaultUser, diagnostics };
|
static MONITOR_OBJECT MyObject = { startMonitor, stopMonitor, registerServer, unregisterServer, defaultUser, diagnostics, setInterval, defaultId };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the mandatory version entry point
|
* Implementation of the mandatory version entry point
|
||||||
@ -126,6 +130,8 @@ MYSQL_MONITOR *handle;
|
|||||||
handle->shutdown = 0;
|
handle->shutdown = 0;
|
||||||
handle->defaultUser = NULL;
|
handle->defaultUser = NULL;
|
||||||
handle->defaultPasswd = NULL;
|
handle->defaultPasswd = NULL;
|
||||||
|
handle->id = MONITOR_DEFAULT_ID;
|
||||||
|
handle->interval = MONITOR_INTERVAL;
|
||||||
spinlock_init(&handle->lock);
|
spinlock_init(&handle->lock);
|
||||||
}
|
}
|
||||||
handle->tid = (THREAD)thread_start(monitorMain, handle);
|
handle->tid = (THREAD)thread_start(monitorMain, handle);
|
||||||
@ -261,7 +267,11 @@ char *sep;
|
|||||||
dcb_printf(dcb, "\tMonitor stopped\n");
|
dcb_printf(dcb, "\tMonitor stopped\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dcb_printf(dcb,"\tSampling interval:\t\t%lu milliseconds\n", handle->interval);
|
||||||
|
dcb_printf(dcb,"\tMaxScale MonitorId:\t\t%lu\n", handle->id);
|
||||||
dcb_printf(dcb, "\tMonitored servers: ");
|
dcb_printf(dcb, "\tMonitored servers: ");
|
||||||
|
|
||||||
db = handle->databases;
|
db = handle->databases;
|
||||||
sep = "";
|
sep = "";
|
||||||
while (db)
|
while (db)
|
||||||
@ -466,6 +476,32 @@ MONITOR_SERVERS *ptr;
|
|||||||
monitorDatabase(ptr, handle->defaultUser, handle->defaultPasswd);
|
monitorDatabase(ptr, handle->defaultUser, handle->defaultPasswd);
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
thread_millisleep(10000);
|
thread_millisleep(handle->interval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the default id to use in the monitor.
|
||||||
|
*
|
||||||
|
* @param arg The handle allocated by startMonitor
|
||||||
|
* @param id The id to set in monitor struct
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
defaultId(void *arg, unsigned long id)
|
||||||
|
{
|
||||||
|
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
||||||
|
memcpy(&handle->id, &id, sizeof(unsigned long));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the monitor sampling interval.
|
||||||
|
*
|
||||||
|
* @param arg The handle allocated by startMonitor
|
||||||
|
* @param interval The interval to set in monitor struct, in milliseconds
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
setInterval(void *arg, unsigned long interval)
|
||||||
|
{
|
||||||
|
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
||||||
|
memcpy(&handle->interval, &interval, sizeof(unsigned long));
|
||||||
|
}
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
* Date Who Description
|
* Date Who Description
|
||||||
* 08/07/13 Mark Riddoch Initial implementation
|
* 08/07/13 Mark Riddoch Initial implementation
|
||||||
* 26/05/14 Massimiliano Pinto Default values for MONITOR_INTERVAL
|
* 26/05/14 Massimiliano Pinto Default values for MONITOR_INTERVAL
|
||||||
|
* 28/05/14 Massimiliano Pinto Addition of new fields in MYSQL_MONITOR struct
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -55,6 +56,8 @@ typedef struct {
|
|||||||
int status; /**< Monitor status */
|
int status; /**< Monitor status */
|
||||||
char *defaultUser; /**< Default username for monitoring */
|
char *defaultUser; /**< Default username for monitoring */
|
||||||
char *defaultPasswd; /**< Default password for monitoring */
|
char *defaultPasswd; /**< Default password for monitoring */
|
||||||
|
unsigned long interval; /**< Monitor sampling interval */
|
||||||
|
unsigned long id; /**< Monitor ID */
|
||||||
MONITOR_SERVERS *databases; /**< Linked list of servers to monitor */
|
MONITOR_SERVERS *databases; /**< Linked list of servers to monitor */
|
||||||
} MYSQL_MONITOR;
|
} MYSQL_MONITOR;
|
||||||
|
|
||||||
@ -63,5 +66,6 @@ typedef struct {
|
|||||||
#define MONITOR_STOPPED 3
|
#define MONITOR_STOPPED 3
|
||||||
|
|
||||||
#define MONITOR_INTERVAL 10000 // in milliseconds
|
#define MONITOR_INTERVAL 10000 // in milliseconds
|
||||||
|
#define MONITOR_DEFAULT_ID 1UL // unsigned long value
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user