diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2016-10-20 22:04:28 +0300 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2016-10-20 22:04:28 +0300 |
commit | addb52bb18ba356fc1cb5888b1fe5b809137346d (patch) | |
tree | 61f3294473d70f9f96e2e302837ff844a70e3207 /charts.d/mysql.chart.sh | |
parent | c6d3138cc7ddb21bac33df2fc9f16c6e76ff1426 (diff) |
better log management for charts.d.plugin - fixes #1144
Diffstat (limited to 'charts.d/mysql.chart.sh')
-rwxr-xr-x | charts.d/mysql.chart.sh | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/charts.d/mysql.chart.sh b/charts.d/mysql.chart.sh index 120fec66e3..2bb80a8a9c 100755 --- a/charts.d/mysql.chart.sh +++ b/charts.d/mysql.chart.sh @@ -17,9 +17,9 @@ mysql_get() { 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]+" )) + #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]" )) + arr=($(run "${@}" -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 @@ -74,13 +74,13 @@ mysql_check() { [ -z "${mysql_cmds[$m]}" ] && mysql_cmds[$m]="$mysql_cmd" if [ -z "${mysql_cmds[$m]}" ] then - echo >&2 "$PROGRAM_NAME: mysql: cannot get mysql command for '$m'. Please set mysql_cmds[$m]='/path/to/mysql', in $confd/mysql.conf" + 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]} if [ ! $? -eq 0 ] then - echo >&2 "$PROGRAM_NAME: mysql: 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" + 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] unset mysql_ids[$m] @@ -97,7 +97,7 @@ mysql_check() { mysql_check tryroot "${@}" return $? else - echo >&2 "$PROGRAM_NAME: mysql: no mysql servers found. Please set mysql_opts[name]='options' to whatever needed to get connected to the mysql server, in $confd/mysql.conf" + error "no mysql servers found. Please set mysql_opts[name]='options' to whatever needed to get connected to the mysql server, in $confd/mysql.conf" return 1 fi fi @@ -318,7 +318,7 @@ mysql_update() { unset mysql_ids[$m] unset mysql_opts[$m] unset mysql_cmds[$m] - echo >&2 "$PROGRAM_NAME: mysql: failed to get values for '$m', disabling it." + error "failed to get values for '$m', disabling it." continue fi @@ -510,7 +510,7 @@ VALUESEOF fi done - [ ${#mysql_ids[@]} -eq 0 ] && echo >&2 "$PROGRAM_NAME: mysql: no mysql servers left active." && return 1 + [ ${#mysql_ids[@]} -eq 0 ] && error "no mysql servers left active." && return 1 return 0 } |