root / plugins / mysql / mysql_slave_threads @ 17f78427
Historique | Voir | Annoter | Télécharger (1,45 ko)
| 1 |
#!/usr/bin/perl |
|---|---|
| 2 |
# Munin plugin for MySQL slave threads monitoring |
| 3 |
# Copyright © 2009 Eutech SSII |
| 4 |
# |
| 5 |
# This program is free software: you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation, either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
# |
| 18 |
# Plugin producing state graphes for a MySQL slave server (1 if |
| 19 |
# I/O or SQL thread is running, 0 otherwise). Can be used to |
| 20 |
# trigger a warning when a replication failure occurs. |
| 21 |
|
| 22 |
use strict; |
| 23 |
|
| 24 |
my $MYSQL = $ENV{mysql} || "mysql";
|
| 25 |
my $MYSQLOPTS = $ENV{mysqlopts} || "";
|
| 26 |
|
| 27 |
if(defined $ARGV[0] && $ARGV[0] eq 'config') {
|
| 28 |
print <<EOC |
| 29 |
graph_title MySQL Slave Threads |
| 30 |
graph_vlabel Running |
| 31 |
graph_category db |
| 32 |
graph_args -l 0 |
| 33 |
io.label I/O Thread |
| 34 |
io.critical 1:1 |
| 35 |
sql.label SQL Thread |
| 36 |
sql.critical 1:1 |
| 37 |
EOC |
| 38 |
; |
| 39 |
exit 0; |
| 40 |
} |
| 41 |
|
| 42 |
my $status = `$MYSQL $MYSQLOPTS -e 'SHOW SLAVE STATUS\\G'`; |
| 43 |
|
| 44 |
$status =~ /Slave_IO_Running: (\w+)/; |
| 45 |
print 'io.value '.($1 eq 'Yes' ? 1 : 0)."\n"; |
| 46 |
$status =~ /Slave_SQL_Running: (\w+)/; |
| 47 |
print 'sql.value '.($1 eq 'Yes' ? 1 : 0)."\n"; |
| 48 |
|
| 49 |
|
