From c008056a1958dc1cf5602587115da1dfdbf067ad Mon Sep 17 00:00:00 2001 From: George Mocanu Date: Sun, 8 Feb 2015 07:27:11 +0200 Subject: [PATCH] Initial commit. --- README.md | 12 +++++++ agents/plugins/mysql_open_files | 16 +++++++++ checkman/mysql_open_files | 21 ++++++++++++ checks/mysql_open_files | 47 +++++++++++++++++++++++++++ info | 17 ++++++++++ mysql_open_files-1.0.mkp | Bin 0 -> 2171 bytes web/plugins/wato/mysql_open_files.py | 32 ++++++++++++++++++ 7 files changed, 145 insertions(+) create mode 100644 agents/plugins/mysql_open_files create mode 100644 checkman/mysql_open_files create mode 100644 checks/mysql_open_files create mode 100644 info create mode 100644 mysql_open_files-1.0.mkp create mode 100644 web/plugins/wato/mysql_open_files.py diff --git a/README.md b/README.md index 9f92c27..95ad4c6 100644 --- a/README.md +++ b/README.md @@ -1 +1,13 @@ # check_mk-mysql_open_files + +This check will monitor mysql open_files value raported to +setted open_files_limit value. The plugin must be copied +into /usr/lib/check_mk_agent/plugins folder and the +executable bit must be set for this file. + +The check will return current open_files_limit and open_files +values. The check gets critical at 90 percent of +open_files_limit and warning at 80. + +Both limits are definable in Wato under "Parameters for +Inventorized Checks", "Applications, Processes & Services". diff --git a/agents/plugins/mysql_open_files b/agents/plugins/mysql_open_files new file mode 100644 index 0000000..36aa239 --- /dev/null +++ b/agents/plugins/mysql_open_files @@ -0,0 +1,16 @@ +#!/bin/bash +# SpearHead Systems george.mocanu@sphs.ro 2015 +# Check_MK plugin for monitoring mysql open_files + +# Get mysqld pid number +mysqlPid=`pidof mysqld` + +# Count files currently opened by mysql +mysqlOpenFiles=`ls -las /proc/$mysqlPid/fd/ | wc -l` + +# Get current open_files_limit value +mysqlOpenFilesLimit=`cat /proc/$mysqlPid/limits | grep 'Max\ open\ files' | awk '{print $4}'` + +# Check output +echo '<<>>' +echo 'open_files ' $mysqlOpenFilesLimit ' ' $mysqlOpenFiles diff --git a/checkman/mysql_open_files b/checkman/mysql_open_files new file mode 100644 index 0000000..a82c650 --- /dev/null +++ b/checkman/mysql_open_files @@ -0,0 +1,21 @@ +title: Check for monitor mysql open_files +agents: linux +catalog: os/linux +license: GPL +distribution: +description: + This check will monitor mysql open_files raported to + setted open_files_limit value. The plugin must be copied + into /usr/lib/check_mk_agent/plugins folder and the + executable bit mus be set for this file. + Will return current open_files_limit and open_files + values. The check gets critical at 90 percent of + open_files_limit and warning at 80. + Both limits are definable in Wato under "Parameters for + Inventorized Checks", "Applications, Processes & Services". + +inventory: + One service will be created for each host running the plugin. + +perfdata: + Percent usage of open_files_limit value. diff --git a/checks/mysql_open_files b/checks/mysql_open_files new file mode 100644 index 0000000..073ad44 --- /dev/null +++ b/checks/mysql_open_files @@ -0,0 +1,47 @@ +#!/usr/bin/python +# SpearHead Systems george.mocanu@sphs.ro 2015 + +# EXAMPLE DATA FROM: +# fomat: "open_files" current_setted_value_of_open_files_limit current_value_of_open_files +# +#<<>> +#open_files 3000 2305 + +factory_settings["mysql_open_files_default_values"] = { + "levels": (80, 90), +} + +def inventory_mysql_open_files(info): + inventory = [] + for line in info: + checkName = line[0] + inventory.append( (checkName, {} ) ) + return inventory + + +def check_mysql_open_files(item, params, info): + if type(params) != dict: + params = { "levels": params } + warn, crit = params["levels"] + for line in info: + if line[0] == item: + open_files_limit = int(line[1]) + open_files = int(line[2]) + openPerc = int(((open_files*100)/open_files_limit)) + perfdata = [ ( "open_files", openPerc, warn, crit ) ] + if openPerc > crit: + return (2, "Open files use level: %d percents. %d files opened out of maximum %d cconfigured." %(openPerc, open_files, open_files_limit), perfdata) + elif openPerc > warn: + return (1, "Open files use level: %d percents. %d files opened out of maximum %d cconfigured." %(openPerc, open_files, open_files_limit), perfdata) + else: + return (0, "Open files use level: %d percents. %d files opened out of maximum %d cconfigured." %(openPerc, open_files, open_files_limit), perfdata) + return(3, "Plugin not running on host") + +check_info["mysql_open_files"] = { + "check_function" :check_mysql_open_files, + "inventory_function" :inventory_mysql_open_files, + "service_description" :"%s", + "default_levels_variable" :"mysql_open_files_default_values", + "has_perfdata" :True, + "group" :"mysql_open_files", +} diff --git a/info b/info new file mode 100644 index 0000000..263ea79 --- /dev/null +++ b/info @@ -0,0 +1,17 @@ +{'author': 'george.mocanu@sphs.ro', + 'description': 'Monitor mysql open_files', + 'download_url': 'https://github.com/spearheadsys/check_mk-mysql_open_files', + 'files': {'agents': ['plugins/mysql_open_files'], + 'checkman': ['mysql_open_files'], + 'checks': ['mysql_open_files'], + 'doc': [], + 'inventory': [], + 'notifications': [], + 'pnp-templates': [], + 'web': ['plugins/wato/mysql_open_files.py']}, + 'name': 'mysql_open_files', + 'num_files': 4, + 'title': 'Check for mysql open_files', + 'version': '1.0', + 'version.min_required': '1.2.6b5', + 'version.packaged': '1.2.6b5'} \ No newline at end of file diff --git a/mysql_open_files-1.0.mkp b/mysql_open_files-1.0.mkp new file mode 100644 index 0000000000000000000000000000000000000000..857ece57c13f463a7019ee550d6f0528fd5f8e07 GIT binary patch literal 2171 zcmZwEc_7n`1IKadr$?p7Q%FpCawd};6LKYY*pJ05Y(>U$lQ|NVD7iDo_BhHl*9hg- zatw287N+rYGq;Hx+xO}3-}8L_eEs?UNXGH=cWi&VdkpXn4fOXy`TDu}pwJjEw?HM8 zYuB%Nd;0OLWqYQIH;BY6dLFC~`7r8BEXVt^onWNaQX5V1zFd~tI zt#eyttRcyPMx^}X$qM~4!zsds zFCdN=pM8yh6=qQt+~40TMqi(A{o#k@4AC{3VUAoMgQ8ra9FN1@AlZZ(b6oL)eXJtv zp%ukW*ELpg$EK5&Z+ZKyL(|O?n*i6aD|0TUNU6u_iO0~=#n?Hb`N4nL2ywOk;Q7IQ zk9M{e&83%P(pc=oWE9JKb$YJ`$EZ`$?QRZGuNR4rSNn3u{}>9H>Ynr~c_TLD^RdS~ z0f7^c1t4)Ug6t#f{2SWL59SCz?-Tygz%GBd%{F4{y668g?g2ODNu(cS+QyG6uH=g* z#SV86fYjr1Xc1h7WB;pl%woX>z3_?4(6Oq{{Cp{qjvsPq~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