From 1746898cefcb17f58b5cf27b4dad3d28236f1152 Mon Sep 17 00:00:00 2001 From: Lennart Weller Date: Mon, 5 Sep 2016 10:27:21 +0200 Subject: Imported Upstream version 1.3.0+dfsg --- charts.d/mysql.chart.sh | 375 +++++++++++++++++------------------------------- 1 file changed, 128 insertions(+), 247 deletions(-) (limited to 'charts.d/mysql.chart.sh') diff --git a/charts.d/mysql.chart.sh b/charts.d/mysql.chart.sh index 56dce42d7..120fec66e 100755 --- a/charts.d/mysql.chart.sh +++ b/charts.d/mysql.chart.sh @@ -1,4 +1,4 @@ -#!/bin/bash +# no need for shebang - this file is loaded from charts.d.plugin # http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.html # @@ -7,139 +7,31 @@ # This statement does not require any privilege. # It requires only the ability to connect to the server. -mysql_update_every=5 +mysql_update_every=2 mysql_priority=60000 -declare -A mysql_cmds=() mysql_opts=() mysql_ids=() +declare -A mysql_cmds=() mysql_opts=() mysql_ids=() mysql_data=() -mysql_exec() { - local ret - - "${@}" -s -e "show global status;" - ret=$? +mysql_get() { + local arr + local oIFS="${IFS}" + mysql_data=() + IFS=$'\t'$'\n' + #arr=($("${@}" -e "SHOW GLOBAL STATUS WHERE value REGEXP '^[0-9]';" | egrep "^(Bytes|Slow_|Que|Handl|Table|Selec|Sort_|Creat|Conne|Abort|Binlo|Threa|Innod|Qcach|Key_|Open)" )) + #arr=($("${@}" -N -e "SHOW GLOBAL STATUS;" | egrep "^(Bytes|Slow_|Que|Handl|Table|Selec|Sort_|Creat|Conne|Abort|Binlo|Threa|Innod|Qcach|Key_|Open)[^ ]+\s[0-9]" )) + arr=($("${@}" -N -e "SHOW GLOBAL STATUS;" | egrep "^(Bytes|Slow_|Que|Handl|Table|Selec|Sort_|Creat|Conne|Abort|Binlo|Threa|Innod|Qcach|Key_|Open)[^[:space:]]+[[:space:]]+[0-9]+" )) + IFS="${oIFS}" + + [ "${#arr[@]}" -lt 3 ] && return 1 + local end=${#arr[@]} + for ((i=2;i