# !/bin/bash
# author : Denny
# Monitor the connection of redis

# 获取实例当前占用连接数
current_connection=`redis-cli -p 6379 info clients | grep "connected_clients" |awk -F":" '{ print $2 }'|tr -d "\r"`

#获取最大连接数
max_connection=`redis-cli -p 6379 config get maxclients | awk 'NR==2{print}' |tr -d "\r"`

connection_utilization=$(echo $current_connection $max_connection | awk '{printf "%0.2f\n" ,$1/$2}')

echo  "scale=1; ($connection_utilization * 100)/1 "|bc
