mirror of
https://github.com/myvesta/vesta
synced 2025-07-06 04:51:54 -07:00
RACK911LABS.COM: safer mysql status check
This commit is contained in:
parent
73e6656986
commit
4c751ab693
1 changed files with 5 additions and 17 deletions
|
@ -14,6 +14,7 @@ period=${1-daily}
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
|
source $VESTA/func/db.sh
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,23 +67,10 @@ for host in $hosts; do
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$period" = 'daily' ]; then
|
if [ "$period" = 'daily' ]; then
|
||||||
# Defining host credentials
|
mysql_connect $host
|
||||||
host_str=$(grep "HOST='$host'" $conf)
|
query='SHOW GLOBAL STATUS'
|
||||||
for key in $host_str; do
|
status=$(mysql_query "$query" 2>/dev/null)
|
||||||
eval ${key%%=*}=${key#*=}
|
if [ $? -ne 0 ]; then
|
||||||
done
|
|
||||||
sql="mysql -h $HOST -u $USER -p$PASSWORD -e"
|
|
||||||
|
|
||||||
# Checking empty vars
|
|
||||||
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ]; then
|
|
||||||
echo "Error: config is broken"
|
|
||||||
log_event "$E_PARSING" "$ARGUMENTS"
|
|
||||||
exit $E_PARSING
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Parsing data
|
|
||||||
status=$($sql "SHOW GLOBAL STATUS" 2>/dev/null); code="$?"
|
|
||||||
if [ '0' -ne "$code" ]; then
|
|
||||||
active=0
|
active=0
|
||||||
slow=0
|
slow=0
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue