Skip to content

Commit

Permalink
Add error message to extinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Baccuet committed Jan 16, 2019
1 parent a535a5d commit 4547f33
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions plugins/mysql/mysql_slave_threads
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ use strict;
my $MYSQL = $ENV{mysql} || "mysql";
my $MYSQLOPTS = $ENV{mysqlopts} || "";

my $status = `$MYSQL $MYSQLOPTS -e 'SHOW SLAVE STATUS\\G'`;

my $sqlerror = "";
my $ioerror = "";

if ($status =~ /Last_SQL_Error: (.+)/) {
$sqlerror = $1;
}
if ($status =~ /Last_IO_Error: (.+)/) {
$ioerror = $1;
}


if(defined $ARGV[0] && $ARGV[0] eq 'config') {
print <<EOC
graph_title MySQL Slave Threads
Expand All @@ -32,18 +45,18 @@ graph_category db
graph_args -l 0
io.label I/O Thread
io.critical 1:1
io.extinfo $ioerror
sql.label SQL Thread
sql.critical 1:1
sql.extinfo $sqlerror
EOC
;
exit 0;
}

my $status = `$MYSQL $MYSQLOPTS -e 'SHOW SLAVE STATUS\\G'`;

$status =~ /Slave_IO_Running: (\w+)/;
print 'io.value '.($1 eq 'Yes' ? 1 : 0)."\n";
$status =~ /Slave_SQL_Running: (\w+)/;
print 'sql.value '.($1 eq 'Yes' ? 1 : 0)."\n";


0 comments on commit 4547f33

Please sign in to comment.