Track the number of performed monitoring intervals
Tracking how many times the monitor has performed its monitoring allows the test framework to consistently wait for an event instead of waiting for a hard-coded time period. The MaxCtrl `api get` command can be used to easily extract the numeric value.
This commit is contained in:
@ -148,6 +148,7 @@ const char CN_STRIP_DB_ESC[] = "strip_db_esc";
|
||||
const char CN_SUBSTITUTE_VARIABLES[] = "substitute_variables";
|
||||
const char CN_THREADS[] = "threads";
|
||||
const char CN_THREAD_STACK_SIZE[] = "thread_stack_size";
|
||||
const char CN_TICKS[] = "ticks";
|
||||
const char CN_TYPE[] = "type";
|
||||
const char CN_UNIX[] = "unix";
|
||||
const char CN_USER[] = "user";
|
||||
|
||||
@ -137,6 +137,7 @@ MXS_MONITOR* monitor_alloc(const char *name, const char *module)
|
||||
mon->script_timeout = DEFAULT_SCRIPT_TIMEOUT;
|
||||
mon->parameters = NULL;
|
||||
mon->server_pending_changes = false;
|
||||
mon->ticks = 0;
|
||||
memset(mon->journal_hash, 0, sizeof(mon->journal_hash));
|
||||
spinlock_init(&mon->lock);
|
||||
spinlock_acquire(&monLock);
|
||||
@ -518,6 +519,7 @@ monitorShow(DCB *dcb, MXS_MONITOR *monitor)
|
||||
dcb_printf(dcb, "Monitor: %p\n", monitor);
|
||||
dcb_printf(dcb, "Name: %s\n", monitor->name);
|
||||
dcb_printf(dcb, "State: %s\n", state);
|
||||
dcb_printf(dcb, "Times monitored: %lu\n", monitor->ticks);
|
||||
dcb_printf(dcb, "Sampling interval: %lu milliseconds\n", monitor->interval);
|
||||
dcb_printf(dcb, "Connect Timeout: %i seconds\n", monitor->connect_timeout);
|
||||
dcb_printf(dcb, "Read Timeout: %i seconds\n", monitor->read_timeout);
|
||||
@ -1860,6 +1862,7 @@ json_t* monitor_json_data(const MXS_MONITOR* monitor, const char* host)
|
||||
|
||||
json_object_set_new(attr, CN_MODULE, json_string(monitor->module_name));
|
||||
json_object_set_new(attr, CN_STATE, json_string(monitor_state_to_string(monitor->state)));
|
||||
json_object_set_new(attr, CN_TICKS, json_integer(monitor->ticks));
|
||||
|
||||
/** Monitor parameters */
|
||||
json_object_set_new(attr, CN_PARAMETERS, monitor_parameters_to_json(monitor));
|
||||
|
||||
Reference in New Issue
Block a user