|
|
package com.monitor.other.maliciousip.util;
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import redis.clients.jedis.Jedis;
|
...
|
...
|
@@ -13,6 +15,10 @@ import redis.clients.jedis.JedisPoolConfig; |
|
|
*/
|
|
|
@Service
|
|
|
public class RedisReadUtil {
|
|
|
/**
|
|
|
* 日志接口
|
|
|
*/
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
/**
|
|
|
* Redis string,里面放ip、ops、百分比
|
...
|
...
|
@@ -80,9 +86,14 @@ public class RedisReadUtil { |
|
|
* @return
|
|
|
*/
|
|
|
public String getIps() {
|
|
|
Jedis jedis = getJedis();
|
|
|
String value = jedis.get(String.format(MALICIOUS_IP, TIME_DIMENSION_MINUTE_KEY));
|
|
|
returnResource(jedis);
|
|
|
String value = null;
|
|
|
try{
|
|
|
Jedis jedis = getJedis();
|
|
|
value = jedis.get(String.format(MALICIOUS_IP, TIME_DIMENSION_MINUTE_KEY));
|
|
|
returnResource(jedis);
|
|
|
}catch(Exception e){
|
|
|
logger.error(" - RedisReadUtil - getIps - error", e);
|
|
|
}
|
|
|
return value;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -92,9 +103,14 @@ public class RedisReadUtil { |
|
|
* @return
|
|
|
*/
|
|
|
public String getIpsBL() {
|
|
|
Jedis jedis = getJedis();
|
|
|
String value = jedis.get(String.format(MALICIOUS_IP_BL, TIME_DIMENSION_MINUTE_KEY));
|
|
|
returnResource(jedis);
|
|
|
String value = null;
|
|
|
try{
|
|
|
Jedis jedis = getJedis();
|
|
|
value = jedis.get(String.format(MALICIOUS_IP_BL, TIME_DIMENSION_MINUTE_KEY));
|
|
|
returnResource(jedis);
|
|
|
}catch(Exception e){
|
|
|
logger.error(" - RedisReadUtil - getIpsBL - error", e);
|
|
|
}
|
|
|
return value;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -104,9 +120,14 @@ public class RedisReadUtil { |
|
|
* @return
|
|
|
*/
|
|
|
public String getIpsCS() {
|
|
|
Jedis jedis = getJedis();
|
|
|
String value = jedis.get(String.format(MALICIOUS_IP_BL, TIME_DIMENSION_MINUTE_KEY));
|
|
|
returnResource(jedis);
|
|
|
String value = null;
|
|
|
try{
|
|
|
Jedis jedis = getJedis();
|
|
|
value = jedis.get(String.format(MALICIOUS_IP_BL, TIME_DIMENSION_MINUTE_KEY));
|
|
|
returnResource(jedis);
|
|
|
}catch(Exception e){
|
|
|
logger.error(" - RedisReadUtil - getIpsBL - error", e);
|
|
|
}
|
|
|
return value;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -117,9 +138,14 @@ public class RedisReadUtil { |
|
|
* @return
|
|
|
*/
|
|
|
public String getDetail(String ip){
|
|
|
Jedis jedis = getJedis();
|
|
|
String value = jedis.get(String.format(MALICIOUS_IP_DETAIL,TIME_DIMENSION_MINUTE_KEY,ip));
|
|
|
returnResource(jedis);
|
|
|
String value = null;
|
|
|
try{
|
|
|
Jedis jedis = getJedis();
|
|
|
value = jedis.get(String.format(MALICIOUS_IP_DETAIL,TIME_DIMENSION_MINUTE_KEY,ip));
|
|
|
returnResource(jedis);
|
|
|
}catch(Exception e){
|
|
|
logger.error(" - RedisReadUtil - getIpsBL - error", e);
|
|
|
}
|
|
|
return value;
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|