root / plugins / mysql / mysql_slave_threads @ 852aa41a
Historique | Voir | Annoter | Télécharger (1,65 ko)
| 1 | c1d110bb | S?bastien Le Ray - Eutech SSII | #!/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 | 4547f33d | Anthony Baccuet | my $status = `$MYSQL $MYSQLOPTS -e 'SHOW SLAVE STATUS\\G'`; |
| 28 | |||
| 29 | my $sqlerror = ""; |
||
| 30 | my $ioerror = ""; |
||
| 31 | |||
| 32 | if ($status =~ /Last_SQL_Error: (.+)/) {
|
||
| 33 | $sqlerror = $1; |
||
| 34 | } |
||
| 35 | if ($status =~ /Last_IO_Error: (.+)/) {
|
||
| 36 | $ioerror = $1; |
||
| 37 | } |
||
| 38 | |||
| 39 | |||
| 40 | c1d110bb | S?bastien Le Ray - Eutech SSII | if(defined $ARGV[0] && $ARGV[0] eq 'config') {
|
| 41 | print <<EOC |
||
| 42 | graph_title MySQL Slave Threads |
||
| 43 | graph_vlabel Running |
||
| 44 | 8af93fce | dipohl | graph_category db |
| 45 | c1d110bb | S?bastien Le Ray - Eutech SSII | graph_args -l 0 |
| 46 | io.label I/O Thread |
||
| 47 | io.critical 1:1 |
||
| 48 | 4547f33d | Anthony Baccuet | io.extinfo $ioerror |
| 49 | c1d110bb | S?bastien Le Ray - Eutech SSII | sql.label SQL Thread |
| 50 | sql.critical 1:1 |
||
| 51 | 4547f33d | Anthony Baccuet | sql.extinfo $sqlerror |
| 52 | c1d110bb | S?bastien Le Ray - Eutech SSII | EOC |
| 53 | ; |
||
| 54 | exit 0; |
||
| 55 | } |
||
| 56 | |||
| 57 | |||
| 58 | 17f78427 | Lars Kruse | $status =~ /Slave_IO_Running: (\w+)/; |
| 59 | c1d110bb | S?bastien Le Ray - Eutech SSII | print 'io.value '.($1 eq 'Yes' ? 1 : 0)."\n"; |
| 60 | $status =~ /Slave_SQL_Running: (\w+)/; |
||
| 61 | print 'sql.value '.($1 eq 'Yes' ? 1 : 0)."\n"; |
