fix:首页traffic带宽统计修正为in与out流量,增加流量格式转换更新sql语句

This commit is contained in:
doufenghu
2019-01-17 12:24:37 +06:00
parent 579ca529b5
commit 8e5055e0ea
3 changed files with 52 additions and 10 deletions

View File

@@ -1,2 +1,15 @@
--
alter table traffic_port_active_statistic add trans_proto int(11) default 0 comment '6-tcp 17 -udp';
alter table traffic_port_active_statistic add trans_proto int(11) default 0 comment '6-tcp 17 -udp';
alter table traffic_trans_statistic add direction int(11) comment '0-out 1-in';
alter table traffic_protocol_statistic add direction int(11) comment '0-out 1-in',
add addr_type varchar(32), add trans_type int(11) ;
alter table traffic_app_statistic add direction int(11) comment '0-out 1-in',
add addr_type varchar(32), add trans_type int(11) ;

View File

@@ -341,8 +341,36 @@ CREATE TABLE `di_rule` (
) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.223:3306/nms/di_rule';
DROP TABLE IF EXISTS `ui_sys_device_info`;
CREATE TABLE `ui_sys_device_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`device_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '设备类型',
`ip_addr` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`device_id` int(11) NOT NULL COMMENT '设备ID相同设备可对应多个运营商',
`link_id` int(11) NOT NULL COMMENT '链路号索引',
`isp` int(11) NOT NULL COMMENT '运营商编码例如ktel-mxpe:1001',
`entrance_id` int(11) NOT NULL COMMENT '地域 1-astana 2-alamty',
`status` int(11) NOT NULL COMMENT '0-未接入 1-接入 2-部分接入',
`create_time` datetime(0) NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/sys_device_info';
;
DROP TABLE IF EXISTS `ui_sys_isp_info`;
CREATE TABLE `ui_sys_isp_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`isp_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '通信运营商名称',
`isp_code` int(11) NOT NULL COMMENT '通信运营商编码',
`business_type_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '业务类型名称',
`business_type_code` int(11) NOT NULL COMMENT '业务类型编码',
`isp_key_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '运营商唯一标识名称例如ktel-mxpe:1001',
`isp_key_code` int(11) NOT NULL COMMENT '运营商唯一标识编码',
`create_time` datetime(0) NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE=FEDERATED AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 CONNECTION='mysql://root:111111@10.0.4.6:3306/ntc_db/sys_isp_info';
;

View File

@@ -32,13 +32,14 @@
</select>
<!-- 根据最近时间条获取带宽,进出口流量 -->
<select id="getNetFlowPortInfoNew" resultType="java.util.HashMap">
SELECT SUM(total_traffic.inoctets) AS inoctets ,SUM(total_traffic.outoctets) AS outoctets FROM (
SELECT IFNULL(SUM(c2s_byte_len),0) inoctets ,IFNULL(SUM(s2c_byte_len),0) outoctets FROM traffic_trans_statistic
where stat_time = (SELECT stat_time FROM traffic_trans_statistic WHERE entrance_id=1 and stat_time > DATE_SUB(now(), INTERVAL 15 MINUTE) ORDER BY stat_time DESC LIMIT 0,1) and entrance_id=1
UNION ALL
SELECT IFNULL(SUM(c2s_byte_len),0) inoctets ,IFNULL(SUM(s2c_byte_len),0) outoctets FROM traffic_trans_statistic
where stat_time = (SELECT stat_time FROM traffic_trans_statistic WHERE entrance_id=2 and stat_time > DATE_SUB(now(), INTERVAL 15 MINUTE) ORDER BY stat_time DESC LIMIT 0,1) and entrance_id=2
) total_traffic
SELECT SUM(total_traffic.inoctets) AS inoctets , SUM(total_traffic.outoctets) AS outoctets FROM (
SELECT sum(case direction when 1 then c2s_byte_len+s2c_byte_len else 0 end) inoctets ,sum(case direction when 0 then c2s_byte_len+s2c_byte_len else 0 end) outoctets FROM traffic_trans_statistic
where stat_time = (SELECT stat_time FROM traffic_trans_statistic WHERE entrance_id=1 and stat_time > DATE_SUB(now(), INTERVAL 15 MINUTE) ORDER BY stat_time DESC LIMIT 0,1) and entrance_id=1
UNION ALL
SELECT sum(case direction when 1 then c2s_byte_len+s2c_byte_len else 0 end) inoctets ,sum(case direction when 0 then c2s_byte_len+s2c_byte_len else 0 end) outoctets FROM traffic_trans_statistic
where stat_time = (SELECT stat_time FROM traffic_trans_statistic WHERE entrance_id=2 and stat_time > DATE_SUB(now(), INTERVAL 15 MINUTE) ORDER BY stat_time DESC LIMIT 0,1) and entrance_id=2
) total_traffic
</select>
<!-- 获取近五分钟的带宽根据ip46协议 tcp,udp变化 -->
<!-- <select id="getBandwidthTrans" resultMap="BandwidthResultMap">