int port;
int timeout;
- bool master_stats;
- bool slave_stats;
+ bool primary_stats;
+ bool replica_stats;
bool innodb_stats;
bool wsrep_stats;
- bool slave_notif;
- bool slave_io_running;
- bool slave_sql_running;
+ bool replica_notif;
+ bool replica_io_running;
+ bool replica_sql_running;
MYSQL *con;
bool is_connected;
db->timeout = 0;
/* trigger a notification, if it's not running */
- db->slave_io_running = true;
- db->slave_sql_running = true;
+ db->replica_io_running = true;
+ db->replica_sql_running = true;
status = cf_util_get_string(ci, &db->instance);
if (status != 0) {
else if (strcasecmp("ConnectTimeout", child->key) == 0)
status = cf_util_get_int(child, &db->timeout);
else if (strcasecmp("MasterStats", child->key) == 0)
- status = cf_util_get_boolean(child, &db->master_stats);
+ status = cf_util_get_boolean(child, &db->primary_stats);
else if (strcasecmp("SlaveStats", child->key) == 0)
- status = cf_util_get_boolean(child, &db->slave_stats);
+ status = cf_util_get_boolean(child, &db->replica_stats);
else if (strcasecmp("SlaveNotifications", child->key) == 0)
- status = cf_util_get_boolean(child, &db->slave_notif);
+ status = cf_util_get_boolean(child, &db->replica_notif);
else if (strcasecmp("InnodbStats", child->key) == 0)
status = cf_util_get_boolean(child, &db->innodb_stats);
else if (strcasecmp("WsrepStats", child->key) == 0)
return res;
} /* exec_query */
-static int mysql_read_master_stats(mysql_database_t *db, MYSQL *con) {
+static int mysql_read_primary_stats(mysql_database_t *db, MYSQL *con) {
MYSQL_RES *res;
MYSQL_ROW row;
row = mysql_fetch_row(res);
if (row == NULL) {
- ERROR("mysql plugin: Failed to get master statistics: "
+ ERROR("mysql plugin: Failed to get primary statistics: "
"`%s' did not return any rows.",
query);
mysql_free_result(res);
field_num = mysql_num_fields(res);
if (field_num < 2) {
- ERROR("mysql plugin: Failed to get master statistics: "
+ ERROR("mysql plugin: Failed to get primary statistics: "
"`%s' returned less than two columns.",
query);
mysql_free_result(res);
}
position = atoll(row[1]);
- derive_submit("mysql_log_position", "master-bin", position, db);
+ derive_submit("mysql_log_position", "primary-bin", position, db);
row = mysql_fetch_row(res);
if (row != NULL)
mysql_free_result(res);
return 0;
-} /* mysql_read_master_stats */
+} /* mysql_read_primary_stats */
-static int mysql_read_slave_stats(mysql_database_t *db, MYSQL *con) {
+static int mysql_read_replica_stats(mysql_database_t *db, MYSQL *con) {
MYSQL_RES *res;
MYSQL_ROW row;
row = mysql_fetch_row(res);
if (row == NULL) {
- ERROR("mysql plugin: Failed to get slave statistics: "
+ ERROR("mysql plugin: Failed to get replica statistics: "
"`%s' did not return any rows.",
query);
mysql_free_result(res);
field_num = mysql_num_fields(res);
if (field_num < 33) {
- ERROR("mysql plugin: Failed to get slave statistics: "
+ ERROR("mysql plugin: Failed to get replica statistics: "
"`%s' returned less than 33 columns.",
query);
mysql_free_result(res);
return -1;
}
- if (db->slave_stats) {
+ if (db->replica_stats) {
unsigned long long counter;
double gauge;
- gauge_submit("bool", "slave-sql-running",
+ gauge_submit("bool", "replica-sql-running",
(row[SLAVE_SQL_RUNNING_IDX] != NULL) &&
(strcasecmp(row[SLAVE_SQL_RUNNING_IDX], "yes") == 0),
db);
- gauge_submit("bool", "slave-io-running",
+ gauge_submit("bool", "replica-io-running",
(row[SLAVE_IO_RUNNING_IDX] != NULL) &&
(strcasecmp(row[SLAVE_IO_RUNNING_IDX], "yes") == 0),
db);
counter = atoll(row[READ_MASTER_LOG_POS_IDX]);
- derive_submit("mysql_log_position", "slave-read", counter, db);
+ derive_submit("mysql_log_position", "replica-read", counter, db);
counter = atoll(row[EXEC_MASTER_LOG_POS_IDX]);
- derive_submit("mysql_log_position", "slave-exec", counter, db);
+ derive_submit("mysql_log_position", "replica-exec", counter, db);
if (row[SECONDS_BEHIND_MASTER_IDX] != NULL) {
gauge = atof(row[SECONDS_BEHIND_MASTER_IDX]);
}
}
- if (db->slave_notif) {
+ if (db->replica_notif) {
notification_t n = {0, cdtime(), "", "", "mysql",
"", "time_offset", "", NULL};
sstrncpy(n.plugin_instance, db->instance, sizeof(n.plugin_instance));
if (((io == NULL) || (strcasecmp(io, "yes") != 0)) &&
- (db->slave_io_running)) {
+ (db->replica_io_running)) {
n.severity = NOTIF_WARNING;
ssnprintf(n.message, sizeof(n.message),
- "slave I/O thread not started or not connected to master");
+ "replica I/O thread not started or not connected to primary");
plugin_dispatch_notification(&n);
- db->slave_io_running = false;
+ db->replica_io_running = false;
} else if (((io != NULL) && (strcasecmp(io, "yes") == 0)) &&
- (!db->slave_io_running)) {
+ (!db->replica_io_running)) {
n.severity = NOTIF_OKAY;
ssnprintf(n.message, sizeof(n.message),
- "slave I/O thread started and connected to master");
+ "replica I/O thread started and connected to primary");
plugin_dispatch_notification(&n);
- db->slave_io_running = true;
+ db->replica_io_running = true;
}
if (((sql == NULL) || (strcasecmp(sql, "yes") != 0)) &&
- (db->slave_sql_running)) {
+ (db->replica_sql_running)) {
n.severity = NOTIF_WARNING;
- ssnprintf(n.message, sizeof(n.message), "slave SQL thread not started");
+ ssnprintf(n.message, sizeof(n.message), "replica SQL thread not started");
plugin_dispatch_notification(&n);
- db->slave_sql_running = false;
+ db->replica_sql_running = false;
} else if (((sql != NULL) && (strcasecmp(sql, "yes") == 0)) &&
- (!db->slave_sql_running)) {
+ (!db->replica_sql_running)) {
n.severity = NOTIF_OKAY;
- ssnprintf(n.message, sizeof(n.message), "slave SQL thread started");
+ ssnprintf(n.message, sizeof(n.message), "replica SQL thread started");
plugin_dispatch_notification(&n);
- db->slave_sql_running = true;
+ db->replica_sql_running = true;
}
}
mysql_free_result(res);
return 0;
-} /* mysql_read_slave_stats */
+} /* mysql_read_replica_stats */
static int mysql_read_innodb_stats(mysql_database_t *db, MYSQL *con) {
MYSQL_RES *res;
if (db->mysql_version >= 50600 && db->innodb_stats)
mysql_read_innodb_stats(db, con);
- if (db->master_stats)
- mysql_read_master_stats(db, con);
+ if (db->primary_stats)
+ mysql_read_primary_stats(db, con);
- if ((db->slave_stats) || (db->slave_notif))
- mysql_read_slave_stats(db, con);
+ if ((db->replica_stats) || (db->replica_notif))
+ mysql_read_replica_stats(db, con);
if (db->wsrep_stats)
mysql_read_wsrep_stats(db, con);