Module: check_mk
Branch: master
Commit: 774399d55fe35f7925c388a05385f88a38ac37cf
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=774399d55fe35f…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Dec 12 13:39:32 2012 +0100
Add: mysql_connections - Monitor number of parallel connections to mysql daemon
---
ChangeLog | 1 +
agents/plugins/mk_mysql | 2 +-
checks/mysql | 48 ++++++++++++++++++++++++++++++++++
web/plugins/wato/check_parameters.py | 24 +++++++++++++++++
4 files changed, 74 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4b40fa7..f088cc6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -27,6 +27,7 @@
* Add: sym_brightmail_queues - monitor the queue levels on Symantec Brightmail mail
scanners.
* Add: plesk_domains - List domains configured in plesk installations
* Add: plesk_backups - Monitor backup spaces configured for domains in plesk
+ * Add: mysql_connections - Monitor number of parallel connections to mysql daemon
* FIX: zfsget: fix exception on snapshot volumes (where available is '-')
* FIX: loading notification scripts in local directory for real
* FIX: oracle_version: return valid check result in case of missing agent info
diff --git a/agents/plugins/mk_mysql b/agents/plugins/mk_mysql
index e634149..de28d4c 100755
--- a/agents/plugins/mk_mysql
+++ b/agents/plugins/mk_mysql
@@ -31,5 +31,5 @@ then
mysqladmin --defaults-extra-file=$MK_CONFDIR/mysql.cfg ping 2>&1
mysql --defaults-extra-file=$MK_CONFDIR/mysql.cfg -sN \
- -e "select '<<<mysql>>>' ; show global status; select
'<<<mysql_capacity>>>' ; SELECT table_schema, sum( data_length +
index_length ), sum( data_free ) FROM information_schema.TABLES GROUP BY
table_schema;"
+ -e "select '<<<mysql>>>' ; show global status; show
global variables; select '<<<mysql_capacity>>>' ; SELECT
table_schema, sum( data_length + index_length ), sum( data_free ) FROM
information_schema.TABLES GROUP BY table_schema;"
fi
diff --git a/checks/mysql b/checks/mysql
index 6087d89..4fe957b 100644
--- a/checks/mysql
+++ b/checks/mysql
@@ -154,3 +154,51 @@ check_info['mysql.innodb_io'] = {
"has_perfdata" : True,
"group" : "mysql_innodb_io",
}
+
+# .--Connections---------------------------------------------------------.
+# | ____ _ _ |
+# | / ___|___ _ __ _ __ ___ ___| |_(_) ___ _ __ ___ |
+# | | | / _ \| '_ \| '_ \ / _ \/ __| __| |/ _ \| '_ \/ __| |
+# | | |__| (_) | | | | | | | __/ (__| |_| | (_) | | | \__ \ |
+# | \____\___/|_| |_|_| |_|\___|\___|\__|_|\___/|_| |_|___/ |
+# | |
+# +----------------------------------------------------------------------+
+
+def inventory_mysql_connections(info):
+ values = parse_mysql(info)
+ if 'Max_used_connections' in values:
+ return [(None, {})]
+
+def check_mysql_connections(item, params, info):
+ values = parse_mysql(info)
+ # The maximum number of connections that have been in use simultaneously
+ # since the server started.
+ conn = float(values['Max_used_connections'])
+ # Maximum number of possible parallel connections
+ max_conn = float(values['max_connections'])
+
+ perc_used = conn / max_conn * 100
+
+ status = 0
+ status_txt = ''
+ if 'perc_used' in params:
+ if perc_used >= params['perc_used'][1]:
+ status = 2
+ status_txt = ' (Threshold (%0.2f%%) for number of maximum parallel
connections ' \
+ 'has been reached at least once since program start' %
params['perc_used'][1]
+ elif perc_used >= params['perc_used'][0]:
+ status = 1
+ status_txt = ' (Threshold (%0.2f%%) for number of maximum parallel
connections ' \
+ 'has been reached at least once since program start)' %
params['perc_used'][0]
+
+ return (status, '%s - Max. parallel Connections: %d (Max.: %d): %0.2f%%%s' %
+ (nagios_state_names[status], conn, max_conn, perc_used, status_txt))
+
+
+check_info['mysql.connections'] = {
+ "check_function" : check_mysql_connections,
+ "inventory_function" : inventory_mysql_connections,
+ "service_description" : "MySQL Daemon Connections",
+ "has_perfdata" : True,
+ "group" : "mysql_connections",
+}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 4b0a20d..41326f4 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -1412,6 +1412,30 @@ checkgroups.append((
checkgroups.append((
subgroup_applications,
+ "mysql_connections",
+ _("MySQL Connections"),
+ Dictionary(
+ elements = [
+ ( "perc_used",
+ Tuple(
+ title = _("Max. parallel connections"),
+ help = _("Compares the the maximum number of connections that
have been "
+ "in use simultaneously since the server started with
the maximum parallel "
+ "connections allowed by the configuration of the
server. This threshold "
+ "makes the check raises warning/critical states if the
percentage is equal to "
+ "or above the configured levels."),
+ elements = [
+ Percentage(title = _("Warning at")),
+ Percentage(title = _("Critical at")),
+ ]
+ )
+ ),
+ ]),
+ None,
+ "dict"))
+
+checkgroups.append((
+ subgroup_applications,
"dbsize",
_("Size of MySQL/PostgresQL databases"),
Optional(