/etc/monit.d/bins/mysqlcheck.sh being overwritten

I’m updating my mysqlcheck.sh to:

#!/bin/sh
[[ -f /etc/sysconfig/argos ]] && . /etc/sysconfig/argos
declare -x HOME=/root
MYSQLBIN=/usr/bin/mysql
[[ -L /usr/bin/mysql ]] && MYSQLBIN=“$(readlink /usr/bin/mysql)”
MAXCONN=${MYSQL_MAXCONN:-100}
CONNECTED=$(echo ‘show status where variable_name = “Threads_connected”;’ | “$MYSQLBIN” --connect-timeout=10 -rq --column-names=false | awk ‘{print $2}’)

Don’t trigger a restart if MySQL is starting up…

[[ -z $CONNECTED || $CONNECTED -lt $MAXCONN ]]
RET=$?
echo $CONNECTED
exit $RET

As we handle a lot of concurrent connections, although it keeps reverting to 40 max connections, which is constantly killing my MySQL process.

That file may not be directly modified. To increase the connection threshold, create a file named /etc/sysconfig/argos if it does not already exist. In it add the following line:

MYSQL_MAXCONN=100

Got it, just made the change. Thank you.

Seems like the file was reverted back to 40 again even after creating the file “argos” in the folder: /etc/sysconfig/

[root@apiscp sysconfig]# cat /etc/sysconfig/argos
MYSQL_MAXCONN=500

lgtm.

[[ -f /etc/sysconfig/argos ]] && . /etc/sysconfig/argos
declare -x HOME=/root
MYSQLBIN=/usr/bin/mysql
[[ -L /usr/bin/mysql ]] && MYSQLBIN="$(readlink /usr/bin/mysql)"
MAXCONN=${MYSQL_MAXCONN:-40}

Sample code to test:

[[ -f /etc/sysconfig/argos ]] && . /etc/sysconfig/argos
MAXCONN=${MYSQL_MAXCONN:-40}
echo $MAXCONN

500 is reported.

I’m a fool, I see it works. Thank you.

1 Like