增加流量统计带宽流出流入统计

This commit is contained in:
zhanghongqing
2018-09-26 16:29:53 +08:00
parent dbafbea626
commit 59a36d63e1
4 changed files with 36 additions and 2 deletions

View File

@@ -8,4 +8,6 @@ import com.nis.web.dao.MyBatisDao;
public interface NtcTotalReportDao { public interface NtcTotalReportDao {
List<Map> getTotalReportList(); List<Map> getTotalReportList();
List<Map> getNetFlowPortInfoNew();
List<Map> getNetFlowPortInfoOld();
} }

View File

@@ -19,6 +19,15 @@
<select id="getTotalReportList" resultType="java.util.HashMap"> <select id="getTotalReportList" resultType="java.util.HashMap">
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, 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 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)
</select>
<select id="getNetFlowPortInfoNew" resultType="java.util.HashMap">
SELECT SUM(INOCTETS) inoctets ,SUM(OUTOCTETS) outoctets FROM galaxy.TRAFFIC_NETFLOW_PORT_INFO
where RECV_TIME >= DATE_SUB((SELECT MAX(RECV_TIME) FROM galaxy.TRAFFIC_NETFLOW_PORT_INFO),INTERVAL 4 MINUTE)
</select>
<select id="getNetFlowPortInfoOld" resultType="java.util.HashMap">
SELECT SUM(INOCTETS) inoctets ,SUM(OUTOCTETS) outoctets FROM galaxy.TRAFFIC_NETFLOW_PORT_INFO
where RECV_TIME between DATE_SUB((SELECT MAX(RECV_TIME) FROM galaxy.TRAFFIC_NETFLOW_PORT_INFO),INTERVAL 9 MINUTE)
and DATE_SUB((SELECT MAX(RECV_TIME) FROM galaxy.TRAFFIC_NETFLOW_PORT_INFO),INTERVAL 4 MINUTE)
</select> </select>
</mapper> </mapper>

View File

@@ -19,7 +19,6 @@
<select id="getDomainByWebsiteList" resultType="com.nis.domain.restful.dashboard.TrafficHttpStatistic"> <select id="getDomainByWebsiteList" resultType="com.nis.domain.restful.dashboard.TrafficHttpStatistic">
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 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 FROM galaxy.TRAFFIC_HTTP_STATISTIC t
LEFT JOIN galaxy.ui_website_domain_topic u ON t.web_id = u.id
LEFT JOIN galaxy.ui_website_domain_topic u ON t.web_id = u.id 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) 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 GROUP BY u.website_service_id ORDER BY count limit 0,10

View File

@@ -47,6 +47,30 @@ public class DashboardService extends BaseService{
*/ */
public List<Map> getTotalReportList(){ public List<Map> getTotalReportList(){
List<Map> totalReportList = ntcTotalReportDao.getTotalReportList(); List<Map> totalReportList = ntcTotalReportDao.getTotalReportList();
//统计带宽的流入流出 单位 五分钟 的 byte
List<Map> newData = ntcTotalReportDao.getNetFlowPortInfoNew();
List<Map> 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; return totalReportList;
} }