From 9e59c5f26e1f9d56681c50016f1377b26160fc25 Mon Sep 17 00:00:00 2001 From: zhanghongqing Date: Fri, 21 Sep 2018 20:56:01 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B5=81=E9=87=8F?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E7=AB=AF=E5=8F=A3=EF=BC=8C=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../restful/dashboard/NtcTotalReport.java | 93 ++++++++++++ .../dashboard/TrafficHttpStatistic.java | 12 +- .../dashboard/TrafficPortActiveStatistic.java | 38 +++++ .../restful/dashboard/WebsiteDomainTopic.java | 59 ++++++++ .../restful/DashboardServiceController.java | 94 +++++++++++- .../web/dao/dashboard/NtcTotalReportDao.java | 11 ++ .../web/dao/dashboard/NtcTotalReportDao.xml | 24 +++ .../dao/dashboard/TrafficAppStatisticDao.xml | 5 +- .../dashboard/TrafficHttpStatisticDao.java | 12 +- .../dao/dashboard/TrafficHttpStatisticDao.xml | 70 ++++++--- .../dashboard/TrafficIpActiveStatisticDao.xml | 2 +- .../TrafficPortActiveStatisticDao.java | 12 ++ .../TrafficPortActiveStatisticDao.xml | 17 +++ .../dashboard/TrafficProtocolStatisticDao.xml | 3 +- .../dao/dashboard/TrafficUaStatisticDao.xml | 32 ++-- .../web/service/restful/DashboardService.java | 140 ++++++++++++++---- 16 files changed, 544 insertions(+), 80 deletions(-) create mode 100644 src/main/java/com/nis/domain/restful/dashboard/NtcTotalReport.java create mode 100644 src/main/java/com/nis/domain/restful/dashboard/TrafficPortActiveStatistic.java create mode 100644 src/main/java/com/nis/domain/restful/dashboard/WebsiteDomainTopic.java create mode 100644 src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java create mode 100644 src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml create mode 100644 src/main/java/com/nis/web/dao/dashboard/TrafficPortActiveStatisticDao.java create mode 100644 src/main/java/com/nis/web/dao/dashboard/TrafficPortActiveStatisticDao.xml diff --git a/src/main/java/com/nis/domain/restful/dashboard/NtcTotalReport.java b/src/main/java/com/nis/domain/restful/dashboard/NtcTotalReport.java new file mode 100644 index 0000000..7c637e1 --- /dev/null +++ b/src/main/java/com/nis/domain/restful/dashboard/NtcTotalReport.java @@ -0,0 +1,93 @@ +package com.nis.domain.restful.dashboard; + +import java.util.Date; + +public class NtcTotalReport { + + private Integer statId ;//int(11) NOT NULL AUTO_INCREMENT COMMENT id自增, + private Integer rejectNum ;//int(11) NOT NULL COMMENT 封堵数量, + private Integer monitorNum ;//int(11) NOT NULL COMMENT 监测数量, + private Integer c2sPktNum ;//int(11) DEFAULT NULL COMMENT c2s包数, + private Integer s2cPktNum ;//int(11) DEFAULT NULL COMMENT s2c包数, + private Integer c2sByteLen ;//int(11) NOT NULL COMMENT c2s字节数, + private Integer s2cByteLen ;//int(11) NOT NULL COMMENT s2c字节数, + private Integer newUniConnNum ;//int(11) DEFAULT NULL COMMENT 新建链接数, + private Integer liveConnNum ;//int(11) DEFAULT NULL COMMENT 活跃链接数, + private Integer dropConnNum ;//int(11) DEFAULT NULL COMMENT 丢弃链接数, + private Integer loopConnNum ;//int(11) DEFAULT NULL COMMENT 回流链接数, + private Date reportTime ;//datetime NOT NULL COMMENT 统计时间, + + public Integer getStatId() { + return statId; + } + public void setStatId(Integer statId) { + this.statId = statId; + } + public Integer getRejectNum() { + return rejectNum; + } + public void setRejectNum(Integer rejectNum) { + this.rejectNum = rejectNum; + } + public Integer getMonitorNum() { + return monitorNum; + } + public void setMonitorNum(Integer monitorNum) { + this.monitorNum = monitorNum; + } + public Integer getC2sPktNum() { + return c2sPktNum; + } + public void setC2sPktNum(Integer c2sPktNum) { + this.c2sPktNum = c2sPktNum; + } + public Integer getS2cPktNum() { + return s2cPktNum; + } + public void setS2cPktNum(Integer s2cPktNum) { + this.s2cPktNum = s2cPktNum; + } + public Integer getC2sByteLen() { + return c2sByteLen; + } + public void setC2sByteLen(Integer c2sByteLen) { + this.c2sByteLen = c2sByteLen; + } + public Integer getS2cByteNen() { + return s2cByteLen; + } + public void setS2cByteNen(Integer s2cByteLen) { + this.s2cByteLen = s2cByteLen; + } + public Integer getNewUniConnNum() { + return newUniConnNum; + } + public void setNewUniConnNum(Integer newUniConnNum) { + this.newUniConnNum = newUniConnNum; + } + public Integer getLiveConnNum() { + return liveConnNum; + } + public void setLiveConnNum(Integer liveConnNum) { + this.liveConnNum = liveConnNum; + } + public Integer getDropConnNum() { + return dropConnNum; + } + public void setDropConnNum(Integer dropConnNum) { + this.dropConnNum = dropConnNum; + } + public Integer getLoopConnNum() { + return loopConnNum; + } + public void setLoopConnNum(Integer loopConnNum) { + this.loopConnNum = loopConnNum; + } + public Date getReportTime() { + return reportTime; + } + public void setReportTime(Date reportTime) { + this.reportTime = reportTime; + } + +} \ No newline at end of file diff --git a/src/main/java/com/nis/domain/restful/dashboard/TrafficHttpStatistic.java b/src/main/java/com/nis/domain/restful/dashboard/TrafficHttpStatistic.java index e928204..9fadebf 100644 --- a/src/main/java/com/nis/domain/restful/dashboard/TrafficHttpStatistic.java +++ b/src/main/java/com/nis/domain/restful/dashboard/TrafficHttpStatistic.java @@ -23,8 +23,18 @@ public class TrafficHttpStatistic { private Integer count; private Integer pktNum; private Integer byteLen; + private Integer websiteServiceId;//网站id - public Integer getCount() { + + public Integer getWesiteServiceId() { + return websiteServiceId; + } + + public void setWebsiteServiceId(Integer websiteServiceId) { + this.websiteServiceId = websiteServiceId; + } + + public Integer getCount() { return count; } diff --git a/src/main/java/com/nis/domain/restful/dashboard/TrafficPortActiveStatistic.java b/src/main/java/com/nis/domain/restful/dashboard/TrafficPortActiveStatistic.java new file mode 100644 index 0000000..98b3592 --- /dev/null +++ b/src/main/java/com/nis/domain/restful/dashboard/TrafficPortActiveStatistic.java @@ -0,0 +1,38 @@ +package com.nis.domain.restful.dashboard; + +import java.util.Date; + +public class TrafficPortActiveStatistic { +//流量统计之活跃端口统计 + private Integer statId; + private Integer port; + private Integer sum; + private Date statTime; + + public Integer getStatId() { + return statId; + } + public void setStatId(Integer statId) { + this.statId = statId; + } + public Integer getPort() { + return port; + } + public void setPort(Integer port) { + this.port = port; + } + public Integer getSum() { + return sum; + } + public void setSum(Integer sum) { + this.sum = sum; + } + public Date getStatTime() { + return statTime; + } + public void setStatTime(Date statTime) { + this.statTime = statTime; + } + + +} diff --git a/src/main/java/com/nis/domain/restful/dashboard/WebsiteDomainTopic.java b/src/main/java/com/nis/domain/restful/dashboard/WebsiteDomainTopic.java new file mode 100644 index 0000000..03319b4 --- /dev/null +++ b/src/main/java/com/nis/domain/restful/dashboard/WebsiteDomainTopic.java @@ -0,0 +1,59 @@ +package com.nis.domain.restful.dashboard; + +import java.util.Date; + +public class WebsiteDomainTopic { + + private Long id; // `id` bigint(20) NOT NULL AUTO_INCREMENT, + private Long websiteServiceId; // `website_service_id` bigint(20) DEFAULT NULL COMMENT '网站服务Id', + private String domain; // `domain` varchar(200) DEFAULT NULL COMMENT '域名', + private Long topicId; // `topic_id` bigint(20) DEFAULT NULL COMMENT '主题Id', + private Date createTime; // `create_time` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(), + private Integer creatorId; // `creator_id` int(11) DEFAULT NULL, + private Integer isValid; // `is_valid` int(1) DEFAULT NULL, + + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + public Long getWebsiteServiceId() { + return websiteServiceId; + } + public void setWebsiteServiceId(Long websiteServiceId) { + this.websiteServiceId = websiteServiceId; + } + public String getDomain() { + return domain; + } + public void setDomain(String domain) { + this.domain = domain; + } + public Long getTopicId() { + return topicId; + } + public void setTopicId(Long topicId) { + this.topicId = topicId; + } + public Date getCreateTime() { + return createTime; + } + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + public Integer getCreatorId() { + return creatorId; + } + public void setCreatorId(Integer creatorId) { + this.creatorId = creatorId; + } + public Integer getIsValid() { + return isValid; + } + public void setIsValid(Integer isValid) { + this.isValid = isValid; + } + + +} diff --git a/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java b/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java index 78f371c..2c6ec57 100644 --- a/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java +++ b/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java @@ -6,6 +6,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import com.nis.domain.restful.dashboard.TrafficPortActiveStatistic; import com.nis.restful.RestServiceException; import com.nis.util.Constants; import javax.servlet.http.HttpServletRequest; @@ -34,6 +35,67 @@ public class DashboardServiceController extends BaseRestController { protected ServicesRequestLogService servicesRequestLogService; @Autowired public DashboardService dashboardService; + + /** + * 流量统计info滚动条数据显示 封堵监测回流丢弃 + */ + @RequestMapping(value = "ntcTotalReport", method = RequestMethod.GET) + @ApiOperation(value = "业务总量汇聚", httpMethod = "GET", notes = "对应流量统计info滚动条数据显示") + public Map ntcTotalReport(Model model, HttpServletRequest request, HttpServletResponse response) { + + long start = System.currentTimeMillis(); + AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null); + List list = new ArrayList(); + try { + List resultList = dashboardService.getTotalReportList(); + if (resultList!=null&&resultList.size() > 0) { + list = resultList; + } + } catch (Exception e) { + e.printStackTrace(); + auditLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause()); + logger.error(e); + if (!(e instanceof RestServiceException)) { + e = new RestServiceException(auditLogThread, System.currentTimeMillis() - start, "业务总量汇聚实时统计数据检索失败"); + } + throw ((RestServiceException) e); + } + return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "业务总量汇聚实时统计数据检索成功",list, 0); + } + /** + * 流量统计活跃端口统计 + */ + @RequestMapping(value = "trafficPortActive", method = RequestMethod.GET) + @ApiOperation(value = "活跃端口统计", httpMethod = "GET", notes = "对应流量统计活跃端口统计") + public Map trafficPortActive(Model model, HttpServletRequest request, HttpServletResponse response) { + + long start = System.currentTimeMillis(); + AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null); + List list = new ArrayList(); + try { + List resultList = dashboardService.getPortActiveList(); + + if (resultList!=null&&resultList.size() > 0) { + for (TrafficPortActiveStatistic port : resultList) { + Map map = new HashMap(); + + map.put("port", port.getPort()); + map.put("sum", port.getSum()); + list.add(map); + } + } + } catch (Exception e) { + e.printStackTrace(); + auditLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause()); + logger.error(e); + if (!(e instanceof RestServiceException)) { + e = new RestServiceException(auditLogThread, System.currentTimeMillis() - start, "活跃端口实时统计数据检索失败"); + } + throw ((RestServiceException) e); + } + return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "活跃端口实时统计数据检索成功",list, 0); + } + /** * 协议统计 @@ -92,7 +154,7 @@ public class DashboardServiceController extends BaseRestController { return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "活跃IP实时统计数据检索成功",list, 0); } /** - * app流量分析 TOP10 + * app应用流量分析 TOP10 */ @RequestMapping(value = "trafficApp", method = RequestMethod.GET) @ApiOperation(value = "app流量分析统计", httpMethod = "GET", notes = "对应app流量分析实时统计查询服务。") @@ -215,7 +277,8 @@ public class DashboardServiceController extends BaseRestController { AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null); List list = new ArrayList(); try { - List websiteChart = dashboardService.websiteList(); +// List websiteChart = dashboardService.websiteList(); + List websiteChart = dashboardService.getDomainByWebsiteList(); if (websiteChart.size() > 0) { list = websiteChart; } @@ -232,13 +295,13 @@ public class DashboardServiceController extends BaseRestController { } @RequestMapping(value = "trafficWebTypeChart", method = RequestMethod.GET) @ApiOperation(value = "http网站分类分析统计", httpMethod = "GET", notes = "对应某个网站类型分类统计图") - public Map trafficWebTypeChart(Integer webId,Model model, HttpServletRequest request, HttpServletResponse response) { + public Map trafficWebTypeChart(Integer websiteServiceId,Model model, HttpServletRequest request, HttpServletResponse response) { long start = System.currentTimeMillis(); AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null); List list = new ArrayList(); try { - List websiteChart = dashboardService.getTypeBywebsite(webId); + List websiteChart = dashboardService.getDomainByWebsiteServiceId(websiteServiceId); if (websiteChart.size() > 0) { list = websiteChart; } @@ -253,4 +316,27 @@ public class DashboardServiceController extends BaseRestController { } return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "http网站分类分析数据检索成功",list, 0); } + @RequestMapping(value = "trafficTopicAndDomainChart", method = RequestMethod.GET) + @ApiOperation(value = "http网站主题分类分析统计", httpMethod = "GET", notes = "对应某个网站主题类型分类统计图") + public Map trafficTopicAndDomainChart(Integer websiteServiceId,Model model, HttpServletRequest request, HttpServletResponse response) { + + long start = System.currentTimeMillis(); + AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null); + List list = new ArrayList(); + try { + List websiteChart = dashboardService.getTopicAndDomainList(); + if (websiteChart.size() > 0) { + list = websiteChart; + } + } catch (Exception e) { + e.printStackTrace(); + auditLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause()); + logger.error(e); + if (!(e instanceof RestServiceException)) { + e = new RestServiceException(auditLogThread, System.currentTimeMillis() - start, "http网站主题分类分析数据检索失败"); + } + throw ((RestServiceException) e); + } + return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "http网站主题分类分析数据检索成功",list, 0); + } } diff --git a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java new file mode 100644 index 0000000..052222e --- /dev/null +++ b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java @@ -0,0 +1,11 @@ +package com.nis.web.dao.dashboard; + +import java.util.List; +import java.util.Map; + +import com.nis.web.dao.MyBatisDao; +@MyBatisDao +public interface NtcTotalReportDao { + + List getTotalReportList(); +} \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml new file mode 100644 index 0000000..d1db7af --- /dev/null +++ b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml @@ -0,0 +1,24 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.xml b/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.xml index 5b9b810..58d7348 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.xml @@ -16,8 +16,9 @@ stat_time \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.java b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.java index 7fca504..5d909e2 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.java @@ -10,10 +10,14 @@ import com.nis.web.dao.MyBatisDao; @MyBatisDao public interface TrafficHttpStatisticDao { List websiteList(); - - List getTypeBywebsite(@Param("webId") Integer webId); - Map websiteTypeOthers(@Param("webType") List webType,@Param("webId") Integer webId); - + //获取域名分类之后属于的网站 + List getDomainByWebsiteList(); Integer preWebsiteListCount(@Param("webId") Integer webId); + List getDomainByWebsiteServiceId(@Param("websiteServiceId") Integer websiteServiceId); + Map websiteDomainOthers(@Param("webIdList") List webIdList,@Param("websiteServiceId") Integer websiteServiceId); + + List getDomainByTopicList(); + + List getDomainByTopicId(@Param("topicId")Object TopicId); } \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml index a2db696..6d37288 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml @@ -3,7 +3,7 @@ - + @@ -15,34 +15,64 @@ stat_id, web_type, web_id, c2s_pkt_num, s2c_pkt_num, c2s_byte_len, s2c_byte_len, stat_time + + + + + - + SELECT web_id webId,link_num count,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen + FROM galaxy.traffic_http_statistic t + LEFT JOIN galaxy.ui_website_domain_topic u ON t.web_id=u.id + where u.website_service_id=#{websiteServiceId} + and t.stat_time >= DATE_SUB((SELECT MAX(stat_time) FROM galaxy.traffic_http_statistic),INTERVAL 5 MINUTE) + GROUP BY t.web_id ORDER BY t.link_num limit 0,10 - - - - + SELECT web_id webId,link_num count,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen + FROM galaxy.traffic_http_statistic t + LEFT JOIN galaxy.ui_website_domain_topic u ON t.web_id=u.id + where u.topic_id=#{topicId} + and t.stat_time >= DATE_SUB((SELECT MAX(stat_time) FROM galaxy.traffic_http_statistic),INTERVAL 5 MINUTE) + GROUP BY t.web_id ORDER BY t.link_num limit 0,10 + - + SELECT SUM(link_num) count ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.traffic_http_statistic t + LEFT JOIN galaxy.ui_website_domain_topic u ON t.web_id=u.id + where u.website_service_id=#{websiteServiceId} + + and t.web_id not in + #{singleType} - and stat_time >= DATE_SUB(NOW(),INTERVAL 5 MINUTE) + and stat_time >= DATE_SUB((SELECT MAX(stat_time) FROM galaxy.traffic_http_statistic),INTERVAL 5 MINUTE) \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficIpActiveStatisticDao.xml b/src/main/java/com/nis/web/dao/dashboard/TrafficIpActiveStatisticDao.xml index 3c6e416..fc311f5 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficIpActiveStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficIpActiveStatisticDao.xml @@ -26,7 +26,7 @@ diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficPortActiveStatisticDao.java b/src/main/java/com/nis/web/dao/dashboard/TrafficPortActiveStatisticDao.java new file mode 100644 index 0000000..bf02dfe --- /dev/null +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficPortActiveStatisticDao.java @@ -0,0 +1,12 @@ +package com.nis.web.dao.dashboard; + +import java.util.List; +import java.util.Map; + +import com.nis.domain.restful.dashboard.TrafficPortActiveStatistic; +import com.nis.web.dao.MyBatisDao; +@MyBatisDao +public interface TrafficPortActiveStatisticDao { + + List getPortActiveList(); +} \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficPortActiveStatisticDao.xml b/src/main/java/com/nis/web/dao/dashboard/TrafficPortActiveStatisticDao.xml new file mode 100644 index 0000000..ef418ad --- /dev/null +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficPortActiveStatisticDao.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.xml b/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.xml index f12e4ab..d30a2ec 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficProtocolStatisticDao.xml @@ -16,6 +16,7 @@ stat_time \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficUaStatisticDao.xml b/src/main/java/com/nis/web/dao/dashboard/TrafficUaStatisticDao.xml index ac8713b..2d6ffb2 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficUaStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficUaStatisticDao.xml @@ -18,25 +18,25 @@ \ No newline at end of file diff --git a/src/main/java/com/nis/web/service/restful/DashboardService.java b/src/main/java/com/nis/web/service/restful/DashboardService.java index a84fe70..cdbf179 100644 --- a/src/main/java/com/nis/web/service/restful/DashboardService.java +++ b/src/main/java/com/nis/web/service/restful/DashboardService.java @@ -12,10 +12,13 @@ import org.springframework.stereotype.Service; import com.nis.domain.Page; import com.nis.domain.restful.dashboard.TrafficHttpStatistic; import com.nis.domain.restful.dashboard.TrafficIpActiveStatistic; +import com.nis.domain.restful.dashboard.TrafficPortActiveStatistic; import com.nis.domain.restful.dashboard.TrafficUaStatistic; +import com.nis.web.dao.dashboard.NtcTotalReportDao; import com.nis.web.dao.dashboard.TrafficAppStatisticDao; import com.nis.web.dao.dashboard.TrafficHttpStatisticDao; import com.nis.web.dao.dashboard.TrafficIpActiveStatisticDao; +import com.nis.web.dao.dashboard.TrafficPortActiveStatisticDao; import com.nis.web.dao.dashboard.TrafficProtocolStatisticDao; import com.nis.web.dao.dashboard.TrafficUaStatisticDao; import com.nis.web.service.BaseService; @@ -33,6 +36,25 @@ public class DashboardService extends BaseService{ public TrafficUaStatisticDao trafficUaStatisticDao; @Autowired public TrafficHttpStatisticDao trafficHttpStatisticDao; + @Autowired + public NtcTotalReportDao ntcTotalReportDao; + @Autowired + public TrafficPortActiveStatisticDao trafficPortActiveStatisticDao; + + /** + * 流量统计 数据显示 + * @return Map + */ + public List getTotalReportList(){ + List totalReportList = ntcTotalReportDao.getTotalReportList(); + + return totalReportList; + } + public List getPortActiveList(){ + List portActiveList = trafficPortActiveStatisticDao.getPortActiveList(); + + return portActiveList; + } /** * 分页查询活跃IPtop100 @@ -108,19 +130,21 @@ public class DashboardService extends BaseService{ List result = new ArrayList(); List list = trafficUaStatisticDao.browserList(); Integer preCount=0; - for (TrafficUaStatistic ua : list) { - Map map = new HashMap(); - map.put("bsType",ua.getBsType()); - map.put("count",ua.getCount()); - map.put("pktNum",ua.getPktNum()); - map.put("byteLen",ua.getByteLen()); - preCount = trafficUaStatisticDao.preBrowserListCount(ua.getBsType());//上个时段的量 用于与现在对比 - if(preCount!=null){ - map.put("preCount",preCount); - }else{ - map.put("preCount",0); + if(list!=null&&list.size()>0){ + for (TrafficUaStatistic ua : list) { + Map map = new HashMap(); + map.put("bsType",ua.getBsType()); + map.put("count",ua.getCount()); + map.put("pktNum",ua.getPktNum()); + map.put("byteLen",ua.getByteLen()); + preCount = trafficUaStatisticDao.preBrowserListCount(ua.getBsType());//上个时段的量 用于与现在对比 + if(preCount!=null){ + map.put("preCount",preCount); + }else{ + map.put("preCount",0); + } + result.add(map); } - result.add(map); } return result; } @@ -145,37 +169,91 @@ public class DashboardService extends BaseService{ List result = new ArrayList(); List list = trafficHttpStatisticDao.websiteList(); Integer preCount=0; - for (TrafficHttpStatistic website : list) { - Map map = new HashMap(); - map.put("webId",website.getWebId()); - map.put("count",website.getCount()); - map.put("pktNum",website.getPktNum()); - map.put("byteLen",website.getByteLen()); - preCount = trafficHttpStatisticDao.preWebsiteListCount(website.getWebId());//上个时段的量 用于与现在对比 - if(preCount!=null){ - map.put("preCount",preCount); - }else{ - map.put("preCount",0); + if(list!=null&&list.size()>0){ + for (TrafficHttpStatistic website : list) { + Map map = new HashMap(); + map.put("webId",website.getWebId()); + map.put("count",website.getCount()); + map.put("pktNum",website.getPktNum()); + map.put("byteLen",website.getByteLen()); + preCount = trafficHttpStatisticDao.preWebsiteListCount(website.getWebId());//上个时段的量 用于与现在对比 + if(preCount!=null){ + map.put("preCount",preCount); + }else{ + map.put("preCount",0); + } + result.add(map); } - result.add(map); } return result; } - public List getTypeBywebsite(Integer webId ){ - List list = trafficHttpStatisticDao.getTypeBywebsite(webId); - List webType = new ArrayList(); - //查询固定网站下的除了TOP10以外的others分类 + /** + * 根据网站服务查询子域名 + * @param websiteServiceId + * @return list + */ + public List getDomainByWebsiteServiceId(Integer websiteServiceId ){ + List list = trafficHttpStatisticDao.getDomainByWebsiteServiceId(websiteServiceId); + List webIdList = new ArrayList(); + //查询固定网站下的域名除了TOP10以外的others域名 if(list!=null&& list.size()>0){ for (Map map : list) { - webType.add(map.get("webType")); + webIdList.add(map.get("webId")); } Map others = new HashMap(); - others = trafficHttpStatisticDao.websiteTypeOthers(webType,webId); + others = trafficHttpStatisticDao.websiteDomainOthers(webIdList,websiteServiceId); if(others!=null&&others.size()>0){ - others.put("webType", "-1"); + others.put("webId", "-1"); list.add(others); } } return list; } + + /** + 获取网站列表 + * @return + */ + @SuppressWarnings("unchecked") + public List getDomainByWebsiteList(){ + List websiteList = trafficHttpStatisticDao.getDomainByWebsiteList(); + List result = new ArrayList(); + if(websiteList!=null&&websiteList.size()>0){ + Integer preCount=0; + for (TrafficHttpStatistic website : websiteList) { + Map map = new HashMap(); + map.put("websiteServiceId",website.getWesiteServiceId()); + map.put("count",website.getCount()); + map.put("pktNum",website.getPktNum()); + map.put("byteLen",website.getByteLen()); + preCount = trafficHttpStatisticDao.preWebsiteListCount(website.getWebId());//上个时段的量 用于与现在对比 + if(preCount!=null){ + map.put("preCount",preCount); + }else{ + map.put("preCount",0); + } + result.add(map); + } + } + + return result; + } + /** + *主题网站分类,域名 + * + * **/ + public List getTopicAndDomainList(){ + //按照主题分类 获得主题 + List topicList = trafficHttpStatisticDao.getDomainByTopicList(); + if(topicList!=null&&topicList.size()>0){ + for (Map m : topicList) { + List domainList= new ArrayList(); + if(m!=null&&m.get("topicId")!=null){ + domainList = trafficHttpStatisticDao.getDomainByTopicId(m.get("topicId")); + m.put("domainData", domainList); + } + } + } + return topicList; + } } From 7051a8aaaf32e3c1898c32a50a96b3ec51db713a Mon Sep 17 00:00:00 2001 From: zhanghongqing Date: Tue, 25 Sep 2018 11:03:14 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E6=B5=81=E9=87=8F=E7=BB=9F=E8=AE=A1=20?= =?UTF-8?q?=E7=BD=91=E7=AB=99=E7=BB=9F=E8=AE=A1sql=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/TrafficHttpStatisticDao.java | 2 +- .../dao/dashboard/TrafficHttpStatisticDao.xml | 20 ++++++++++--------- .../dashboard/TrafficIpActiveStatisticDao.xml | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.java b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.java index 5d909e2..3c2ff0c 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.java @@ -13,7 +13,7 @@ public interface TrafficHttpStatisticDao { //获取域名分类之后属于的网站 List getDomainByWebsiteList(); - Integer preWebsiteListCount(@Param("webId") Integer webId); + Integer preWebsiteListCount(@Param("websiteServiceId") Integer websiteServiceId); List getDomainByWebsiteServiceId(@Param("websiteServiceId") Integer websiteServiceId); Map websiteDomainOthers(@Param("webIdList") List webIdList,@Param("websiteServiceId") Integer websiteServiceId); diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml index 6d37288..6722b39 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml @@ -19,28 +19,30 @@ SELECT SUM(link_num) count, IFNULL( website_service_id, 268435455 ) websiteServiceId ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.TRAFFIC_HTTP_STATISTIC t LEFT JOIN galaxy.ui_website_domain_topic u ON t.web_id = u.id - and stat_time between DATE_SUB((SELECT MAX(stat_time) FROM galaxy.traffic_http_statistic),INTERVAL 10 MINUTE) and DATE_SUB(NOW(),INTERVAL 5 MINUTE) - GROUP BY u.website_service_id ORDER BY t.link_num limit 0,10 + + and t.stat_time >= DATE_SUB((SELECT MAX(stat_time) FROM galaxy.traffic_http_statistic),INTERVAL 5 MINUTE) + GROUP BY u.website_service_id ORDER BY count limit 0,10 @@ -50,7 +52,7 @@ LEFT JOIN galaxy.ui_website_domain_topic u ON t.web_id=u.id where u.website_service_id=#{websiteServiceId} and t.stat_time >= DATE_SUB((SELECT MAX(stat_time) FROM galaxy.traffic_http_statistic),INTERVAL 5 MINUTE) - GROUP BY t.web_id ORDER BY t.link_num limit 0,10 + GROUP BY t.web_id ORDER BY count limit 0,10 diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficIpActiveStatisticDao.xml b/src/main/java/com/nis/web/dao/dashboard/TrafficIpActiveStatisticDao.xml index fc311f5..57a4db1 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficIpActiveStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficIpActiveStatisticDao.xml @@ -27,7 +27,7 @@ \ No newline at end of file From 9937dc1f8a5f4e5cfba1db8e7a92520ed9706cca Mon Sep 17 00:00:00 2001 From: zhangdongxu Date: Tue, 25 Sep 2018 11:54:39 +0800 Subject: [PATCH 03/12] =?UTF-8?q?APP=E7=89=B9=E5=BE=81=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../restful/SingleDimensionReport.java | 2 +- .../applicationConfig-rule.properties | 26 +++++++++---------- .../applicationConfig-rule.test.properties | 26 +++++++++---------- .../applicationConfig-rule.ysp.properties | 26 +++++++++---------- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/nis/web/controller/restful/SingleDimensionReport.java b/src/main/java/com/nis/web/controller/restful/SingleDimensionReport.java index 3e8b7bd..675c68f 100644 --- a/src/main/java/com/nis/web/controller/restful/SingleDimensionReport.java +++ b/src/main/java/com/nis/web/controller/restful/SingleDimensionReport.java @@ -364,7 +364,7 @@ public class SingleDimensionReport extends BaseRestController { */ public void resetReportTime(NtcReportEntity entity,Boolean isTotal) throws Exception { //日志总量统计查询全部 - if ("1".equals(entity.getSearchBusinessType())) { + if ("1".equals(entity.getSearchBusinessType())&&isTotal) { return ; } if (StringUtil.isEmpty(entity.getSearchReportStartTime())&&StringUtil.isEmpty(entity.getSearchReportEndTime())) { diff --git a/src/main/resources/applicationConfig-rule.properties b/src/main/resources/applicationConfig-rule.properties index 873fd60..926a192 100644 --- a/src/main/resources/applicationConfig-rule.properties +++ b/src/main/resources/applicationConfig-rule.properties @@ -176,19 +176,19 @@ service=1:128;2:128;16:16;17:16;18:16;19:16;20:16;21:16;22:16;23:16;24:16;26:16; 768=10:IR_POLICY_COMPILE;11:IR_POLICY_GROUP;12:IR_POLICY_IP;14:NTC_SUBSCRIBE_ID;18:NTC_IP_RANGE #0x400 APP HTTP特征发现 -1024=10:APP_COMPILE;11:APP_GROUP;14:APP_SUBSCRIBE_ID;15:APP_HTTP;18:NTC_IP_RANGE -#0x401 APP载荷特征表 -1025=10:APP_COMPILE;11:APP_GROUP;12:APP_IP_RANGE;14:APP_SUBSCRIBE_ID;15:APP_PAYLOAD;18:NTC_IP_RANGE -#0x402 APP DOMAIN特征发现 -1026=10:APP_COMPILE;11:APP_GROUP;14:APP_DOMAIN,APP_SUBSCRIBE_ID;18:NTC_IP_RANGE -#0x403 APP DNS特征匹配 -1027=10:APP_COMPILE;11:APP_GROUP;14:APP_SUBSCRIBE_ID;15:APP_DNS;18:NTC_IP_RANGE -#0x404 APP IP特征 -1028=10:APP_COMPILE;11:APP_GROUP;12:APP_STATIC_SEV_IP;14:APP_SUBSCRIBE_ID;18:NTC_IP_RANGE -#0x405 APP SSL特征 -1029=10:APP_COMPILE;11:APP_GROUP;12:APP_IP_RANGE;14:APP_SUBSCRIBE_ID;15:APP_SSL;18:NTC_IP_RANGE -#0x406 APP多用途标签 -1030=10:APP_COMPILE;11:APP_GROUP;14:APP_SUBSCRIBE_ID;15:APP_DK_GL;18:NTC_IP_RANGE +1024=10:APP_COMPILE;11:APP_GROUP;15:APP_HTTP;12:APP_IP_RANGE +#0x401 APP载荷特征表 +1025=10:APP_COMPILE;11:APP_GROUP;12:APP_IP_RANGE;15:APP_PAYLOAD +#0x402 APP DOMAIN特征发现 +1026=10:APP_COMPILE;11:APP_GROUP;14:APP_DOMAIN +#0x403 APP DNS特征匹配 +1027=10:APP_COMPILE;11:APP_GROUP;15:APP_DNS +#0x404 APP IP特征 +1028=10:APP_COMPILE;11:APP_GROUP;12:APP_STATIC_SEV_IP +#0x405 APP SSL特征 +1029=10:APP_COMPILE;11:APP_GROUP;12:APP_IP_RANGE;15:APP_SSL +#0x406 APP多用途标签 +1030=10:APP_COMPILE;11:APP_GROUP;14:APP_DK_GL #0x410 APP丢弃 1040=10:APP_COMPILE;11:APP_GROUP;12:NTC_UNIVERSAL_IP;13:NTC_UNIVERSAL_PROTO_TYPE;14:APP_POLICY,APP_SUBSCRIBE_ID;18:NTC_IP_RANGE diff --git a/src/main/resources/applicationConfig-rule.test.properties b/src/main/resources/applicationConfig-rule.test.properties index bbd62c2..583941a 100644 --- a/src/main/resources/applicationConfig-rule.test.properties +++ b/src/main/resources/applicationConfig-rule.test.properties @@ -176,19 +176,19 @@ service=1:128;2:128;16:16;17:16;18:16;19:16;20:16;21:16;22:16;23:16;24:16;26:16; 768=10:IR_POLICY_COMPILE;11:IR_POLICY_GROUP;12:IR_POLICY_IP;14:NTC_SUBSCRIBE_ID;18:NTC_IP_RANGE #0x400 APP HTTP特征发现 -1024=10:APP_COMPILE;11:APP_GROUP;14:APP_SUBSCRIBE_ID;15:APP_HTTP;18:NTC_IP_RANGE -#0x401 APP载荷特征表 -1025=10:APP_COMPILE;11:APP_GROUP;12:APP_IP_RANGE;14:APP_SUBSCRIBE_ID;15:APP_PAYLOAD;18:NTC_IP_RANGE -#0x402 APP DOMAIN特征发现 -1026=10:APP_COMPILE;11:APP_GROUP;14:APP_DOMAIN,APP_SUBSCRIBE_ID;18:NTC_IP_RANGE -#0x403 APP DNS特征匹配 -1027=10:APP_COMPILE;11:APP_GROUP;14:APP_SUBSCRIBE_ID;15:APP_DNS;18:NTC_IP_RANGE -#0x404 APP IP特征 -1028=10:APP_COMPILE;11:APP_GROUP;12:APP_STATIC_SEV_IP;14:APP_SUBSCRIBE_ID;18:NTC_IP_RANGE -#0x405 APP SSL特征 -1029=10:APP_COMPILE;11:APP_GROUP;12:APP_IP_RANGE;14:APP_SUBSCRIBE_ID;15:APP_SSL;18:NTC_IP_RANGE -#0x406 APP多用途标签 -1030=10:APP_COMPILE;11:APP_GROUP;14:APP_SUBSCRIBE_ID;15:APP_DK_GL;18:NTC_IP_RANGE +1024=10:APP_COMPILE;11:APP_GROUP;15:APP_HTTP;12:APP_IP_RANGE +#0x401 APP载荷特征表 +1025=10:APP_COMPILE;11:APP_GROUP;12:APP_IP_RANGE;15:APP_PAYLOAD +#0x402 APP DOMAIN特征发现 +1026=10:APP_COMPILE;11:APP_GROUP;14:APP_DOMAIN +#0x403 APP DNS特征匹配 +1027=10:APP_COMPILE;11:APP_GROUP;15:APP_DNS +#0x404 APP IP特征 +1028=10:APP_COMPILE;11:APP_GROUP;12:APP_STATIC_SEV_IP +#0x405 APP SSL特征 +1029=10:APP_COMPILE;11:APP_GROUP;12:APP_IP_RANGE;15:APP_SSL +#0x406 APP多用途标签 +1030=10:APP_COMPILE;11:APP_GROUP;14:APP_DK_GL #0x410 APP丢弃 1040=10:APP_COMPILE;11:APP_GROUP;12:NTC_UNIVERSAL_IP;13:NTC_UNIVERSAL_PROTO_TYPE;14:APP_POLICY,APP_SUBSCRIBE_ID;18:NTC_IP_RANGE diff --git a/src/main/resources/applicationConfig-rule.ysp.properties b/src/main/resources/applicationConfig-rule.ysp.properties index 26bd007..e560940 100644 --- a/src/main/resources/applicationConfig-rule.ysp.properties +++ b/src/main/resources/applicationConfig-rule.ysp.properties @@ -176,19 +176,19 @@ service=1:128;2:128;16:16;17:16;18:16;19:16;20:16;21:16;22:16;23:16;24:16;26:16; 768=10:IR_POLICY_COMPILE;11:IR_POLICY_GROUP;12:IR_POLICY_IP;14:NTC_SUBSCRIBE_ID;18:NTC_IP_RANGE #0x400 APP HTTP特征发现 -1024=10:APP_COMPILE;11:APP_GROUP;14:APP_SUBSCRIBE_ID;15:APP_HTTP;18:NTC_IP_RANGE -#0x401 APP载荷特征表 -1025=10:APP_COMPILE;11:APP_GROUP;12:APP_IP_RANGE;14:APP_SUBSCRIBE_ID;15:APP_PAYLOAD;18:NTC_IP_RANGE -#0x402 APP DOMAIN特征发现 -1026=10:APP_COMPILE;11:APP_GROUP;14:APP_DOMAIN,APP_SUBSCRIBE_ID;18:NTC_IP_RANGE -#0x403 APP DNS特征匹配 -1027=10:APP_COMPILE;11:APP_GROUP;14:APP_SUBSCRIBE_ID;15:APP_DNS;18:NTC_IP_RANGE -#0x404 APP IP特征 -1028=10:APP_COMPILE;11:APP_GROUP;12:APP_STATIC_SEV_IP;14:APP_SUBSCRIBE_ID;18:NTC_IP_RANGE -#0x405 APP SSL特征 -1029=10:APP_COMPILE;11:APP_GROUP;12:APP_IP_RANGE;14:APP_SUBSCRIBE_ID;15:APP_SSL;18:NTC_IP_RANGE -#0x406 APP多用途标签 -1030=10:APP_COMPILE;11:APP_GROUP;14:APP_SUBSCRIBE_ID;15:APP_DK_GL;18:NTC_IP_RANGE +1024=10:APP_COMPILE;11:APP_GROUP;15:APP_HTTP;12:APP_IP_RANGE +#0x401 APP载荷特征表 +1025=10:APP_COMPILE;11:APP_GROUP;12:APP_IP_RANGE;15:APP_PAYLOAD +#0x402 APP DOMAIN特征发现 +1026=10:APP_COMPILE;11:APP_GROUP;14:APP_DOMAIN +#0x403 APP DNS特征匹配 +1027=10:APP_COMPILE;11:APP_GROUP;15:APP_DNS +#0x404 APP IP特征 +1028=10:APP_COMPILE;11:APP_GROUP;12:APP_STATIC_SEV_IP +#0x405 APP SSL特征 +1029=10:APP_COMPILE;11:APP_GROUP;12:APP_IP_RANGE;15:APP_SSL +#0x406 APP多用途标签 +1030=10:APP_COMPILE;11:APP_GROUP;14:APP_DK_GL #0x410 APP丢弃 1040=10:APP_COMPILE;11:APP_GROUP;12:NTC_UNIVERSAL_IP;13:NTC_UNIVERSAL_PROTO_TYPE;14:APP_POLICY,APP_SUBSCRIBE_ID;18:NTC_IP_RANGE From ebd2932596b94b01fd16eca27f837f903cd7f7d1 Mon Sep 17 00:00:00 2001 From: RenKaiGe-Office Date: Tue, 25 Sep 2018 18:06:49 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9nms=E4=B8=8A=E6=8A=A5?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=94=AF=E6=8C=81=E6=89=B9=E9=87=8F=E6=8F=90?= =?UTF-8?q?=E4=BA=A4,=E4=BF=AE=E6=94=B9=E4=B8=BA=E9=98=80=E9=97=A8?= =?UTF-8?q?=E4=B8=AD=E5=9F=9F=E6=B7=BB=E5=8A=A0=E9=A2=9D=E5=A4=96=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E6=97=B6=E7=9A=84=E9=98=80=E9=97=A8=E5=BA=93=E7=BC=96?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TrafficNmsServerStatisticList.java | 31 ++++++++++++++++++ .../controller/restful/NmsInfoController.java | 32 ++++++++----------- .../restful/ConfigJedisServiceimpl.java | 2 +- .../TrafficNmsServerStatisticService.java | 21 ++++++------ src/main/resources/nis.properties | 3 +- 5 files changed, 57 insertions(+), 32 deletions(-) create mode 100644 src/main/java/com/nis/domain/restful/TrafficNmsServerStatisticList.java diff --git a/src/main/java/com/nis/domain/restful/TrafficNmsServerStatisticList.java b/src/main/java/com/nis/domain/restful/TrafficNmsServerStatisticList.java new file mode 100644 index 0000000..101bfa5 --- /dev/null +++ b/src/main/java/com/nis/domain/restful/TrafficNmsServerStatisticList.java @@ -0,0 +1,31 @@ +package com.nis.domain.restful; + +import java.io.Serializable; +import java.util.List; + +import com.wordnik.swagger.annotations.ApiModel; + +/** + * + *

Title: TrafficNmsServerStatistic

+ *

Description: 记录nms服务器信息,全网机器总量,正常在线机器总数,异常机器列表

+ *

Company: IIE

+ * @author rkg + * @date 2018年8月17日 + * + */ +@ApiModel(value = "TrafficNmsServerStatistic对象", description = "nms上报的服务器相关信息对象类") +public class TrafficNmsServerStatisticList implements Serializable { + private static final long serialVersionUID = 1L; + + private List trafficNmsServerList; + + public List getTrafficNmsServerList() { + return trafficNmsServerList; + } + + public void setTrafficNmsServerList(List trafficNmsServerList) { + this.trafficNmsServerList = trafficNmsServerList; + } + +} diff --git a/src/main/java/com/nis/web/controller/restful/NmsInfoController.java b/src/main/java/com/nis/web/controller/restful/NmsInfoController.java index f2bca8f..7523cef 100644 --- a/src/main/java/com/nis/web/controller/restful/NmsInfoController.java +++ b/src/main/java/com/nis/web/controller/restful/NmsInfoController.java @@ -1,21 +1,19 @@ package com.nis.web.controller.restful; -import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import com.nis.domain.restful.TrafficNmsServerStatistic; +import com.nis.domain.restful.TrafficNmsServerStatisticList; import com.nis.restful.RestBusinessCode; -import com.nis.restful.RestConstants; import com.nis.restful.RestServiceException; import com.nis.util.Constants; import com.nis.web.controller.BaseRestController; @@ -38,30 +36,28 @@ public class NmsInfoController extends BaseRestController { @RequestMapping(value = "/nms/v1/saveServerStatus", method = RequestMethod.POST) @ApiOperation(value = "存储NMS系统上报的服务器状态接口", httpMethod = "POST", response = Map.class, notes = "接收NMS系统上报的服务器状态信息") @ApiParam(value = "存储NMS系统上报的服务器状态接口", name = "saveServerStatus", required = true) - public Map saveServerStatus(@RequestBody TrafficNmsServerStatistic trafficNmsServerStatistic, - HttpServletRequest request, HttpServletResponse response) { + public Map saveServerStatus( + @RequestBody TrafficNmsServerStatisticList trafficNmsServerStatisticList, HttpServletRequest request, + HttpServletResponse response) { long start = System.currentTimeMillis(); AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request, - trafficNmsServerStatistic); - - Map map = new HashMap(); - map.put(RestConstants.REST_SERVICE_HTTP_STATUS, HttpStatus.OK); + trafficNmsServerStatisticList); try { - TrafficNmsServerStatistic saveNmsServer = trafficNmsServerStatisticService - .saveNmsServer(trafficNmsServerStatistic); - try { - trafficNmsServerStatisticService.saveAbnormalMachine(saveNmsServer.getId(), - saveNmsServer.getAbnormalMachineList()); - } catch (Exception e) { - trafficNmsServerStatisticService.delNmsServer(saveNmsServer); - throw e; + + if (trafficNmsServerStatisticList != null && trafficNmsServerStatisticList.getTrafficNmsServerList() != null + && trafficNmsServerStatisticList.getTrafficNmsServerList().size() > 0) { + trafficNmsServerStatisticService.saveNmsInfo(trafficNmsServerStatisticList.getTrafficNmsServerList()); + } else { + throw new RestServiceException(thread, System.currentTimeMillis() - start, "参数trafficNmsServerList不能为空", + RestBusinessCode.missing_args.getValue()); } + } catch (Exception e) { throw new RestServiceException(thread, System.currentTimeMillis() - start, "上报服务器状态信息异常:" + e.getMessage(), RestBusinessCode.unknow_error.getValue()); } return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "上报服务器状态信息成功", - Constants.IS_DEBUG ? trafficNmsServerStatistic : null); + Constants.IS_DEBUG ? trafficNmsServerStatisticList : null); } } diff --git a/src/main/java/com/nis/web/service/restful/ConfigJedisServiceimpl.java b/src/main/java/com/nis/web/service/restful/ConfigJedisServiceimpl.java index 8178a8c..9465244 100644 --- a/src/main/java/com/nis/web/service/restful/ConfigJedisServiceimpl.java +++ b/src/main/java/com/nis/web/service/restful/ConfigJedisServiceimpl.java @@ -32,7 +32,7 @@ import redis.clients.jedis.exceptions.JedisConnectionException; @Service() public class ConfigJedisServiceimpl implements ConfigRedisService { private static Logger logger = LoggerFactory.getLogger(ConfigJedisServiceimpl.class); - private static final int TAPREDISDB = Configurations.getIntProperty("tapRedisDb", 7); + private static final int TAPREDISDB = Configurations.getIntProperty("tapRedisDb", 5); // 用于在实时统计配置后面添加时间,方便读取入库时间 private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); diff --git a/src/main/java/com/nis/web/service/restful/TrafficNmsServerStatisticService.java b/src/main/java/com/nis/web/service/restful/TrafficNmsServerStatisticService.java index 4fe2b2c..93ca9b8 100644 --- a/src/main/java/com/nis/web/service/restful/TrafficNmsServerStatisticService.java +++ b/src/main/java/com/nis/web/service/restful/TrafficNmsServerStatisticService.java @@ -4,8 +4,8 @@ import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; -import com.nis.domain.restful.AbnormalMachine; import com.nis.domain.restful.TrafficNmsServerStatistic; import com.nis.web.dao.TrafficNmsServerStatisticDao; @@ -14,16 +14,13 @@ public class TrafficNmsServerStatisticService { @Autowired TrafficNmsServerStatisticDao trafficNmsServerStatisticDao; - public TrafficNmsServerStatistic saveNmsServer(TrafficNmsServerStatistic trafficNmsServerStatistic) { - trafficNmsServerStatisticDao.insert(trafficNmsServerStatistic); - return trafficNmsServerStatistic; - } - - public void saveAbnormalMachine(Integer id, List abnormalMachineList) { - trafficNmsServerStatisticDao.insertAbnormalMachine(id, abnormalMachineList); - } - - public void delNmsServer(TrafficNmsServerStatistic trafficNmsServerStatistic) { - trafficNmsServerStatisticDao.delete(trafficNmsServerStatistic); + @Transactional + public void saveNmsInfo(List trafficNmsServerList) { + for (TrafficNmsServerStatistic trafficNmsServerStatistic : trafficNmsServerList) { + trafficNmsServerStatisticDao.insert(trafficNmsServerStatistic); + trafficNmsServerStatisticDao.insertAbnormalMachine(trafficNmsServerStatistic.getId(), + trafficNmsServerStatistic.getAbnormalMachineList()); + } + Integer.parseInt(null); } } diff --git a/src/main/resources/nis.properties b/src/main/resources/nis.properties index 94f9fae..909fbb0 100644 --- a/src/main/resources/nis.properties +++ b/src/main/resources/nis.properties @@ -197,7 +197,7 @@ idRelaRedisDBIndex=15 #存储分组复用域配置的redisdb tmpStorageReuseRegionDB=15 ##阀门配置在redisdb的序号 -tapRedisDb=7 +tapRedisDb=5 ##实时统计(编译配置)数据表达式 redisStatisticsReal=[COMPILE_ID];\t;[SERVICE];\t;[ACTION];\t;[CONT_TYPE];\t;[ATTR_TYPE];\t;[CONT_LABEL];\t;[TASK_ID];\t;[AFFAIR_ID];\t;[DO_BLACKLIST];\t;[DO_LOG];\t;[EFFECTIVE_RANGE];\t;[START_TIME];\t;[END_TIME];\t;[USER_REGION];\t;[IS_VALID];\t;[GROUP_NUM];\t;[FATHER_CFG_ID];\t;[OP_TIME] @@ -205,6 +205,7 @@ redisStatisticsReal=[COMPILE_ID];\t;[SERVICE];\t;[ACTION];\t;[CONT_TYPE];\t;[ATT redisStatisticsRealDBIndex=14 #maat测试程序输出日志的文件目录 maatTestLogPath=c:/maat/mmat.log +#maatTestLogPath=/home/maat/mmat.log #样例文件存放目录,{tableType}和{fileName}会替换成具体内容 mmSampleDstPath=/home/mesasoft/{tableType}/full/{fileName} From e47e60e4c0c056da6492f22168b8415f2640aaa5 Mon Sep 17 00:00:00 2001 From: zhanghongqing Date: Wed, 26 Sep 2018 09:17:35 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BD=91=E7=AB=99?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml index 6722b39..bb768fe 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml @@ -47,7 +47,7 @@ --> SELECT SUM(reject_num) rejectNum,SUM(monitor_num) monitorNum,SUM(c2s_pkt_num) c2sPktNum,SUM(s2c_pkt_num) s2cPktNum,SUM(c2s_byte_len) c2sByteLen,SUM(s2c_byte_len) s2cByteLen,SUM(new_uni_conn_num) newUniConnNum,SUM(live_conn_num) liveConnNum, SUM(drop_conn_num) dropConnNum,SUM(loop_conn_num) loopConnNum FROM galaxy.ntc_total_report - where report_time >= DATE_SUB((SELECT MAX(report_time) FROM ntc_total_report),INTERVAL 5 MINUTE) + where report_time >= DATE_SUB((SELECT MAX(report_time) FROM galaxy.ntc_total_report),INTERVAL 5 MINUTE) + + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml index bb768fe..2f560bf 100644 --- a/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/TrafficHttpStatisticDao.xml @@ -19,7 +19,6 @@ SELECT SUM(link_num) count, IFNULL( website_service_id, 268435455 ) websiteServiceId ,(SUM(c2s_pkt_num)+SUM(s2c_pkt_num)) pktNum,(SUM(c2s_byte_len)+SUM(s2c_byte_len)) byteLen FROM galaxy.TRAFFIC_HTTP_STATISTIC t LEFT JOIN galaxy.ui_website_domain_topic u ON t.web_id = u.id - and t.stat_time >= DATE_SUB((SELECT MAX(stat_time) FROM galaxy.traffic_http_statistic),INTERVAL 5 MINUTE) GROUP BY u.website_service_id ORDER BY count limit 0,10 diff --git a/src/main/java/com/nis/web/service/restful/DashboardService.java b/src/main/java/com/nis/web/service/restful/DashboardService.java index 68ca65c..6e1faad 100644 --- a/src/main/java/com/nis/web/service/restful/DashboardService.java +++ b/src/main/java/com/nis/web/service/restful/DashboardService.java @@ -47,6 +47,30 @@ public class DashboardService extends BaseService{ */ public List getTotalReportList(){ List totalReportList = ntcTotalReportDao.getTotalReportList(); + //统计带宽的流入流出 单位 五分钟 的 byte + List newData = ntcTotalReportDao.getNetFlowPortInfoNew(); + List oldData = ntcTotalReportDao.getNetFlowPortInfoOld(); + Double inoctets=0d; + Double outoctets=0d; + if(newData!=null&&newData.size()>0&&oldData!=null&&oldData.size()>0&&newData.get(0)!=null&&oldData.get(0)!=null){ + Double newInoctets=Double.parseDouble(newData.get(0).get("inoctets").toString()) ; + Double newOutoctets=Double.parseDouble(newData.get(0).get("outoctets").toString()) ; + Double oldInoctets=Double.parseDouble(oldData.get(0).get("inoctets").toString()); + Double oldOutoctets=Double.parseDouble(oldData.get(0).get("outoctets").toString()); + //结果为当前五分钟减去上个五分钟 + inoctets=newInoctets-oldInoctets; + outoctets=newOutoctets-oldOutoctets; + if(inoctets<0||outoctets<0){ + inoctets=0d; + outoctets=0d; + } + } + if(totalReportList!=null&&totalReportList.size()>0){ + for (Map map : totalReportList) { + map.put("inoctets", inoctets); + map.put("outoctets", outoctets); + } + } return totalReportList; }