Module: check_mk
Branch: master
Commit: ab01ac097ecdb39ff6324c27115b4853dbfbf682
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ab01ac097ecdb3…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jun 5 09:34:30 2014 +0200
mysql_slave: New check for monitoring MySQL slave sync state
---
.werks/815 | 8 ++++
ChangeLog | 1 +
checkman/mysql_slave | 29 +++++++++++
checks/mysql_slave | 88 ++++++++++++++++++++++++++++++++++
web/plugins/wato/check_parameters.py | 24 ++++++++++
5 files changed, 150 insertions(+)
diff --git a/.werks/815 b/.werks/815
new file mode 100644
index 0000000..77bb675
--- /dev/null
+++ b/.werks/815
@@ -0,0 +1,8 @@
+Title: mysql_slave: New check for monitoring MySQL slave sync state
+Level: 1
+Component: checks
+Version: 1.2.5i4
+Date: 1401953646
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 747a77c..6d184ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
* 0812 nginx_status: New check for monitoring status information of the Nginx web
server...
* 0986 citrix_licenses: new check for monitoring Citrix licenses
* 0814 Agent versions can now be checked with "at least version X"
parameters...
+ * 0815 mysql_slave: New check for monitoring MySQL slave sync state
* 0616 FIX: brocade.fan, brocade.power, brocade.temp: will now only discover services
which are not marked as absent
Multisite:
diff --git a/checkman/mysql_slave b/checkman/mysql_slave
new file mode 100644
index 0000000..aa3393c
--- /dev/null
+++ b/checkman/mysql_slave
@@ -0,0 +1,29 @@
+title: MySQL Database: Slave Sync Status
+agents: linux
+catalog: app/mysql
+license: GPL
+distribution: check_mk
+description:
+ This check monitors the synchronsiation state of MySQL slave databases.
+
+ This check needs the agent plugin {mk_mysql} to be installed on the
+ monitored database server. Further details about this plugin and
+ monitoring of MySQL can be found in the Check_MK online documentation
+ in the article "Monitoring MySQL with Check_MK".
+
+inventory:
+ On each host where the agent plugin {mk_mysql} is being installed
+ and the MySQL daemon is running one service is being generated.
+
+[parameters]
+parameters (dict): A dictionary with currentl just one possible key:
{"seconds_behind_master"}. This
+ is a pair if two floating point numbers:
+
+ {warn} (float): The maximum number of seconds behind the master that triggers
+ a {WARN} state.
+
+ {crit} (float): The maximum number of seconds behind the master that triggers
+ a {CRIT} state.
+
+ If {seconds_behind_master} is not set, the check always reports {CRITICAL} states
+ when either the slave IO or slave SQL are reported as not running.
diff --git a/checks/mysql_slave b/checks/mysql_slave
new file mode 100644
index 0000000..56868d1
--- /dev/null
+++ b/checks/mysql_slave
@@ -0,0 +1,88 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+def inventory_mysql_slave(info):
+ if info:
+ return [(None, {})]
+
+def parse_mysql_slave(info):
+ data = {}
+ for l in info:
+ if ':' in l[0]:
+ val = ' '.join(l[1:])
+
+ # Parse some values
+ try:
+ val = int(val)
+ except ValueError:
+ if val == 'Yes':
+ val = True
+ elif val == 'No':
+ val = False
+ elif val == 'None':
+ val = None
+
+ data[l[0][:-1]] = val
+ return data
+
+def check_mysql_slave(_unused, params, info):
+ data = parse_mysql_slave(info)
+
+ state = 0
+ perfdata = []
+ output = []
+
+ if data['Slave_IO_Running']:
+ output.append('Slave-IO: running')
+ else:
+ output.append('Slave-IO: not running(!!)')
+
+ if data['Slave_SQL_Running']:
+ output.append('Slave-SQL: running')
+ else:
+ output.append('Slave-SQL: not running(!!)')
+
+ out = 'Time behind Master: %s' %
get_age_human_readable(data['Seconds_Behind_Master'])
+ warn, crit = params.get('seconds_behind_master', (None, None))
+ if crit != None and data['Seconds_Behind_Master'] > crit:
+ state = 2
+ out += '(!!)'
+ elif warn != None and data['Seconds_Behind_Master'] > warn:
+ state = 1
+ out += '(!)'
+ output.append(out)
+ perfdata.append(('seconds_behind_master',
data['Seconds_Behind_Master'], warn, crit))
+
+ return state, ', '.join(output), perfdata
+
+check_info['mysql_slave'] = {
+ "check_function" : check_mysql_slave,
+ "inventory_function" : inventory_mysql_slave,
+ "service_description" : "MySQL DB Slave",
+ "has_perfdata" : False,
+ "group" : "mysql_slave",
+}
+
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 0b3b1d8..1b85e29 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -3028,6 +3028,30 @@ register_check_parameters(
register_check_parameters(
subgroup_applications,
+ "mysql_slave",
+ _("MySQL Slave"),
+ Dictionary(
+ elements = [
+ ( "seconds_behind_master",
+ Tuple(
+ title = _("Seconds behind master (Slave lag)"),
+ help = _("When the slave is actively processing updates, this
field shows the difference "
+ "between the current timestamp on the slave and the
original timestamp logged on "
+ "the master for the most event currently being
processed on the slave. "
+ "You can configure the amount of time you treat as a
problem here."),
+ elements = [
+ Age(title = _("Warning if above")),
+ Age(title = _("Critical if above")),
+ ]
+ )
+ ),
+ ]),
+ None,
+ "dict"
+)
+
+register_check_parameters(
+ subgroup_applications,
"f5_connections",
_("F5 Loadbalancer Connections"),
Dictionary(