summaryrefslogtreecommitdiffstats
path: root/collectors/charts.d.plugin/mysql
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2019-02-08 07:30:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2019-02-08 07:30:37 +0000
commit8a7b72f7cd1ccd547a03eb4243294e741d661d3f (patch)
tree7bc7be4a8e9e298daa1349348400aa2a653866f2 /collectors/charts.d.plugin/mysql
parentNew upstream version 1.11.1+dfsg (diff)
downloadnetdata-8a7b72f7cd1ccd547a03eb4243294e741d661d3f.tar.xz
netdata-8a7b72f7cd1ccd547a03eb4243294e741d661d3f.zip
Adding upstream version 1.12.0.upstream/1.12.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/charts.d.plugin/mysql')
-rw-r--r--collectors/charts.d.plugin/mysql/README.md8
-rw-r--r--collectors/charts.d.plugin/mysql/mysql.chart.sh71
2 files changed, 32 insertions, 47 deletions
diff --git a/collectors/charts.d.plugin/mysql/README.md b/collectors/charts.d.plugin/mysql/README.md
index 6765b53ab..e52449a4f 100644
--- a/collectors/charts.d.plugin/mysql/README.md
+++ b/collectors/charts.d.plugin/mysql/README.md
@@ -1,8 +1,8 @@
-> THIS MODULE IS OBSOLETE.
-> USE THE PYTHON ONE - IT SUPPORTS MULTIPLE JOBS AND IT IS MORE EFFICIENT
-
# mysql
+> THIS MODULE IS OBSOLETE.
+> USE [THE PYTHON ONE](../../python.d.plugin/mysql) - IT SUPPORTS MULTIPLE JOBS AND IT IS MORE EFFICIENT
+
The plugin will monitor one or more mysql servers
It will produce the following charts:
@@ -79,3 +79,5 @@ If no configuration is given, the plugin will attempt to connect to mysql server
---
+
+[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fcollectors%2Fcharts.d.plugin%2Fmysql%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)]()
diff --git a/collectors/charts.d.plugin/mysql/mysql.chart.sh b/collectors/charts.d.plugin/mysql/mysql.chart.sh
index 37e8e2a7c..e1207dc9a 100644
--- a/collectors/charts.d.plugin/mysql/mysql.chart.sh
+++ b/collectors/charts.d.plugin/mysql/mysql.chart.sh
@@ -27,19 +27,19 @@ mysql_get() {
#arr=($(run "${@}" -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=($(run "${@}" -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]" ))
# shellcheck disable=SC2207
- arr=($(run "${@}" -N -e "SHOW GLOBAL STATUS;" | grep -E "^(Bytes|Slow_|Que|Handl|Table|Selec|Sort_|Creat|Conne|Abort|Binlo|Threa|Innod|Qcach|Key_|Open)[^[:space:]]+[[:space:]]+[0-9]+" ))
+ arr=($(run "${@}" -N -e "SHOW GLOBAL STATUS;" | grep -E "^(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<end;i+=2)); do
- mysql_data["${arr[$i]}"]=${arr[$i+1]}
+ for ((i = 2; i < end; i += 2)); do
+ mysql_data["${arr[$i]}"]=${arr[i + 1]}
done
[ -z "${mysql_data[Connections]}" ] && return 1
mysql_data[Thread_cache_misses]=0
- [ $(( mysql_data[Connections] + 1 - 1 )) -gt 0 ] && mysql_data[Thread_cache_misses]=$(( mysql_data[Threads_created] * 10000 / mysql_data[Connections] ))
+ [ $((mysql_data[Connections] + 1 - 1)) -gt 0 ] && mysql_data[Thread_cache_misses]=$((mysql_data[Threads_created] * 10000 / mysql_data[Connections]))
return 0
}
@@ -51,23 +51,20 @@ mysql_check() {
local x m mysql_cmd tryroot=0 unconfigured=0
- if [ "${1}" = "tryroot" ]
- then
+ if [ "${1}" = "tryroot" ]; then
tryroot=1
shift
fi
- # shellcheck disable=SC2230
+ # shellcheck disable=SC2230
[ -z "${mysql_cmd}" ] && mysql_cmd="$(which mysql 2>/dev/null || command -v mysql 2>/dev/null)"
- if [ ${#mysql_opts[@]} -eq 0 ]
- then
+ if [ ${#mysql_opts[@]} -eq 0 ]; then
unconfigured=1
mysql_cmds[local]="$mysql_cmd"
- if [ $tryroot -eq 1 ]
- then
+ if [ $tryroot -eq 1 ]; then
# the user has not configured us for mysql access
# if the root user is passwordless in mysql, we can
# attempt to connect to mysql as root
@@ -78,19 +75,16 @@ mysql_check() {
fi
# check once if the url works
- for m in "${!mysql_opts[@]}"
- do
+ for m in "${!mysql_opts[@]}"; do
[ -z "${mysql_cmds[$m]}" ] && mysql_cmds[$m]="$mysql_cmd"
- if [ -z "${mysql_cmds[$m]}" ]
- then
+ if [ -z "${mysql_cmds[$m]}" ]; then
# shellcheck disable=SC2154
error "cannot get mysql command for '${m}'. Please set mysql_cmds[$m]='/path/to/mysql', in $confd/mysql.conf"
fi
mysql_get "${mysql_cmds[$m]}" ${mysql_opts[$m]}
# shellcheck disable=SC2181
- if [ ! $? -eq 0 ]
- then
+ if [ ! $? -eq 0 ]; then
error "cannot get global status for '$m'. Please set mysql_opts[$m]='options' to whatever needed to get connected to the mysql server, in $confd/mysql.conf"
unset "mysql_cmds[$m]"
unset "mysql_opts[$m]"
@@ -98,13 +92,11 @@ mysql_check() {
continue
fi
- mysql_ids[$m]="$( fixid "$m" )"
+ mysql_ids[$m]="$(fixid "$m")"
done
- if [ ${#mysql_opts[@]} -eq 0 ]
- then
- if [ ${unconfigured} -eq 1 ] && [ ${tryroot} -eq 0 ]
- then
+ if [ ${#mysql_opts[@]} -eq 0 ]; then
+ if [ ${unconfigured} -eq 1 ] && [ ${tryroot} -eq 0 ]; then
mysql_check tryroot "${@}"
return $?
else
@@ -120,8 +112,7 @@ mysql_create() {
local x
# create the charts
- for x in "${mysql_ids[@]}"
- do
+ for x in "${mysql_ids[@]}"; do
cat <<EOF
CHART mysql_$x.net '' "mysql Bandwidth" "kilobits/s" bandwidth mysql.net area $((mysql_priority + 1)) $mysql_update_every
DIMENSION Bytes_received in incremental 8 1024
@@ -230,7 +221,7 @@ DIMENSION Innodb_buffer_pool_pages_flushed flushed incremental -1 1
DIMENSION Innodb_buffer_pool_pages_misc misc absolute -1 1
DIMENSION Innodb_buffer_pool_pages_total total absolute 1 1
-CHART mysql_$x.innodb_buffer_pool_bytes '' "mysql InnoDB Buffer Pool Bytes" "MB" innodb mysql.innodb_buffer_pool_bytes area $((mysql_priority + 21)) $mysql_update_every
+CHART mysql_$x.innodb_buffer_pool_bytes '' "mysql InnoDB Buffer Pool Bytes" "MiB" innodb mysql.innodb_buffer_pool_bytes area $((mysql_priority + 21)) $mysql_update_every
DIMENSION Innodb_buffer_pool_bytes_data data absolute 1 $((1024 * 1024))
DIMENSION Innodb_buffer_pool_bytes_dirty dirty absolute -1 $((1024 * 1024))
@@ -256,7 +247,7 @@ DIMENSION Qcache_not_cached 'not cached' incremental -1 1
CHART mysql_$x.qcache '' "mysql QCache Queries in Cache" "queries" qcache mysql.qcache line $((mysql_priority + 26)) $mysql_update_every
DIMENSION Qcache_queries_in_cache queries absolute 1 1
-CHART mysql_$x.qcache_freemem '' "mysql QCache Free Memory" "MB" qcache mysql.qcache_freemem area $((mysql_priority + 27)) $mysql_update_every
+CHART mysql_$x.qcache_freemem '' "mysql QCache Free Memory" "MiB" qcache mysql.qcache_freemem area $((mysql_priority + 27)) $mysql_update_every
DIMENSION Qcache_free_memory free absolute 1 $((1024 * 1024))
CHART mysql_$x.qcache_memblocks '' "mysql QCache Memory Blocks" "blocks" qcache mysql.qcache_memblocks line $((mysql_priority + 28)) $mysql_update_every
@@ -283,18 +274,16 @@ CHART mysql_$x.files_rate '' "mysql Opened Files Rate" "files/s" files mysql.fil
DIMENSION Opened_files files incremental 1 1
EOF
- if [ ! -z "${mysql_data[Binlog_stmt_cache_disk_use]}" ]
- then
- cat <<EOF
+ if [ ! -z "${mysql_data[Binlog_stmt_cache_disk_use]}" ]; then
+ cat <<EOF
CHART mysql_$x.binlog_stmt_cache '' "mysql Binlog Statement Cache" "statements/s" binlog mysql.binlog_stmt_cache line $((mysql_priority + 50)) $mysql_update_every
DIMENSION Binlog_stmt_cache_disk_use disk incremental 1 1
DIMENSION Binlog_stmt_cache_use all incremental 1 1
EOF
- fi
+ fi
- if [ ! -z "${mysql_data[Connection_errors_accept]}" ]
- then
- cat <<EOF
+ if [ ! -z "${mysql_data[Connection_errors_accept]}" ]; then
+ cat <<EOF
CHART mysql_$x.connection_errors '' "mysql Connection Errors" "connections/s" connections mysql.connection_errors line $((mysql_priority + 51)) $mysql_update_every
DIMENSION Connection_errors_accept accept incremental 1 1
DIMENSION Connection_errors_internal internal incremental 1 1
@@ -303,13 +292,12 @@ DIMENSION Connection_errors_peer_addr peer_addr incremental 1 1
DIMENSION Connection_errors_select select incremental 1 1
DIMENSION Connection_errors_tcpwrap tcpwrap incremental 1 1
EOF
- fi
+ fi
done
return 0
}
-
mysql_update() {
# the first argument to this function is the microseconds since last update
# pass this parameter to the BEGIN statement (see bellow).
@@ -319,14 +307,12 @@ mysql_update() {
# remember: KEEP IT SIMPLE AND SHORT
local m x
- for m in "${!mysql_ids[@]}"
- do
+ for m in "${!mysql_ids[@]}"; do
x="${mysql_ids[$m]}"
mysql_get "${mysql_cmds[$m]}" ${mysql_opts[$m]}
# shellcheck disable=SC2181
- if [ $? -ne 0 ]
- then
+ if [ $? -ne 0 ]; then
unset "mysql_ids[$m]"
unset "mysql_opts[$m]"
unset "mysql_cmds[$m]"
@@ -497,8 +483,7 @@ SET Opened_files = ${mysql_data[Opened_files]}
END
VALUESEOF
- if [ ! -z "${mysql_data[Binlog_stmt_cache_disk_use]}" ]
- then
+ if [ ! -z "${mysql_data[Binlog_stmt_cache_disk_use]}" ]; then
cat <<VALUESEOF
BEGIN mysql_$x.binlog_stmt_cache $1
SET Binlog_stmt_cache_disk_use = ${mysql_data[Binlog_stmt_cache_disk_use]}
@@ -507,8 +492,7 @@ END
VALUESEOF
fi
- if [ ! -z "${mysql_data[Connection_errors_accept]}" ]
- then
+ if [ ! -z "${mysql_data[Connection_errors_accept]}" ]; then
cat <<VALUESEOF
BEGIN mysql_$x.connection_errors $1
SET Connection_errors_accept = ${mysql_data[Connection_errors_accept]}
@@ -525,4 +509,3 @@ VALUESEOF
[ ${#mysql_ids[@]} -eq 0 ] && error "no mysql servers left active." && return 1
return 0
}
-