Module: check_mk
Branch: master
Commit: d8a8229490da2a6fcde827fac9ba113bebd087eb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d8a8229490da2a…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Thu Nov 19 17:16:32 2015 +0100
#1304 mk_mysql: Agent plugin can now detect multiple instances running unter the same
user
In case that the agent plugin detects more then one running instance, the Name of the
socket will be used as item.
---
.werks/1304 | 10 ++++++++++
ChangeLog | 1 +
agents/plugins/mk_mysql | 9 ++++++++-
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/.werks/1304 b/.werks/1304
new file mode 100644
index 0000000..6eba6b0
--- /dev/null
+++ b/.werks/1304
@@ -0,0 +1,10 @@
+Title: mk_mysql: Agent plugin can now detect multiple instances running unter the same
user
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i4
+Date: 1447949700
+Class: feature
+
+In case that the agent plugin detects more then one running instance, the Name of the
socket will be used as item.
+
diff --git a/ChangeLog b/ChangeLog
index f1e39c5..bd617b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -37,6 +37,7 @@
* 2711 janitza_umg: added support for umg508...
* 2792 check_mk_agent.aix: now able to use wildcards in the fileinfo.cfg
* 1303 multipath, solaris_multipath: Level for needed paths can now be specified in
percent
+ * 1304 mk_mysql: Agent plugin can now detect multiple instances running unter the
same user...
* 2660 FIX: fixed windows agent using the wrong working directory...
* 2664 FIX: ps: Speedup in situation with many matching processes...
* 2661 FIX: windows agent: fixed incomplete process list...
diff --git a/agents/plugins/mk_mysql b/agents/plugins/mk_mysql
index ebbba5c..8c6ee7d 100755
--- a/agents/plugins/mk_mysql
+++ b/agents/plugins/mk_mysql
@@ -26,7 +26,14 @@
# gets optional socket as argument
function do_query() {
INSTANCE=$(echo $1|awk -v FS="=" '{print $2}')
- INSTANCE_NAME="[[$(ps -ef|grep socket|grep "${INSTANCE}"|grep
"[u]ser" | sed -ne 's/.*user=\([^ ]*\).*/\1/p')]]"
+ COUNT=$(ps -ef | grep [/]usr/sbin/mysqld | grep socket | wc -l)
+ if [ $COUNT -gt 1 ]
+ then
+ INSTANCE_NAME=$(ps -ef|grep socket|grep "${INSTANCE}"|grep
"[u]ser" | sed -ne 's/.*socket=\([^.]*\).*/\1/p')
+ INSTANCE_NAME="[[${INSTANCE_NAME##*/}]]"
+ else
+ INSTANCE_NAME="[[$(ps -ef|grep socket|grep "${INSTANCE}"|grep
"[u]ser" | sed -ne 's/.*user=\([^ ]*\).*/\1/p')]]"
+ fi