...
|
...
|
@@ -22,11 +22,21 @@ public class RedisMonitorServiceImpl implements IRedisMonitorService { |
|
|
@Override
|
|
|
public void redisMonitor() {
|
|
|
|
|
|
String isSlave="";
|
|
|
String redisInfo = SSHRedis.exec("192.168.102.162", "root", "123456", 22,"sleep 20;cd /usr/bin;redis-cli -h 192.168.102.222 -p 6379 info;");
|
|
|
//检验主从同步
|
|
|
SSHRedis.exec("192.168.102.162", "root", "123456", 22,"sleep 20;cd /usr/bin;redis-cli -h 192.168.102.222 -p 6379 set test_key 'test';");
|
|
|
String redisInfo2 = SSHRedis.exec("192.168.102.162", "root", "123456", 22,"sleep 20;cd /usr/bin;redis-cli -h 192.168.102.222 -p 6379 get test_key;");
|
|
|
String[] arry = redisInfo2.split("<br>");
|
|
|
String val = arry[0].replace("\r\n", "").trim();
|
|
|
if("test".equals(val)){
|
|
|
isSlave="同步";
|
|
|
}else {
|
|
|
isSlave="不同步";
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(redisInfo)) {
|
|
|
RedisInfo redis = new RedisInfo("192.168.102.162", getRedisInfo(
|
|
|
redisInfo, "connected_clients"), getRedisInfo(redisInfo,
|
|
|
"used_memory"), getRedisInfo(redisInfo,
|
|
|
redisInfo, "connected_clients"), isSlave, getRedisInfo(redisInfo,
|
|
|
"used_memory_peak_human"), getRedisInfo(redisInfo,"role"));
|
|
|
redisMapper.insert(redis);
|
|
|
}
|
...
|
...
|
|