PATH:
usr
/
share
/
lve
/
dbgovernor
/
utils
/
Editing: mysql_export
#!/bin/bash export LD_PRELOAD= ARCH=`getconf LONG_BIT` LIBDIR=/usr/lib if [ "$ARCH" == "64" ]; then LIBDIR=/usr/lib64 fi FILE=$LIBDIR/libgovernor_stubs.so if [ -f "$FILE" ]; then export LD_PRELOAD=$LIBDIR/libgovernor.so else export LD_PRELOAD= fi cpu_limit= io_limit= vercomp() { if [[ $1 == $2 ]] then return 0 fi local IFS=. local i ver1=($1) ver2=($2) # fill empty fields in ver1 with zeros for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)) do ver1[i]=0 done for ((i=0; i<${#ver1[@]}; i++)) do if [[ -z ${ver2[i]} ]] then # fill empty fields in ver2 with zeros ver2[i]=0 fi if ((10#${ver1[i]} > 10#${ver2[i]})) then return 1 fi if ((10#${ver1[i]} < 10#${ver2[i]})) then return 2 fi done return 0 } get_limit(){ return if [ -e /usr/sbin/lvectl ]; then VERS=$(/usr/sbin/lvectl version | cut -d"-" -f1) vercomp "1.4" "$VERS" VERS_GET=$? if [ "$VERS_GET" -eq 1 ];then LVE_VER=$(/usr/sbin/lvectl --lve-version) if [ "$LVE_VER" == "4" ]; then io_limit=$(/usr/sbin/lvectl limits 3 | awk 'NR == 2' | awk '{print $6}') else io_limit=$(/usr/sbin/lvectl limits 3 | awk 'NR == 2' | awk '{print $8}') fi cpu_limit=$(/usr/sbin/lvectl limits 3 | awk 'NR == 2' | awk '{print $2}') else LVE_VER=$(/usr/sbin/lvectl --lve-version) if [ "$LVE_VER" == "4" ]; then io_limit=$(/usr/sbin/lvectl limits 3 | awk 'NR == 2' | awk '{print $6}') else io_limit=$(/usr/sbin/lvectl limits 3 | awk 'NR == 2' | awk '{print $8}') fi cpu_limit=$(/usr/sbin/lvectl limits 3 | awk 'NR == 2' | awk '{print $2}') fi fi } set_big_limit(){ return if [ -e /usr/sbin/lvectl ]; then VERS=$(/usr/sbin/lvectl version | cut -d"-" -f1) vercomp "1.4" "$VERS" VERS_GET=$? if [ "$VERS_GET" -eq 1 ];then if [ -e /usr/sbin/lvectl ]; then /usr/sbin/lvectl set 3 --cpu=100 --io=0 --save-all-parameters fi else proc_numb=$(cat /proc/cpuinfo | grep processor | wc -l) let "max_limit = $proc_numb * 100"; /usr/sbin/lvectl set 3 --speed=$max_limit% --io=0 --save-all-parameters fi fi } set_old_limit(){ return if [ -e /usr/sbin/lvectl ]; then VERS=$(/usr/sbin/lvectl version | cut -d"-" -f1) vercomp "1.4" "$VERS" VERS_GET=$? if [ "$VERS_GET" -eq 1 ];then if [ -z "$io_limit" ]; then /usr/sbin/lvectl set 3 --cpu="$cpu_limit" --save-all-parameters else /usr/sbin/lvectl set 3 --cpu="$cpu_limit" --io="$io_limit" --save-all-parameters fi else if [ -z "$io_limit" ]; then /usr/sbin/lvectl set 3 --speed="$cpu_limit"% --save-all-parameters else /usr/sbin/lvectl set 3 --speed="$cpu_limit"% --io="$io_limit" --save-all-parameters fi fi fi }
SAVE
CANCEL