summaryrefslogtreecommitdiff
path: root/src/main/resources/mybatis/mapper/NetflowTopNMapper.xml
blob: 374f520b13b6f5dc82819d80f4f0785dc6996ba7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.nis.galaxy.web.dao.NetflowTopNDao">
    <!--5分钟内活跃IP流量-->
    <select id="getNetflow5minIpActiveWaterflow" resultType="com.nis.galaxy.domain.IpActiveInt">
       <![CDATA[
       SELECT #{push} AS time,'up' AS type,area_id AS area,ip_addr AS IP,SUM(c2s_byte_len) AS count
       FROM traffic_ip_active_statistic
          WHERE stat_time >= #{start}
          AND stat_time < #{end}
       GROUP BY IP ,area
       UNION ALL
       ( SELECT #{push} AS time,'down' AS type,area_id AS area,ip_addr AS IP,SUM(s2c_byte_len) AS count
       FROM traffic_ip_active_statistic
          WHERE stat_time >= #{start}
          AND stat_time < #{end}
       GROUP BY IP ,area )
        ]]>
    </select>
    <!--互联网流量TOP10-->
    <select id="getNetFlowWaterTop10_old" resultType="com.nis.galaxy.domain.NetFlowWater">
        <![CDATA[
        SELECT ifnull(dic.area,0) AS area,net.time AS time,sum(net.count)/1024/1024 AS count
        FROM (
            SELECT RECV_TIME time,sum(INOCTETS+OUTOCTETS) count,NODE_IP ip
        from traffic_netflow_port_info
        WHERE RECV_TIME>= #{start}
            AND RECV_TIME< #{end}
        GROUP BY RECV_TIME,ip) net
        LEFT JOIN
        (SELECT entrance_id area,manager_ip ip from ntc_device_info) dic
        ON net.ip = dic.ip
        GROUP BY area,time
        ]]>
    </select>


    <select id="getNetFlowWaterTop10" resultType="com.nis.galaxy.domain.NetFlowWater">
        <![CDATA[

        select entrance_id as area ,stat_time as time, IFNULL(SUM(c2s_byte_len+s2c_byte_len),0) as count
        from traffic_trans_statistic where STAT_TIME>= #{start} and STAT_TIME<#{end}
        group by stat_time,entrance_id


        ]]>
    </select>
    <!--1小时互联网流量TOP10-->
    <select id="getNetflow1HourWaterflowTop10" resultType="com.nis.galaxy.domain.NetFlowWater" parameterType="java.util.List">
        <foreach collection="list" item="item" index="index" open="(" close=")" separator=") UNION ALL (">
            <![CDATA[
            SELECT ifnull(dic.area,0) as area,#{item.start} time,sum(net.count)/1024/1024 count FROM (
            select sum(INOCTETS+OUTOCTETS) count,NODE_IP ip
            from traffic_netflow_port_info
            WHERE RECV_TIME>= #{item.start}
            AND RECV_TIME< #{item.end}
            GROUP BY ip) net
            LEFT JOIN
            (SELECT entrance_id area,manager_ip ip from ntc_device_info) dic
            on net.ip = dic.ip
            GROUP BY area
            ]]>
        </foreach>
    </select>
    <!--通过ip获取局点-->
    <select id="getIpEntranceRe" resultType="com.nis.galaxy.domain.Entrance">
        SELECT entrance_id AS entrance
        FROM ntc_device_info
        GROUP BY entrance;
    </select>

    <!--最近数据时间的获取 and 小于参数end-->
    <!--时间:5分钟内活跃IP流量TOP10-->
    <select id="getNetflow5minIpActiveWaterflowLastTime" resultType="java.util.Date">
        <![CDATA[
        SELECT stat_time
        FROM traffic_ip_active_statistic
        WHERE stat_time < #{end}
        ORDER BY stat_time DESC
        LIMIT 1
        ]]>
    </select>
    <!--时间:1小时内互联网流量TOP10-->
    <select id="getNetFlowWaterTop10LastTime_old" resultType="java.util.Date">
        <![CDATA[
        SELECT RECV_TIME
        FROM traffic_netflow_port_info
        WHERE RECV_TIME < #{end}
        ORDER BY RECV_TIME DESC
        LIMIT 1
        ]]>
    </select>
    <select id="getNetFlowWaterTop10LastTime" resultType="java.util.Date">
        <![CDATA[
        SELECT stat_time
        FROM traffic_trans_statistic
        WHERE stat_time < #{end}
        ORDER BY stat_time DESC
        LIMIT 1
        ]]>
    </select>
</mapper>