Skip to content

Commit 4c751ab

Browse files
author
Serghey Rodin
committed
RACK911LABS.COM: safer mysql status check
1 parent 73e6656 commit 4c751ab

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

bin/v-update-sys-rrd-mysql

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ period=${1-daily}
1414

1515
# Includes
1616
source $VESTA/func/main.sh
17+
source $VESTA/func/db.sh
1718
source $VESTA/conf/vesta.conf
1819

1920

@@ -66,23 +67,10 @@ for host in $hosts; do
6667
fi
6768

6869
if [ "$period" = 'daily' ]; then
69-
# Defining host credentials
70-
host_str=$(grep "HOST='$host'" $conf)
71-
for key in $host_str; do
72-
eval ${key%%=*}=${key#*=}
73-
done
74-
sql="mysql -h $HOST -u $USER -p$PASSWORD -e"
75-
76-
# Checking empty vars
77-
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ]; then
78-
echo "Error: config is broken"
79-
log_event "$E_PARSING" "$ARGUMENTS"
80-
exit $E_PARSING
81-
fi
82-
83-
# Parsing data
84-
status=$($sql "SHOW GLOBAL STATUS" 2>/dev/null); code="$?"
85-
if [ '0' -ne "$code" ]; then
70+
mysql_connect $host
71+
query='SHOW GLOBAL STATUS'
72+
status=$(mysql_query "$query" 2>/dev/null)
73+
if [ $? -ne 0 ]; then
8674
active=0
8775
slow=0
8876
else

0 commit comments

Comments
 (0)