2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
28 # FIXME: Crapy copy n paste! Consolidate with other mysql_* parse functions
29 def parse_mysql_slave(info
):
44 return line
[0][:-1], val
50 if line
[0].startswith("[["):
51 instance
= line
[0][2:-2]
56 key
, value
= parse_line(line
)
58 parsed
[instance
][key
] = value
60 # Support for old Plugin version
64 key
, value
= parse_line(line
)
66 parsed
['mysql'][key
] = value
72 def inventory_mysql_slave(key
, values
):
73 return len(values
) > 0
77 def check_mysql_slave(item
, params
, data
):
82 if data
['Slave_IO_Running']:
83 output
.append('Slave-IO: running')
85 if data
['Relay_Log_Space']:
86 output
.append('Relay Log: %s' % get_bytes_human_readable(data
['Relay_Log_Space']))
87 perfdata
.append(('relay_log_space', data
['Relay_Log_Space']))
90 output
.append('Slave-IO: not running(!!)')
93 if data
['Slave_SQL_Running']:
94 output
.append('Slave-SQL: running')
96 # Makes only sense to monitor the age when the SQL slave is running
97 if data
['Seconds_Behind_Master'] == 'NULL':
98 output
.append('Time behind master: NULL (Lost connection?)(!!)')
101 out
= 'Time behind Master: %s' % get_age_human_readable(data
['Seconds_Behind_Master'])
102 warn
, crit
= params
.get('seconds_behind_master', (None, None))
103 if crit
is not None and data
['Seconds_Behind_Master'] > crit
:
106 elif warn
is not None and data
['Seconds_Behind_Master'] > warn
:
107 state
= max(state
, 1)
110 perfdata
.append(('sync_latency', data
['Seconds_Behind_Master'], warn
, crit
))
112 output
.append('Slave-SQL: not running(!!)')
115 return state
, ', '.join(output
), perfdata
118 check_info
['mysql_slave'] = {
119 "parse_function": parse_mysql_slave
,
120 "inventory_function": inventory_mysql_slave
,
121 "check_function": check_mysql_slave
,
122 "service_description": "MySQL DB Slave %s",
123 "has_perfdata": True,
124 "group": "mysql_slave",