Browse Source

Initial commit.

George Mocanu 3 years ago
parent
commit
c008056a19

+ 12
- 0
README.md View File

@@ -1 +1,13 @@
1 1
 # check_mk-mysql_open_files
2
+
3
+This check will monitor mysql open_files value raported to
4
+setted open_files_limit value. The plugin must be copied
5
+into /usr/lib/check_mk_agent/plugins folder and the
6
+executable bit must be set for this file.
7
+
8
+The check will return current open_files_limit and open_files
9
+values. The check gets critical at 90 percent of
10
+open_files_limit and warning at 80.
11
+ 
12
+Both limits are definable in Wato under "Parameters for
13
+Inventorized Checks", "Applications, Processes & Services".

+ 16
- 0
agents/plugins/mysql_open_files View File

@@ -0,0 +1,16 @@
1
+#!/bin/bash
2
+# SpearHead Systems george.mocanu@sphs.ro 2015
3
+# Check_MK plugin for monitoring mysql open_files
4
+
5
+# Get mysqld pid number
6
+mysqlPid=`pidof mysqld`
7
+
8
+# Count files currently opened by mysql 
9
+mysqlOpenFiles=`ls -las /proc/$mysqlPid/fd/ | wc -l`
10
+
11
+# Get current open_files_limit value
12
+mysqlOpenFilesLimit=`cat /proc/$mysqlPid/limits | grep 'Max\ open\ files' | awk '{print $4}'`
13
+
14
+# Check output
15
+echo '<<<mysql_open_files>>>'
16
+echo 'open_files ' $mysqlOpenFilesLimit ' ' $mysqlOpenFiles

+ 21
- 0
checkman/mysql_open_files View File

@@ -0,0 +1,21 @@
1
+title: Check for monitor mysql open_files
2
+agents: linux
3
+catalog: os/linux
4
+license: GPL
5
+distribution:
6
+description:
7
+ This check will monitor mysql open_files raported to
8
+ setted open_files_limit value. The plugin must be copied
9
+ into /usr/lib/check_mk_agent/plugins folder and the 
10
+ executable bit mus be set for this file.
11
+ Will return current open_files_limit and open_files
12
+ values. The check gets critical at 90 percent of 
13
+ open_files_limit and warning at 80. 
14
+ Both limits are definable in Wato under "Parameters for 
15
+ Inventorized Checks", "Applications, Processes & Services".
16
+
17
+inventory:
18
+ One service will be created for each host running the plugin.
19
+
20
+perfdata:
21
+ Percent usage of open_files_limit value.

+ 47
- 0
checks/mysql_open_files View File

@@ -0,0 +1,47 @@
1
+#!/usr/bin/python
2
+# SpearHead Systems george.mocanu@sphs.ro 2015
3
+
4
+# EXAMPLE DATA FROM:
5
+# fomat: "open_files" current_setted_value_of_open_files_limit  current_value_of_open_files
6
+#
7
+#<<<mysql_open_files>>>
8
+#open_files 3000 2305
9
+
10
+factory_settings["mysql_open_files_default_values"] = {
11
+        "levels": (80, 90),
12
+}
13
+
14
+def inventory_mysql_open_files(info):
15
+    inventory = []
16
+    for line in info:
17
+        checkName = line[0]
18
+        inventory.append( (checkName, {} ) )
19
+    return inventory
20
+
21
+
22
+def check_mysql_open_files(item, params, info):
23
+    if type(params) != dict:
24
+        params = { "levels": params }
25
+    warn, crit = params["levels"]
26
+    for line in info:
27
+        if line[0] == item:
28
+            open_files_limit = int(line[1])
29
+            open_files = int(line[2])
30
+            openPerc = int(((open_files*100)/open_files_limit))
31
+            perfdata = [ ( "open_files", openPerc, warn, crit ) ]
32
+            if openPerc > crit:
33
+                return (2, "Open files use level: %d percents. %d files opened out of maximum %d cconfigured." %(openPerc, open_files, open_files_limit), perfdata)
34
+            elif openPerc > warn:
35
+                return (1, "Open files use level: %d percents. %d files opened out of maximum %d cconfigured." %(openPerc, open_files, open_files_limit), perfdata)
36
+            else:
37
+                return (0, "Open files use level: %d percents. %d files opened out of maximum %d cconfigured." %(openPerc, open_files, open_files_limit), perfdata)
38
+    return(3, "Plugin not running on host")
39
+
40
+check_info["mysql_open_files"] = {
41
+    "check_function"            :check_mysql_open_files,
42
+    "inventory_function"        :inventory_mysql_open_files,
43
+    "service_description"       :"%s",
44
+    "default_levels_variable"   :"mysql_open_files_default_values",
45
+    "has_perfdata"              :True,
46
+    "group"                     :"mysql_open_files",
47
+}

+ 17
- 0
info View File

@@ -0,0 +1,17 @@
1
+{'author': 'george.mocanu@sphs.ro',
2
+ 'description': 'Monitor mysql open_files',
3
+ 'download_url': 'https://github.com/spearheadsys/check_mk-mysql_open_files',
4
+ 'files': {'agents': ['plugins/mysql_open_files'],
5
+           'checkman': ['mysql_open_files'],
6
+           'checks': ['mysql_open_files'],
7
+           'doc': [],
8
+           'inventory': [],
9
+           'notifications': [],
10
+           'pnp-templates': [],
11
+           'web': ['plugins/wato/mysql_open_files.py']},
12
+ 'name': 'mysql_open_files',
13
+ 'num_files': 4,
14
+ 'title': 'Check for mysql open_files',
15
+ 'version': '1.0',
16
+ 'version.min_required': '1.2.6b5',
17
+ 'version.packaged': '1.2.6b5'}

BIN
mysql_open_files-1.0.mkp View File


+ 32
- 0
web/plugins/wato/mysql_open_files.py View File

@@ -0,0 +1,32 @@
1
+#!/usr/bin/python
2
+# SpearHead Syste  george.mocanu@sphs.ro  2015
3
+
4
+register_check_parameters(
5
+    subgroup_applications,
6
+    "mysql_open_files",
7
+    _("Mysql Open Files Usage Status"),
8
+    Dictionary(
9
+        elements = [
10
+            ("levels", # Name of your parameters
11
+                Tuple(
12
+                    title = "Levels for Mysql Open Files Usage check", # Specify a title for this parameters
13
+                    elements = [
14
+                        Integer(
15
+                            title = _("Warning if above"),
16
+                            unit = _("Percent"),
17
+                            default_value = 80
18
+                        ),
19
+                        Integer(
20
+                            title = _("Critical if above"),
21
+                            unit = _("Percent"),
22
+                            default_value = 90
23
+                        ),
24
+                    ]
25
+                )
26
+            ),
27
+	],
28
+        optional_keys = None, # Always show this subgroup
29
+    ),
30
+    TextAscii( title = "Service name"),
31
+    "dict"
32
+)    

Loading…
Cancel
Save