监控redis的Info信息脚本

#!/bin/bash
cmd=/usr/redis/redis-cli
host=localhost
port=6379
file=redis-info.txt
space_time=$1
continue_count=$2
 
if [ -z $space_time ];then
  space_time=2s
fi
 
count=1
while [[ "$count" -le $continue_count ]];do
echo '--------------------------------------------------------------------'>> $file
echo "$cmd -h $host -p $port info at $(date "+%Y-%m-%d %H:%M:%S")"  >> $file
echo '--------------------------------------------------------------------'>> $file
`$cmd -h $host -p $port info >> $file`
let ++count
sleep $space_time
 
done

将以上命令保存到redis-info.sh。

chmod +x redis-info.sh
./redis-info.sh 1200s #执行20分钟

记录日志结果如下:


by 雪洁 2018-08-15 06:13:01 373 views
我来说几句

相关文章