2022-09-10 23:13:42 +08:00
|
|
|
|
<template>
|
2022-09-15 15:51:00 +08:00
|
|
|
|
<div class="link-direction-grid">
|
2022-09-28 15:35:03 +08:00
|
|
|
|
<!--左侧链路出入口-->
|
2022-10-13 16:36:14 +08:00
|
|
|
|
<popover-content :isNoData="isNoData" :gridData="gridData" style="width: 900px;"/>
|
2022-09-28 15:35:03 +08:00
|
|
|
|
|
|
|
|
|
|
<!--右侧链路下一跳-->
|
2022-10-13 16:36:14 +08:00
|
|
|
|
<popover-content :isNoData="isNoData" :gridData="gridData2" />
|
2022-09-15 15:51:00 +08:00
|
|
|
|
</div>
|
2022-09-10 23:13:42 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import chartMixin from '@/views/charts2/chart-mixin'
|
2022-09-15 15:51:00 +08:00
|
|
|
|
import { getSecond } from '@/utils/date-util'
|
|
|
|
|
|
import { api } from '@/utils/api'
|
|
|
|
|
|
import { get } from '@/utils/http'
|
2022-09-28 15:35:03 +08:00
|
|
|
|
import { storageKey } from '@/utils/constants'
|
|
|
|
|
|
import PopoverContent from './LinkDirectionGrid/PopoverContent'
|
|
|
|
|
|
import { computeScore } from '@/utils/tools'
|
2022-09-10 23:13:42 +08:00
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: 'LinkDirectionGrid',
|
2022-09-15 15:51:00 +08:00
|
|
|
|
mixins: [chartMixin],
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
|
|
|
|
|
gridData: [],
|
2022-10-13 16:36:14 +08:00
|
|
|
|
gridData2: [],
|
|
|
|
|
|
isNoData: false
|
2022-09-15 15:51:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-09-28 15:35:03 +08:00
|
|
|
|
components: {
|
|
|
|
|
|
PopoverContent
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
timeFilter: {
|
|
|
|
|
|
handler (n) {
|
|
|
|
|
|
this.init()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted () {
|
|
|
|
|
|
this.init()
|
|
|
|
|
|
},
|
2022-09-15 15:51:00 +08:00
|
|
|
|
methods: {
|
|
|
|
|
|
init () {
|
2022-09-28 15:35:03 +08:00
|
|
|
|
// 链路基本信息
|
|
|
|
|
|
let linkInfo = localStorage.getItem(storageKey.linkInfo)
|
|
|
|
|
|
linkInfo = JSON.parse(linkInfo)
|
|
|
|
|
|
console.log('LinkDirectionGrid.vue---init--获取链路基本信息缓存', linkInfo)
|
|
|
|
|
|
|
2022-09-15 15:51:00 +08:00
|
|
|
|
const params = {
|
|
|
|
|
|
startTime: getSecond(this.timeFilter.startTime),
|
|
|
|
|
|
endTime: getSecond(this.timeFilter.endTime)
|
|
|
|
|
|
}
|
2022-09-28 15:35:03 +08:00
|
|
|
|
|
2022-10-11 20:10:04 +08:00
|
|
|
|
const dataRequest = get(api.linkMonitor.bigramAnalysis, params)
|
|
|
|
|
|
const nextHopRequest = get(api.linkMonitor.bigramNextHopAnalysis, params)
|
2022-10-13 16:36:14 +08:00
|
|
|
|
this.toggleLoading(true)
|
2022-09-28 15:35:03 +08:00
|
|
|
|
|
|
|
|
|
|
Promise.all([dataRequest, nextHopRequest]).then(res => {
|
2022-09-15 15:51:00 +08:00
|
|
|
|
if (res[0].code === 200 && res[1].code === 200) {
|
2022-09-28 15:35:03 +08:00
|
|
|
|
// 链路流量数据
|
|
|
|
|
|
const linkData = res[0].data.result
|
|
|
|
|
|
// 链路下一跳信息
|
|
|
|
|
|
const nextLinkData = res[1].data.result
|
|
|
|
|
|
|
2022-10-13 16:36:14 +08:00
|
|
|
|
this.isNoData = linkData.length === 0 && nextLinkData.length === 0
|
|
|
|
|
|
if (this.isNoData) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-28 15:35:03 +08:00
|
|
|
|
// 链路流量数据
|
|
|
|
|
|
const gridData = []
|
|
|
|
|
|
// 链路下一跳数据
|
|
|
|
|
|
const gridData2 = []
|
|
|
|
|
|
linkData.forEach(d => {
|
|
|
|
|
|
const ingressLink = linkInfo.find(l => l.originalLinkId === d.ingressLinkId)
|
|
|
|
|
|
const egressLink = linkInfo.find(l => l.originalLinkId === d.egressLinkId)
|
|
|
|
|
|
if (ingressLink && egressLink) {
|
|
|
|
|
|
const data = gridData.find(g => g.linkId === ingressLink.linkId)
|
|
|
|
|
|
|
|
|
|
|
|
// 上行使用情况计算
|
|
|
|
|
|
const egressUsage = this.computeUsage(d.egressBytes, egressLink.bandwidth)
|
|
|
|
|
|
// 下行使用情况计算
|
2022-09-30 14:16:23 +08:00
|
|
|
|
const ingressUsage = this.computeUsage(d.ingressBytes, ingressLink.bandwidth)
|
2022-09-28 16:55:53 +08:00
|
|
|
|
// 宽带使用超过90%,赋红点
|
|
|
|
|
|
d.usageMore90 = false
|
2022-09-29 16:36:30 +08:00
|
|
|
|
if (egressUsage >= 0.9 || ingressUsage >= 0.9) {
|
2022-09-28 16:55:53 +08:00
|
|
|
|
d.usageMore90 = true
|
|
|
|
|
|
}
|
2022-09-28 15:35:03 +08:00
|
|
|
|
// 计算npm分数
|
2022-09-28 16:55:53 +08:00
|
|
|
|
// 分数低于3分,赋红点
|
2022-09-28 15:35:03 +08:00
|
|
|
|
d.score = this.localComputeScore(d)
|
2022-09-28 16:55:53 +08:00
|
|
|
|
d.scoreLow3 = false
|
|
|
|
|
|
if (d.score < 3) {
|
|
|
|
|
|
d.scoreLow3 = true
|
|
|
|
|
|
}
|
2022-09-28 15:35:03 +08:00
|
|
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
|
|
const existedEgressLink = data.egress.find(e => e.linkId === egressLink.linkId)
|
|
|
|
|
|
if (!existedEgressLink) {
|
|
|
|
|
|
data.egress.push({
|
|
|
|
|
|
linkId: egressLink.linkId,
|
|
|
|
|
|
egressUsage: egressUsage,
|
|
|
|
|
|
ingressUsage: ingressUsage,
|
|
|
|
|
|
totalBytes: d.totalBytes,
|
|
|
|
|
|
...d
|
|
|
|
|
|
})
|
2022-09-15 15:51:00 +08:00
|
|
|
|
}
|
2022-09-28 15:35:03 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
gridData.push({
|
|
|
|
|
|
linkId: ingressLink.linkId,
|
|
|
|
|
|
egress: [{
|
|
|
|
|
|
linkId: egressLink.linkId,
|
|
|
|
|
|
egressUsage: egressUsage,
|
|
|
|
|
|
ingressUsage: ingressUsage,
|
|
|
|
|
|
totalBytes: d.totalBytes,
|
|
|
|
|
|
...d
|
|
|
|
|
|
}]
|
|
|
|
|
|
})
|
2022-09-15 15:51:00 +08:00
|
|
|
|
}
|
2022-09-28 15:35:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2022-09-30 14:16:23 +08:00
|
|
|
|
|
2022-09-28 16:55:53 +08:00
|
|
|
|
this.gridData = gridData
|
2022-09-28 15:35:03 +08:00
|
|
|
|
|
|
|
|
|
|
nextLinkData.forEach(d => {
|
|
|
|
|
|
const ingressLink = linkInfo.find(l => l.nextHop === d.ingressLinkDirection && l.direction === 'ingress')
|
|
|
|
|
|
const egressLink = linkInfo.find(l => l.nextHop === d.egressLinkDirection && l.direction === 'egress')
|
|
|
|
|
|
|
|
|
|
|
|
if (ingressLink && egressLink) {
|
|
|
|
|
|
const data = gridData2.find(g => g.linkId === ingressLink.linkId)
|
|
|
|
|
|
|
|
|
|
|
|
let egressBanwidth = 0
|
|
|
|
|
|
let ingressBanwidth = 0
|
|
|
|
|
|
linkInfo.forEach((item) => {
|
|
|
|
|
|
if (item.nextHop === d.egressLinkDirection && item.direction === 'egress') {
|
|
|
|
|
|
egressBanwidth += item.bandwidth
|
|
|
|
|
|
}
|
|
|
|
|
|
if (item.nextHop === d.ingressLinkDirection && item.direction === 'ingress') {
|
|
|
|
|
|
ingressBanwidth += item.bandwidth
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 上行使用情况计算
|
|
|
|
|
|
const egressUsage = this.computeUsage(d.egressBytes, egressBanwidth)
|
|
|
|
|
|
// 下行使用情况计算
|
|
|
|
|
|
const ingressUsage = this.computeUsage(d.ingressBytes, ingressBanwidth)
|
2022-09-28 16:55:53 +08:00
|
|
|
|
// 宽带使用超过90%,赋红点
|
|
|
|
|
|
d.usageMore90 = false
|
2022-09-29 16:36:30 +08:00
|
|
|
|
if (egressUsage >= 0.9 || ingressUsage >= 0.9) {
|
2022-09-28 16:55:53 +08:00
|
|
|
|
d.usageMore90 = true
|
|
|
|
|
|
}
|
2022-09-28 15:35:03 +08:00
|
|
|
|
// 计算npm分数
|
2022-09-28 16:55:53 +08:00
|
|
|
|
// 分数低于3分,赋红点
|
2022-09-28 15:35:03 +08:00
|
|
|
|
d.score = this.localComputeScore(d)
|
2022-09-28 16:55:53 +08:00
|
|
|
|
d.scoreLow3 = false
|
|
|
|
|
|
if (d.score < 3) {
|
|
|
|
|
|
d.scoreLow3 = true
|
|
|
|
|
|
}
|
2022-09-28 15:35:03 +08:00
|
|
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
|
|
const existedEgressLink = data.egress.find(e => e.linkId === egressLink.linkId)
|
|
|
|
|
|
if (!existedEgressLink) {
|
|
|
|
|
|
data.egress.push({
|
|
|
|
|
|
linkId: egressLink.linkId,
|
|
|
|
|
|
nextHop: egressLink.nextHop,
|
|
|
|
|
|
egressUsage: egressUsage,
|
|
|
|
|
|
ingressUsage: ingressUsage,
|
|
|
|
|
|
totalBytes: d.totalBytes,
|
|
|
|
|
|
...d
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
gridData2.push({
|
|
|
|
|
|
linkId: ingressLink.linkId,
|
|
|
|
|
|
nextHop: ingressLink.nextHop,
|
|
|
|
|
|
egress: [{
|
|
|
|
|
|
linkId: egressLink.linkId,
|
|
|
|
|
|
nextHop: ingressLink.nextHop,
|
|
|
|
|
|
egressUsage: egressUsage,
|
|
|
|
|
|
ingressUsage: ingressUsage,
|
|
|
|
|
|
totalBytes: d.totalBytes,
|
|
|
|
|
|
...d
|
|
|
|
|
|
}]
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.gridData2 = gridData2
|
2022-10-13 16:36:14 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.isNoData = true
|
2022-09-15 15:51:00 +08:00
|
|
|
|
}
|
2022-10-13 16:36:14 +08:00
|
|
|
|
}).catch(e => {
|
|
|
|
|
|
console.error('====', e)
|
|
|
|
|
|
this.isNoData = true
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.toggleLoading(false)
|
2022-09-15 15:51:00 +08:00
|
|
|
|
})
|
2022-09-28 15:35:03 +08:00
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 计算上下行使用占比
|
|
|
|
|
|
*/
|
|
|
|
|
|
computeUsage (e, bandwidth) {
|
2022-09-29 16:36:30 +08:00
|
|
|
|
let usage = e / bandwidth
|
|
|
|
|
|
if (usage >= 1) {
|
|
|
|
|
|
usage = 1
|
|
|
|
|
|
}
|
|
|
|
|
|
return usage
|
2022-09-28 15:35:03 +08:00
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 本地计算npm分数
|
|
|
|
|
|
*/
|
|
|
|
|
|
localComputeScore (data, bandwidth) {
|
|
|
|
|
|
const keyPre = ['tcp', 'http', 'ssl', 'tcpLost', 'packetRetrans']
|
|
|
|
|
|
let score = 0
|
|
|
|
|
|
keyPre.forEach((item, index) => {
|
|
|
|
|
|
score = computeScore(data, index)
|
|
|
|
|
|
data[keyPre[index] + 'Score'] = score
|
|
|
|
|
|
})
|
|
|
|
|
|
let npmScore = Math.ceil((data.tcpScore + data.httpScore + data.sslScore + data.tcpLostScore + data.packetRetransScore) * 6)
|
|
|
|
|
|
if (npmScore > 6) {
|
|
|
|
|
|
npmScore = 6
|
|
|
|
|
|
}
|
|
|
|
|
|
return npmScore
|
2022-09-15 15:51:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-09-10 23:13:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
</script>
|