Module: check_mk
Branch: master
Commit: 63d71de4ca107e62d4f907fb387dfe77e42937d4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=63d71de4ca107e…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Jun 4 17:15:34 2012 +0200
Mysql-Check for database capacities
---
agents/plugins/mk_mysql | 43 ++++++++++++++++++++
checks/mysql_capacity | 61 +++++++++++++++++++++++++++++
pnp-templates/check_mk-mysql_capacity.php | 1 +
web/plugins/perfometer/check_mk.py | 1 +
4 files changed, 106 insertions(+), 0 deletions(-)
diff --git a/agents/plugins/mk_mysql b/agents/plugins/mk_mysql
new file mode 100755
index 0000000..8d2ed9d
--- /dev/null
+++ b/agents/plugins/mk_mysql
@@ -0,0 +1,43 @@
+#!/bin/sh
+# +-----------------------------------------------------------------+
+# | |
+# | ( ___ \ | \ /\|\ /||\ /|( ( /| |
+# | | ( ) ) | \ / /| ) ( || ) ( || \ ( | |
+# | | (__/ / | (_/ / | | | || (___) || \ | | |
+# | | __ ( | _ ( | | | || ___ || (\ \) | |
+# | | ( \ \ | ( \ \ | | | || ( ) || | \ | |
+# | | )___) )_ | / \ \| (___) || ) ( || ) \ | |
+# | |/ \___/(_) |_/ \/(_______)|/ \||/ )_) |
+# | |
+# | Copyright Bastian Kuhn 2011 mail(a)bastian-kuhn.de |
+# +-----------------------------------------------------------------+
+#
+# This file is a check Script for check_mk
+# Information about me can be found at
http://bastian-kuhn.de
+# Information about check_mk at
http://mathias-kettner.de/check_mk.
+#
+# This 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.
+#
+# Hint: You may want to set configure:
+# e.g. --socket='/var/run/mysqld/mysqld.sock'
+# e.g. --user=root
+# e.g. --password='XYZ'
+
+if which mysqladmin > /dev/null
+then
+ # Check if mysqld is running and root password setup
+ echo "<<<mysql_ping>>>"
+ mysqladmin --defaults-extra-file=$MK_CONFDIR/mysql.cfg ping 2>&1
+
+ mysql --defaults-extra-file=$MK_CONFDIR/mysql.cfg -sN \
+ -e "select '<<<mysql_status>>>' ; 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;"
+fi
diff --git a/checks/mysql_capacity b/checks/mysql_capacity
new file mode 100644
index 0000000..66b7081
--- /dev/null
+++ b/checks/mysql_capacity
@@ -0,0 +1,61 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2012 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.
+
+# <<<mysql_capacity>>>
+# greendb 163840 1428160512
+# hirn 16384 238026752
+# information_schema 9216 0
+# mysql 650067 0
+# performance_schema 0 0
+# wa-confluence 15499264 13805551616
+
+def inventory_mysql_capacity(info):
+ inventory = []
+ for dbname, used, avail in info:
+ if dbname not in [ "information_schema", "mysql",
"performance_schema" ]:
+ inventory.append((dbname, {}))
+ return inventory
+
+def check_mysql_capacity(item, params, info):
+ for dbname, used, avail in info:
+ if item == dbname:
+ used_mb = int(used) / 1048576.0
+ avail_mb = int(avail) / 1048576.0
+ size_mb = used_mb + avail_mb
+ return df_check_filesystem(g_hostname, item, size_mb, avail_mb, params)
+
+ return (3, "UNKNOWN - Database not found")
+
+
+check_info['mysql_capacity'] = {
+ "check_function" : check_mysql_capacity,
+ "inventory_function" : inventory_mysql_capacity,
+ "service_description" : "MYSQL Capacity %s",
+ "has_perfdata" : True,
+ "group" : "filesystem",
+ "default_levels_variable" : "filesystem_default_levels",
+ "includes" : [ "df.include" ],
+}
diff --git a/pnp-templates/check_mk-mysql_capacity.php
b/pnp-templates/check_mk-mysql_capacity.php
new file mode 120000
index 0000000..28b85a4
--- /dev/null
+++ b/pnp-templates/check_mk-mysql_capacity.php
@@ -0,0 +1 @@
+check_mk-df.php
\ No newline at end of file
diff --git a/web/plugins/perfometer/check_mk.py b/web/plugins/perfometer/check_mk.py
index 9ae4df9..25d38ec 100644
--- a/web/plugins/perfometer/check_mk.py
+++ b/web/plugins/perfometer/check_mk.py
@@ -68,6 +68,7 @@ perfometers["check_mk-df_netapp"] = perfometer_check_mk_df
perfometers["check_mk-df_netapp32"] = perfometer_check_mk_df
perfometers["check_mk-hr_fs"] = perfometer_check_mk_df
perfometers["check_mk-oracle_asm_diskgroup"] = perfometer_check_mk_df
+perfometers["check_mk-mysql_capacity"] = perfometer_check_mk_df
def perfometer_check_mk_kernel_util(row, check_command, perf_data):