monitorID and monitor_interval
monitorID and monitor_interval
This commit is contained in:
@ -31,6 +31,7 @@
|
|||||||
* 11/03/14 Massimiliano Pinto Added Unix socket support
|
* 11/03/14 Massimiliano Pinto Added Unix socket support
|
||||||
* 11/05/14 Massimiliano Pinto Added version_string support to service
|
* 11/05/14 Massimiliano Pinto Added version_string support to service
|
||||||
* 19/05/14 Mark Riddoch Added unique names from section headers
|
* 19/05/14 Mark Riddoch Added unique names from section headers
|
||||||
|
* 23/05/14 Massimiliano Pinto Added automatic set of maxscale-id: first listening ipv4_raw + port + pid
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -494,18 +495,37 @@ int error_count = 0;
|
|||||||
char *servers;
|
char *servers;
|
||||||
char *user;
|
char *user;
|
||||||
char *passwd;
|
char *passwd;
|
||||||
|
unsigned long interval = 0;
|
||||||
|
|
||||||
module = config_get_value(obj->parameters, "module");
|
module = config_get_value(obj->parameters, "module");
|
||||||
servers = config_get_value(obj->parameters, "servers");
|
servers = config_get_value(obj->parameters, "servers");
|
||||||
user = config_get_value(obj->parameters, "user");
|
user = config_get_value(obj->parameters, "user");
|
||||||
passwd = config_get_value(obj->parameters, "passwd");
|
passwd = config_get_value(obj->parameters, "passwd");
|
||||||
|
if (config_get_value(obj->parameters, "monitor_interval")) {
|
||||||
|
interval = strtoul(config_get_value(obj->parameters, "monitor_interval"), NULL, 10);
|
||||||
|
}
|
||||||
|
|
||||||
if (module)
|
if (module)
|
||||||
{
|
{
|
||||||
obj->element = monitor_alloc(obj->object, module);
|
obj->element = monitor_alloc(obj->object, module);
|
||||||
if (servers && obj->element)
|
if (servers && obj->element)
|
||||||
{
|
{
|
||||||
char *s = strtok(servers, ",");
|
char *s;
|
||||||
|
|
||||||
|
/* if id is not set, compute it now with pid only */
|
||||||
|
if (gateway.id == 0) {
|
||||||
|
gateway.id = getpid();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* add the maxscale-id to monitor data */
|
||||||
|
monitorSetId(obj->element, gateway.id);
|
||||||
|
|
||||||
|
/* set monitor interval */
|
||||||
|
if (interval > 0)
|
||||||
|
monitorSetInterval(obj->element, interval);
|
||||||
|
|
||||||
|
/* get the servers to monitor */
|
||||||
|
s = strtok(servers, ",");
|
||||||
while (s)
|
while (s)
|
||||||
{
|
{
|
||||||
CONFIG_CONTEXT *obj1 = context;
|
CONFIG_CONTEXT *obj1 = context;
|
||||||
@ -747,6 +767,7 @@ global_defaults()
|
|||||||
gateway.version_string = strdup(version_string);
|
gateway.version_string = strdup(version_string);
|
||||||
else
|
else
|
||||||
gateway.version_string = NULL;
|
gateway.version_string = NULL;
|
||||||
|
gateway.id=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1004,6 +1025,7 @@ SERVER *server;
|
|||||||
char *protocol;
|
char *protocol;
|
||||||
char *address;
|
char *address;
|
||||||
char *socket;
|
char *socket;
|
||||||
|
struct sockaddr_in serv_addr;
|
||||||
|
|
||||||
service = config_get_value(obj->parameters, "service");
|
service = config_get_value(obj->parameters, "service");
|
||||||
address = config_get_value(obj->parameters, "address");
|
address = config_get_value(obj->parameters, "address");
|
||||||
@ -1011,6 +1033,12 @@ SERVER *server;
|
|||||||
protocol = config_get_value(obj->parameters, "protocol");
|
protocol = config_get_value(obj->parameters, "protocol");
|
||||||
socket = config_get_value(obj->parameters, "socket");
|
socket = config_get_value(obj->parameters, "socket");
|
||||||
|
|
||||||
|
/* if id is not set, do it now */
|
||||||
|
if (gateway.id == 0) {
|
||||||
|
setipaddress(&serv_addr.sin_addr, (address == NULL) ? "0.0.0.0" : address);
|
||||||
|
gateway.id = (unsigned long) (serv_addr.sin_addr.s_addr + port + getpid());
|
||||||
|
}
|
||||||
|
|
||||||
if (service && socket && protocol)
|
if (service && socket && protocol)
|
||||||
{
|
{
|
||||||
CONFIG_CONTEXT *ptr = context;
|
CONFIG_CONTEXT *ptr = context;
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
* Date Who Description
|
* Date Who Description
|
||||||
* 21/06/13 Mark Riddoch Initial implementation
|
* 21/06/13 Mark Riddoch Initial implementation
|
||||||
* 07/05/14 Massimiliano Pinto Added version_string to global configuration
|
* 07/05/14 Massimiliano Pinto Added version_string to global configuration
|
||||||
|
* 23/05/14 Massimiliano Pinto Added id to global configuration
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -78,6 +79,7 @@ typedef struct config_context {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
int n_threads; /**< Number of polling threads */
|
int n_threads; /**< Number of polling threads */
|
||||||
char *version_string; /**< The version string of embedded database library */
|
char *version_string; /**< The version string of embedded database library */
|
||||||
|
unsigned long id; /**< MaxScale ID */
|
||||||
} GATEWAY_CONF;
|
} GATEWAY_CONF;
|
||||||
|
|
||||||
extern int config_load(char *);
|
extern int config_load(char *);
|
||||||
|
|||||||
Reference in New Issue
Block a user