Skip to content

Commit 1bc574f

Browse files
authored
Update mysql plugin to work with MySQL 8.4 (#1676)
Fixes #1648
2 parents eb5a3c7 + da95a1c commit 1bc574f

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

plugins/node.d/mysql_

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ resources for each graph
126126
=item mysql_replication
127127
128128
slave_io_running and slave_sql_running both translate the "Yes" values to 0 and
129-
anything else to 1 for their respective fields in the "SHOW SLAVE STATUS" output.
130-
This can be used to warn on slave failure if the warning and critical values
129+
anything else to 1 for their respective fields in the "SHOW REPLICA STATUS" output.
130+
This can be used to warn on replica failure if the warning and critical values
131131
are set as seen in a previous section.
132132
133133
=item wsrep_cluster_status
@@ -2018,12 +2018,12 @@ sub update_innodb {
20182018
sub update_master {
20192019
my ($dbh) = @_;
20202020

2021-
my $sth = $dbh->prepare('SHOW MASTER LOGS');
2021+
my $sth = $dbh->prepare('SHOW BINARY LOGS');
20222022
eval {
20232023
$sth->execute();
20242024
};
20252025
if ($@) {
2026-
# SHOW MASTER LOGS failed because binlog is not enabled
2026+
# SHOW BINARY LOGS failed because binlog is not enabled
20272027
return if $@ =~ /You are not using binary logging/;
20282028
die $@;
20292029
}
@@ -2039,7 +2039,7 @@ sub update_master {
20392039
sub update_slave {
20402040
my ($dbh) = @_;
20412041

2042-
my $sth = $dbh->prepare('SHOW SLAVE STATUS');
2042+
my $sth = $dbh->prepare('SHOW REPLICA STATUS');
20432043
$sth->execute();
20442044
my $row = $sth->fetchrow_hashref();
20452045
return 1 unless $row;
@@ -2048,21 +2048,21 @@ sub update_slave {
20482048
}
20492049
$sth->finish();
20502050

2051-
# We choose master_host here as a stopped slave
2052-
# may not indicate that we have reset all slave capability
2051+
# We choose master_host here as a stopped replica
2052+
# may not indicate that we have reset all replica capability
20532053
# however the minimium requirement is a master_host
2054-
return 1 if not defined $data->{master_host};
2054+
return 1 if not defined $data->{source_host};
20552055

2056-
# undef when slave is stopped, or when MySQL fails to calculate
2056+
# undef when replica is stopped, or when MySQL fails to calculate
20572057
# the lag (which happens depresingly often). (mk-heartbeat fixes
20582058
# this problem.)
20592059
$data->{seconds_behind_master} ||= 0;
20602060

2061-
# Track these two fields so we can trigger warnings if the slave stops
2061+
# Track these two fields so we can trigger warnings if the replica stops
20622062
# running
2063-
$data->{slave_sql_running} = ($data->{slave_sql_running} eq 'Yes')
2063+
$data->{slave_sql_running} = ($data->{replica_sql_running} eq 'Yes')
20642064
? 0 : 1;
2065-
$data->{slave_io_running} = ($data->{slave_io_running} eq 'Yes')
2065+
$data->{slave_io_running} = ($data->{replica_io_running} eq 'Yes')
20662066
? 0 : 1;
20672067
return 0;
20682068
}

0 commit comments

Comments
 (0)