2 # +------------------------------------------------------------------+
3 # | ____ _ _ __ __ _ __ |
4 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
5 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
6 # | | |___| | | | __/ (__| < | | | | . \ |
7 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
10 # +------------------------------------------------------------------+
12 # This file is part of Check_MK.
13 # The official homepage is at http://mathias-kettner.de/check_mk.
15 # check_mk is free software; you can redistribute it and/or modify it
16 # under the terms of the GNU General Public License as published by
17 # the Free Software Foundation in version 2. check_mk is distributed
18 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
19 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
20 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
21 # tails. You should have received a copy of the GNU General Public
22 # License along with GNU Make; see the file COPYING. If not, write
23 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
24 # Boston, MA 02110-1301 USA.
26 # gets optional socket as argument
28 INSTANCE
=$
(echo $1|
awk -v FS
="=" '{print $2}')
29 COUNT
=$
(ps
-fww -C mysqld |
grep socket |
wc -l)
32 INSTANCE_NAME
=$
(ps
-efww|
grep socket|
grep "${INSTANCE}"|
grep "[u]ser" |
sed -ne 's/.*socket=\([^.]*\).*/\1/p')
33 INSTANCE_NAME
="[[${INSTANCE_NAME##*/}]]"
35 INSTANCE_NAME
="[[$(ps -efww|grep socket|grep "${INSTANCE}"|grep "[u
]ser
" | sed -ne 's/.*user=\([^ ]*\).*/\1/p')]]"
40 # Check if mysqld is running and root password setup
41 echo "<<<mysql_ping>>>"
43 mysqladmin
--defaults-extra-file=$MK_CONFDIR/mysql.cfg
$1 ping 2>&1
49 mysql
--defaults-extra-file=$MK_CONFDIR/mysql.cfg
$1 -sN \
50 -e "show global status ; show global variables ;"
52 echo "<<<mysql_capacity>>>"
54 mysql
--defaults-extra-file=$MK_CONFDIR/mysql.cfg
$1 -sN \
55 -e "SELECT table_schema, sum(data_length + index_length), sum(data_free)
56 FROM information_schema.TABLES GROUP BY table_schema"
58 echo "<<<mysql_slave>>>"
60 mysql
--defaults-extra-file=$MK_CONFDIR/mysql.cfg
$1 -s \
61 -e "show slave status\G"
67 if which mysqladmin
>/dev
/null
69 mysql_sockets
=$
(fgrep socket
$MK_CONFDIR/mysql.cfg|
sed -ne 's/.*socket=\([^ ]*\).*/\1/p')
70 if [ -z "$mysql_sockets" ] ; then
71 mysql_sockets
=$
(ps
-fww -C mysqld |
grep "[s]ocket" |
sed -ne 's/.*socket=\([^ ]*\).*/\1/p')
73 if [ -z "$mysql_sockets" ] ; then
76 for socket
in $mysql_sockets ; do
77 do_query
"--socket="$socket
80 #echo "<<<mysql_version>>>"
83 echo "<<<mysql_port>>>"
84 ps
-fww -C mysqld |
while read LINE
; do echo $LINE|
grep "[u]ser" |
sed -ne 's/.*user=\([^ ]*\).*/\1/p'; echo $LINE|
grep mysqld |
grep "[p]ort"|
sed -ne 's/.*port=\([^ ]*\).*/\1/p' ; done|
xargs -n2
86 #echo "<<<mysql_instances>>>"
87 #mysql --defaults-extra-file=$MK_CONFDIR/mysql.cfg $1 -s \