Initial commit.
This commit is contained in:
parent
71f003f003
commit
c008056a19
12
README.md
12
README.md
@ -1 +1,13 @@
|
|||||||
# check_mk-mysql_open_files
|
# 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".
|
||||||
|
16
agents/plugins/mysql_open_files
Normal file
16
agents/plugins/mysql_open_files
Normal file
@ -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 '<<<mysql_open_files>>>'
|
||||||
|
echo 'open_files ' $mysqlOpenFilesLimit ' ' $mysqlOpenFiles
|
21
checkman/mysql_open_files
Normal file
21
checkman/mysql_open_files
Normal file
@ -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.
|
47
checks/mysql_open_files
Normal file
47
checks/mysql_open_files
Normal file
@ -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
|
||||||
|
#
|
||||||
|
#<<<mysql_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",
|
||||||
|
}
|
17
info
Normal file
17
info
Normal file
@ -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'}
|
BIN
mysql_open_files-1.0.mkp
Normal file
BIN
mysql_open_files-1.0.mkp
Normal file
Binary file not shown.
32
web/plugins/wato/mysql_open_files.py
Normal file
32
web/plugins/wato/mysql_open_files.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# SpearHead Syste george.mocanu@sphs.ro 2015
|
||||||
|
|
||||||
|
register_check_parameters(
|
||||||
|
subgroup_applications,
|
||||||
|
"mysql_open_files",
|
||||||
|
_("Mysql Open Files Usage Status"),
|
||||||
|
Dictionary(
|
||||||
|
elements = [
|
||||||
|
("levels", # Name of your parameters
|
||||||
|
Tuple(
|
||||||
|
title = "Levels for Mysql Open Files Usage check", # Specify a title for this parameters
|
||||||
|
elements = [
|
||||||
|
Integer(
|
||||||
|
title = _("Warning if above"),
|
||||||
|
unit = _("Percent"),
|
||||||
|
default_value = 80
|
||||||
|
),
|
||||||
|
Integer(
|
||||||
|
title = _("Critical if above"),
|
||||||
|
unit = _("Percent"),
|
||||||
|
default_value = 90
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
],
|
||||||
|
optional_keys = None, # Always show this subgroup
|
||||||
|
),
|
||||||
|
TextAscii( title = "Service name"),
|
||||||
|
"dict"
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user