Merge branch 'develop' of https://git.mesalab.cn/K18_NTCS_WEB/NTC.git into develop

This commit is contained in:
leijun
2019-01-18 09:51:38 +08:00
23 changed files with 215 additions and 115 deletions

View File

@@ -199,7 +199,7 @@ public class BaseCfg<T> extends BaseEntity<T> implements Cloneable{
/**
* 来函
*/
@ExcelField(title="letter",sort=58)
@ExcelField(title="letter",sort=60)
protected String requestName;
/**
* 是否区域gk
@@ -209,7 +209,7 @@ public class BaseCfg<T> extends BaseEntity<T> implements Cloneable{
/**
* 分类
*/
@ExcelField(title="classification",dictType="type",sort=60)
@ExcelField(title="classification",dictType="type",sort=62)
protected String classify;
/**
* 性质

View File

@@ -43,24 +43,24 @@ public class BaseIpCfg extends BaseCfg<BaseIpCfg> {
*/
@Expose
@SerializedName("ipType")
@ExcelField(title="ip_type",dictType="IP_TYPE",sort=44)
@ExcelField(title="ip_type",dictType="IP_TYPE",sort=50)
protected Integer ipType;
@ExcelField(title="ip_pattern",dictType="IP_PATTERN",sort=45)
@ExcelField(title="ip_pattern",dictType="IP_PATTERN",sort=51)
protected Integer ipPattern;
@ExcelField(title="client_ip",sort=47)
@ExcelField(title="client_ip",sort=53)
protected String srcIpAddress;
@ExcelField(title="server_ip",sort=46)
@ExcelField(title="server_ip",sort=52)
protected String destIpAddress;
@ExcelField(title="port_pattern",dictType="PORT_PATTERN",sort=48)
@ExcelField(title="port_pattern",dictType="PORT_PATTERN",sort=54)
protected Integer portPattern;
@ExcelField(title="client_port",sort=49)
@ExcelField(title="client_port",sort=55)
protected String srcPort;
@ExcelField(title="server_port",sort=50)
@ExcelField(title="server_port",sort=56)
protected String destPort;
protected Integer dnsStrategyId;
@ExcelField(title="ir_type",dictType="IR_TYPE",sort=51)
@ExcelField(title="ir_type",dictType="IR_TYPE",sort=57)
protected Integer irType;
@ExcelField(title="group_name",sort=52)
@ExcelField(title="group_name",sort=58)
protected String groupName;
private List<NtcSubscribeIdCfg> ntcSubscribeIdCfgList;
@@ -75,7 +75,7 @@ public class BaseIpCfg extends BaseCfg<BaseIpCfg> {
protected String organization; //仅用于copy属性使用
protected String country; //仅用于copy属性使用
protected String detail; //仅用于copy属性使用
@ExcelField(title="log_total",sort=31)
@ExcelField(title="log_total",sort=42)
private Long totalLogs;
public String getOrganization() {
@@ -177,14 +177,14 @@ public class BaseIpCfg extends BaseCfg<BaseIpCfg> {
*/
@Expose
@SerializedName("direction")
@ExcelField(title="direction",dictType="DIRECTION",sort=53)
@ExcelField(title="direction",dictType="DIRECTION",sort=58)
protected Integer direction ;
/**
* 协议
*/
@Expose
@SerializedName("protocol")
@ExcelField(title="protocol",dictType="PROTOCOL",sort=54)
@ExcelField(title="protocol",dictType="PROTOCOL",sort=59)
protected Integer protocol ;
/**
* 协议ID

View File

@@ -23,29 +23,13 @@ public class DdosIpCfg extends BaseIpCfg {
*/
private static final long serialVersionUID = -5446903784736960824L;
private String indexTable="ddos_ip_cfg";
@ExcelField(title="antiddos_protocol",sort=41)
@ExcelField(title="antiddos_protocol",sort=46)
private String antiddosProtocol;//目前支持TCP_SYN, DNS, NTP
@ExcelField(title="bps_threadshold",sort=42)
@ExcelField(title="bps_threadshold",sort=47)
private Long bpsThreadshold;// 即DDoS攻击保护动作触发阈值每秒Bit数和每秒包数
@ExcelField(title="pps_threadshold",sort=43)
@ExcelField(title="pps_threadshold",sort=48)
private Long ppsThreadshold;
@ExcelField(title="log_total",sort=32)
private Long totalLogs;
@ExcelField(title="is_audit",dictType="AUDIT_STATUS",sort=20)
private Integer isAudit;
public Integer getIsAudit() {
return isAudit;
}
public void setIsAudit(Integer isAudit) {
this.isAudit = isAudit;
}
public Long getTotalLogs() {
return totalLogs;
}
public void setTotalLogs(Long totalLogs) {
this.totalLogs = totalLogs;
}
public String getAntiddosProtocol() {
return antiddosProtocol;
}

View File

@@ -24,6 +24,8 @@ public class TrafficIpActiveStatistic{
String statTime;
private String _byte;
private String _packet;
private String avgByte;
private String avgPacket;
@ExcelField(title="Byte",sort=51,type=1)
public String get_byte() {
return BigInteger.valueOf(this.getC2sByteLen()).add(BigInteger.valueOf(this.getS2cByteLen())).toString();
@@ -95,5 +97,16 @@ public class TrafficIpActiveStatistic{
public void setS2cByteLen(Long s2cByteLen) {
this.s2cByteLen = s2cByteLen;
}
public String getAvgByte() {
return avgByte;
}
public void setAvgByte(String avgByte) {
this.avgByte = avgByte;
}
public String getAvgPacket() {
return avgPacket;
}
public void setAvgPacket(String avgPacket) {
this.avgPacket = avgPacket;
}
}

View File

@@ -188,6 +188,20 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
long afterTime = after.getTime();
return (afterTime - beforeTime) / (1000 * 60 * 60 * 24);
}
/**
* 获取两个日期之间的秒数
*
* @param before
* @param after
* @return
*/
public static double getSecondsOfTwoDate(Date before, Date after) {
long beforeTime = before.getTime();
long afterTime = after.getTime();
return (afterTime - beforeTime) / (1000);
}
/**
*
*

View File

@@ -3,6 +3,7 @@ package com.nis.web.controller.dashboard;
import java.lang.reflect.Type;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
@@ -248,7 +249,7 @@ public class DashboardController extends BaseController{
@ResponseBody
public List ajaxIpActiveList(String beginDate,String endDate,Integer entranceId){
Map<String, Object> fromJsonList = new HashMap<String, Object>();
List list = new ArrayList();
List<TrafficIpActiveStatistic> list = new ArrayList<TrafficIpActiveStatistic>();
try {
String url=Constants.DASHBOARD_URL+Constants.TRAFFIC_IPACTIVE_ONEHOUR;
url=urlAddDate(url, beginDate, endDate);
@@ -260,6 +261,16 @@ public class DashboardController extends BaseController{
fromJsonList = gson.fromJson(string, new TypeToken<Map<String, Object>>(){}.getType());
logger.debug("活跃IP1小时"+fromJsonList);
list = gson.fromJson(fromJsonList.get("data").toString(), new TypeToken<List<TrafficIpActiveStatistic>>() {}.getType()) ;
if(list.size()>0) {
DecimalFormat lf = new DecimalFormat("0");
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//两个时间段之间的秒数
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
for(TrafficIpActiveStatistic data:list) {
data.setAvgByte(lf.format(Integer.parseInt(data.get_byte())*8/allSeconds));
data.setAvgPacket(lf.format(Integer.parseInt(data.get_packet())/allSeconds));
}
}
Collections.sort(list, new Comparator<TrafficIpActiveStatistic>() {
@Override
@@ -282,7 +293,7 @@ public class DashboardController extends BaseController{
} catch (Exception e) {
e.printStackTrace();
logger.error("活跃IP数据获取错误"+e);
list.add(Maps.newHashMap("error","request_service_failed"));
//list.add(Maps.newHashMap("error","request_service_failed"));
}
return list;
}

View File

@@ -44,6 +44,7 @@ import com.nis.domain.dashboard.TrafficIpActiveStatistic;
import com.nis.util.CodeDicUtils;
import com.nis.util.Constants;
import com.nis.util.DateUtil;
import com.nis.util.DateUtils;
import com.nis.util.DictUtils;
import com.nis.util.StringUtil;
import com.nis.util.httpclient.HttpClientUtil;
@@ -301,6 +302,7 @@ public class TrafficStatisticsInfoController extends BaseController {
@RequestMapping(value="protocolList")
@ResponseBody
public List protocolList(Model model,Integer entranceId,Integer[] protoType,@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate){
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Map<String, Object> fromJsonList = new HashMap<String, Object>();
List list = new ArrayList();
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_PROTOCOL_LIST;
@@ -327,6 +329,8 @@ public class TrafficStatisticsInfoController extends BaseController {
DecimalFormat lf = new DecimalFormat("0");
DecimalFormat df = new DecimalFormat("0.0000000000");
List<CodeResult> appCodeList = CodeDicUtils.getCodeList("appCode");
//两个时间段之间的秒数
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
if(!StringUtil.isEmpty(list)){
for (Object object : list) {
Map m=(Map) object;
@@ -336,6 +340,10 @@ public class TrafficStatisticsInfoController extends BaseController {
m.put("GByte", df.format(m.get("GByte")));
m.put("packets", lf.format(m.get("packets")));
m.put("linkNum", lf.format(m.get("linkNum")));
double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds;
m.put("pps",lf.format(avgPacket));
double avgByte=Double.parseDouble(m.get("GByte").toString())*1024*1024*1024*8/allSeconds;
m.put("bps",lf.format(avgByte));
totalLink+=Long.parseLong( m.get("linkNum").toString());
totalPackets+=Long.parseLong(m.get("packets").toString());
// 协议没匹配的匹配app码表
@@ -407,6 +415,9 @@ public class TrafficStatisticsInfoController extends BaseController {
Double totalGByte=0d;
DecimalFormat lf = new DecimalFormat("0");
DecimalFormat df = new DecimalFormat("0.0000000000");
//两个时间段之间的秒数
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
if(!StringUtil.isEmpty(list)){
for (Object object : list) {
Map m=(Map) object;
@@ -417,6 +428,11 @@ public class TrafficStatisticsInfoController extends BaseController {
m.put("linkNum", lf.format(m.get("linkNum")));
totalLink+=Long.parseLong( m.get("linkNum").toString());
totalPackets+=Long.parseLong(m.get("packets").toString());
double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds;
m.put("pps",lf.format(avgPacket));
double avgByte=Double.parseDouble(m.get("GByte").toString())*1024*1024*1024*8/allSeconds;
m.put("bps",lf.format(avgByte));
}
for (Object object : list) {
Map m=(Map) object;
@@ -485,7 +501,7 @@ public class TrafficStatisticsInfoController extends BaseController {
@ResponseBody
public List ajaxAppTopList(String beginDate,String endDate,Integer appType,Integer entranceId,Integer searchQuota,Model model){
Map<String, Object> fromJsonList = new HashMap<String, Object>();
List list = new ArrayList();
List<Map> list = new ArrayList<Map>();
try {
String url=Constants.DASHBOARD_URL+Constants.APPCONN_RECORD_TOP100;
URIBuilder uriBuilder = new URIBuilder(url);
@@ -508,7 +524,18 @@ public class TrafficStatisticsInfoController extends BaseController {
fromJsonList = gson.fromJson(string, new TypeToken<Map<String, Object>>(){}.getType());
logger.debug("app列表Top100"+fromJsonList);
list = (ArrayList) fromJsonList.get("data");
if(list.size()>0) {
//两个时间段之间的秒数
DecimalFormat dl = new DecimalFormat("0");
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
for(Map m:list) {
double avgPacket=Double.parseDouble(m.get("pktNum").toString())/allSeconds;
m.put("pps",dl.format(avgPacket));
double avgByte=Double.parseDouble(m.get("byteNum").toString())*8/allSeconds;
m.put("bps",dl.format(avgByte));
}
}
} catch (Exception e) {
e.printStackTrace();
logger.error("app列表Top100"+e);
@@ -610,6 +637,9 @@ public class TrafficStatisticsInfoController extends BaseController {
// Double totalLink=0d;
Double totalGbyte=0d;
Double totalPackets=0d;
//两个时间段之间的秒数
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
for (Object object : list) {
Map m=(Map)object;
Double count=(Double)m.get("byteCount");
@@ -618,6 +648,11 @@ public class TrafficStatisticsInfoController extends BaseController {
totalPackets+=(Double)m.get("pktCount");
String format = df.format(count/1024/1024/1024);
m.put("Gbyte", format);
double avgPacket=Double.parseDouble(m.get("pktCount").toString())/allSeconds;
m.put("pps",dl.format(avgPacket));
double avgByte=Double.parseDouble(m.get("byteCount").toString())*8/allSeconds;
m.put("bps",dl.format(avgByte));
}
List<WebsiteDomainTopic> codeList = appCfgService.getDomainDict(new WebsiteDomainTopic());
Map<Long, String> map = new HashMap<Long,String>();
@@ -687,12 +722,19 @@ public class TrafficStatisticsInfoController extends BaseController {
Long totalPackets=0l;
Double totalGByte=0d;
DecimalFormat lf = new DecimalFormat("0");
//两个时间段之间的秒数
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
if(!StringUtil.isEmpty(list)){
for (Object object : list) {
Map m=(Map) object;
totalLink+=Long.parseLong(lf.format(m.get("linkNum")));
totalPackets+=Long.parseLong(lf.format(m.get("packets")));
totalGByte+=Double.parseDouble(lf.format(m.get("count")));
double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds;
m.put("pps",lf.format(avgPacket));
double avgByte=Double.parseDouble(m.get("count").toString())*8/allSeconds;
m.put("bps",lf.format(avgByte));
m.remove("domainData");
Double value1=0d;
if(StringUtil.isBlank(m.get("topicId").toString())){

View File

@@ -87,11 +87,11 @@ public class TrafficStatisticsReportController extends BaseController {
// statTime=DateUtils.getDate()+" 00:00:00"; // 默认今天
// endTime=DateUtils.getDateTime();
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(cal.getTime());// 获取到完整的时间
cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 1);
statTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(cal.getTime());
Calendar time = Calendar.getInstance();
endTime = DateUtils.formatDateTimeByParm(time.getTime(),"yyyy-MM-dd HH")+":00:00";
time.add(Calendar.HOUR_OF_DAY, -1);
statTime = DateUtils.formatDateTimeByParm(time.getTime(),"yyyy-MM-dd HH")+":00:00";;
bean.setSearchFoundStartTime(statTime);
bean.setSearchFoundEndTime(endTime);
statTime = URLEncoder.encode(statTime, "UTF-8");