腾讯云监控redis连接IP只有实时IP连接监控情况,直接使用redis-cli client list也只能看到当时的连接情况,没有时间戳可以参考,所以对此命令进行加工,增加时间戳并输出到文件中,进行参考,以下是全部内容
iplist=(192.168.1.37 192.168.1.125 192.168.0.34 192.168.0.85) portlist=(6338 6378 6379 6379) for i in "${!iplist[@]}" do #echo $i,${iplist[$i]},${portlist[$i]} echo `/bin/redis-cli -h ${iplist[$i]} -p ${portlist[$i]} client list| awk -F ' ' 'BEGIN { "date \"+%Y-%m-%d %H:%M:%S\"" | getline now; close("date \"+%Y-%m-%d %H:%M:%S\"");} {print now,$1,$2,$3}' |tee -a /home/sfish/redis/${iplist[$i]}.info` done #redis-cli -h 192.168.0.85 -p 6379 client list | awk -F ' ' 'BEGIN { "date \"+%Y-%m-%d %H:%M:%S\"" | getline now; close("date \"+%Y-%m-%d %H:%M:%S\""); print now } {print now,$1,$2,$3}'
输出文件
192.168.0.34.info 192.168.0.85.info 192.168.1.125.info 192.168.1.37.info
内容查看.
more 192.168.0.34.info
2023-03-30 13:07:01 id=-139014578367029239 addr=192.168.0.113:61768 fd=245 2023-03-30 13:07:01 id=-194465148779028471 addr=192.168.0.70:45416 fd=199 2023-03-30 13:07:01 id=-237249345239048183 addr=192.168.0.134:6500 fd=281 2023-03-30 13:07:01 id=-445540828004933623 addr=192.168.0.53:40726 fd=96 2023-03-30 13:07:01 id=-390653207546355703 addr=192.168.32.10:26294 fd=24 2023-03-30 13:07:01 id=-429778229309136887 addr=192.168.0.53:41518 fd=339 2023-03-30 13:07:01 id=-145207027854663671 addr=192.168.0.58:54736 fd=180 2023-03-30 13:07:01 id=-4751014476046327 addr=192.168.0.97:38724 fd=387 2023-03-30 13:07:01 id=-121000179857547255 addr=192.168.0.70:45274 fd=178 2023-03-30 13:07:01 id=-203753823010480119 addr=192.168.0.70:45410 fd=197
标签:03,01,addr,IP,30,redis,192.168,fd,客户端 From: https://www.cnblogs.com/i1991/p/17272132.html