2022-07-18 15:04:32 +08:00
|
|
|
<template>
|
2022-07-19 09:52:28 +08:00
|
|
|
<div class="npm-network-quantity">
|
2022-08-08 17:45:50 +08:00
|
|
|
<single-value
|
|
|
|
|
:npm-network-name="npmNetworkName"
|
2022-08-23 16:12:24 +08:00
|
|
|
:npm-network-data="npmNetworkData"
|
2022-08-08 17:45:50 +08:00
|
|
|
></single-value>
|
2022-07-19 09:52:28 +08:00
|
|
|
</div>
|
2022-07-18 15:04:32 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-09-13 17:52:38 +08:00
|
|
|
import SingleValue from '@/views/charts2/charts/npm/localComponents/SingleValue'
|
2022-08-08 17:45:50 +08:00
|
|
|
import { get } from '@/utils/http'
|
|
|
|
|
import { getSecond } from '@/utils/date-util'
|
|
|
|
|
import { api } from '@/utils/api'
|
2022-08-21 22:11:53 +08:00
|
|
|
import chartMixin from '@/views/charts2/chart-mixin'
|
2022-08-22 15:49:38 +08:00
|
|
|
import _ from 'lodash'
|
2022-08-24 11:43:04 +08:00
|
|
|
import { computeScore, getChainRatio } from '@/utils/tools'
|
2022-07-18 15:04:32 +08:00
|
|
|
export default {
|
2022-07-19 09:52:28 +08:00
|
|
|
name: 'NpmNetworkQuantity',
|
|
|
|
|
components: { SingleValue },
|
2022-08-21 22:11:53 +08:00
|
|
|
mixins: [chartMixin],
|
2022-07-19 09:52:28 +08:00
|
|
|
data () {
|
|
|
|
|
return {
|
2022-08-08 17:45:50 +08:00
|
|
|
npmNetworkName: [
|
2022-08-09 11:39:08 +08:00
|
|
|
{ name: 'networkAppPerformance.tcpConnectionEstablishLatency' },
|
|
|
|
|
{ name: 'networkAppPerformance.httpResponse' },
|
|
|
|
|
{ name: 'networkAppPerformance.sslResponseLatency' },
|
|
|
|
|
{ name: 'networkAppPerformance.packetLoss' },
|
|
|
|
|
{ name: 'overall.packetRetrans' }
|
2022-08-08 17:45:50 +08:00
|
|
|
],
|
2022-08-22 15:49:38 +08:00
|
|
|
npmNetworkCycleData: [],
|
2022-08-23 16:12:24 +08:00
|
|
|
npmNetworkLastCycleData: [],
|
|
|
|
|
npmNetworkData: [],
|
2022-08-22 15:49:38 +08:00
|
|
|
side: '',
|
|
|
|
|
chartData: {}
|
2022-08-08 17:45:50 +08:00
|
|
|
}
|
|
|
|
|
},
|
2022-08-24 17:09:42 +08:00
|
|
|
watch: {
|
|
|
|
|
timeFilter: {
|
|
|
|
|
deep: true,
|
|
|
|
|
handler (n) {
|
|
|
|
|
this.npmNetworkCycleData = []
|
|
|
|
|
this.npmNetworkLastCycleData = []
|
|
|
|
|
this.npmNetworkCycleQuery()
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-08-08 17:45:50 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
npmNetworkCycleQuery () {
|
2022-09-20 09:33:49 +08:00
|
|
|
const conditionStr = this.$route.query.queryCondition ? this.$route.query.queryCondition : ''
|
2022-08-24 16:58:34 +08:00
|
|
|
let condition = ''
|
2022-09-20 09:33:49 +08:00
|
|
|
if (conditionStr.indexOf('OR') > -1) {
|
|
|
|
|
condition = conditionStr.split(/["|'](.*?)["|']/)
|
2022-08-24 16:58:34 +08:00
|
|
|
} else {
|
2022-09-20 09:33:49 +08:00
|
|
|
condition = conditionStr
|
2022-08-24 16:58:34 +08:00
|
|
|
}
|
2022-09-20 09:33:49 +08:00
|
|
|
// const type = this.$store.getters.getDimensionType
|
|
|
|
|
const type = this.$route.query.dimensionType ? this.$route.query.dimensionType : ''
|
2022-08-08 17:45:50 +08:00
|
|
|
const params = {
|
|
|
|
|
startTime: getSecond(this.timeFilter.startTime),
|
|
|
|
|
endTime: getSecond(this.timeFilter.endTime),
|
|
|
|
|
cycle: 0
|
|
|
|
|
}
|
2022-08-22 15:49:38 +08:00
|
|
|
if (this.chartData.id === 23) {
|
|
|
|
|
this.side = 'client'
|
2022-08-26 11:31:34 +08:00
|
|
|
} else if (this.chartData.id === 26) {
|
2022-08-22 15:49:38 +08:00
|
|
|
this.side = 'server'
|
|
|
|
|
}
|
2022-08-24 16:58:34 +08:00
|
|
|
if (condition && (typeof condition !== 'object') && type) {
|
|
|
|
|
params.q = condition
|
2022-08-30 10:58:22 +08:00
|
|
|
params.type = type
|
2022-08-24 16:58:34 +08:00
|
|
|
} else if (condition.length > 1 && type && type === 'ip') {
|
2022-08-22 15:49:38 +08:00
|
|
|
params.q = `${type}='${condition[1]}' and side='${this.side}'`
|
2022-08-30 10:58:22 +08:00
|
|
|
params.type = type
|
2022-08-24 16:58:34 +08:00
|
|
|
} else if (condition.length > 1 && type && type !== 'ip') {
|
2022-08-24 18:18:28 +08:00
|
|
|
if (type === 'country' || type === 'asn' || type === 'province' || type === 'city' || type === 'isp') {
|
2022-08-24 16:58:34 +08:00
|
|
|
params.q = `${type}='${condition[1]}'`
|
2022-08-30 10:58:22 +08:00
|
|
|
params.type = type
|
2022-08-24 16:58:34 +08:00
|
|
|
} else if (type === 'idcRenter') {
|
|
|
|
|
params.q = `idc_renter='${condition[1]}'`
|
2022-08-30 10:58:22 +08:00
|
|
|
params.type = type
|
2022-08-24 16:58:34 +08:00
|
|
|
} else {
|
|
|
|
|
params.q = `${condition[0]}'${condition[1]}'`
|
2022-08-30 10:58:22 +08:00
|
|
|
params.type = type
|
2022-08-24 16:58:34 +08:00
|
|
|
}
|
2022-08-22 15:49:38 +08:00
|
|
|
}
|
2022-08-30 19:08:29 +08:00
|
|
|
if (type && condition) {
|
|
|
|
|
this.toggleLoading(true)
|
|
|
|
|
get(api.npm.overview.networkAnalysis, params).then(res => {
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
this.npmNetworkCycleData = res.data.result
|
2022-09-06 11:41:36 +08:00
|
|
|
this.npmNetworkLastCycleQuery()
|
2022-08-09 11:39:08 +08:00
|
|
|
}
|
2022-09-06 11:41:36 +08:00
|
|
|
}).catch(e => {
|
2022-08-30 19:08:29 +08:00
|
|
|
this.toggleLoading(false)
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
const tcp = get(api.npm.overview.tcpSessionDelay, params)
|
|
|
|
|
const http = get(api.npm.overview.httpResponseDelay, params)
|
|
|
|
|
const ssl = get(api.npm.overview.sslConDelay, params)
|
|
|
|
|
const tcpPercent = get(api.npm.overview.tcpLostlenPercent, params)
|
|
|
|
|
const packetPercent = get(api.npm.overview.packetRetransPercent, params)
|
|
|
|
|
this.toggleLoading(true)
|
|
|
|
|
Promise.all([tcp, http, ssl, tcpPercent, packetPercent]).then(res => {
|
2022-09-06 11:37:56 +08:00
|
|
|
this.npmNetworkCycleData = []
|
2022-08-30 19:08:29 +08:00
|
|
|
res.forEach(t => {
|
|
|
|
|
if (t.code === 200) {
|
|
|
|
|
this.npmNetworkCycleData.push(t.data.result)
|
|
|
|
|
}
|
|
|
|
|
})
|
2022-09-06 11:37:56 +08:00
|
|
|
this.npmNetworkLastCycleQuery()
|
|
|
|
|
}).catch(e => {
|
2022-08-30 19:08:29 +08:00
|
|
|
this.toggleLoading(false)
|
2022-08-09 11:39:08 +08:00
|
|
|
})
|
2022-08-30 19:08:29 +08:00
|
|
|
}
|
2022-08-23 16:12:24 +08:00
|
|
|
},
|
|
|
|
|
npmNetworkLastCycleQuery () {
|
2022-09-20 09:33:49 +08:00
|
|
|
const conditionStr = this.$route.query.queryCondition ? this.$route.query.queryCondition : ''
|
2022-08-24 16:58:34 +08:00
|
|
|
let condition = ''
|
2022-09-20 09:33:49 +08:00
|
|
|
if (conditionStr.indexOf('OR') > -1) {
|
|
|
|
|
condition = conditionStr.split(/["|'](.*?)["|']/)
|
2022-08-24 16:58:34 +08:00
|
|
|
} else {
|
2022-09-20 09:33:49 +08:00
|
|
|
condition = conditionStr
|
2022-08-24 16:58:34 +08:00
|
|
|
}
|
2022-09-20 09:33:49 +08:00
|
|
|
// const type = this.$store.getters.getDimensionType
|
|
|
|
|
const type = this.$route.query.dimensionType ? this.$route.query.dimensionType : ''
|
2022-08-23 16:12:24 +08:00
|
|
|
const params = {
|
|
|
|
|
startTime: getSecond(this.timeFilter.startTime),
|
|
|
|
|
endTime: getSecond(this.timeFilter.endTime),
|
|
|
|
|
cycle: 1
|
|
|
|
|
}
|
|
|
|
|
if (this.chartData.id === 23) {
|
|
|
|
|
this.side = 'client'
|
2022-08-24 16:58:34 +08:00
|
|
|
} else if (this.chartData.id === 26) {
|
2022-08-23 16:12:24 +08:00
|
|
|
this.side = 'server'
|
|
|
|
|
}
|
2022-08-24 16:58:34 +08:00
|
|
|
if (condition && (typeof condition !== 'object') && type) {
|
|
|
|
|
params.q = condition
|
2022-08-30 10:58:22 +08:00
|
|
|
params.type = type
|
2022-08-24 16:58:34 +08:00
|
|
|
} else if (condition.length > 1 && type && type === 'ip') {
|
2022-08-23 16:12:24 +08:00
|
|
|
params.q = `${type}='${condition[1]}' and side='${this.side}'`
|
2022-08-30 10:58:22 +08:00
|
|
|
params.type = type
|
2022-08-24 16:58:34 +08:00
|
|
|
} else if (condition.length > 1 && type && type !== 'ip') {
|
2022-08-24 18:18:28 +08:00
|
|
|
if (type === 'country' || type === 'asn' || type === 'province' || type === 'city' || type === 'isp') {
|
2022-08-24 16:58:34 +08:00
|
|
|
params.q = `${type}='${condition[1]}'`
|
2022-08-30 10:58:22 +08:00
|
|
|
params.type = type
|
2022-08-24 16:58:34 +08:00
|
|
|
} else if (type === 'idcRenter') {
|
|
|
|
|
params.q = `idc_renter='${condition[1]}'`
|
2022-08-30 10:58:22 +08:00
|
|
|
params.type = type
|
2022-08-24 16:58:34 +08:00
|
|
|
} else {
|
|
|
|
|
params.q = `${condition[0]}'${condition[1]}'`
|
2022-08-30 10:58:22 +08:00
|
|
|
params.type = type
|
2022-08-24 16:58:34 +08:00
|
|
|
}
|
2022-08-23 16:12:24 +08:00
|
|
|
}
|
2022-08-30 19:08:29 +08:00
|
|
|
if (type && condition) {
|
|
|
|
|
this.toggleLoading(true)
|
|
|
|
|
get(api.npm.overview.networkAnalysis, params).then(res => {
|
|
|
|
|
const keyPre = ['tcp', 'http', 'ssl', 'tcpLost', 'packetRetrans']
|
|
|
|
|
const scoreInfo = {}
|
|
|
|
|
let index = 0
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
if (res.data.result.establishLatencyMsAvg || res.data.result.establishLatencyMsAvg === 0) {
|
|
|
|
|
res.data.result.establishLatencyMs = res.data.result.establishLatencyMsAvg
|
|
|
|
|
index = 0
|
2022-08-24 11:43:04 +08:00
|
|
|
}
|
2022-08-30 19:08:29 +08:00
|
|
|
if (res.data.result.httpResponseLatencyAvg || res.data.result.httpResponseLatencyAvg === 0) {
|
2022-09-06 11:15:48 +08:00
|
|
|
res.data.result.httpResponseLatency = res.data.result.httpResponseLatencyAvg
|
2022-08-30 19:08:29 +08:00
|
|
|
index = 1
|
2022-08-24 11:43:04 +08:00
|
|
|
}
|
2022-08-30 19:08:29 +08:00
|
|
|
if (res.data.result.tcpLostlenPercentAvg || res.data.result.tcpLostlenPercentAvg === 0) {
|
2022-09-06 11:15:48 +08:00
|
|
|
res.data.result.tcpLostlenPercent = res.data.result.tcpLostlenPercentAvg
|
2022-08-30 19:08:29 +08:00
|
|
|
index = 3
|
2022-08-24 11:43:04 +08:00
|
|
|
}
|
2022-08-30 19:08:29 +08:00
|
|
|
if (res.data.result.pktRetransPercentAvg || res.data.result.pktRetransPercentAvg === 0) {
|
2022-09-06 11:15:48 +08:00
|
|
|
res.data.result.pktRetransPercent = res.data.result.pktRetransPercentAvg
|
2022-08-30 19:08:29 +08:00
|
|
|
index = 4
|
2022-08-24 11:43:04 +08:00
|
|
|
}
|
2022-08-30 19:08:29 +08:00
|
|
|
if (res.data.result.sslConLatencyAvg || res.data.result.sslConLatencyAvg === 0) {
|
2022-09-06 11:15:48 +08:00
|
|
|
res.data.result.sslConLatency = res.data.result.sslConLatencyAvg
|
2022-08-30 19:08:29 +08:00
|
|
|
index = 2
|
|
|
|
|
}
|
|
|
|
|
scoreInfo[keyPre[index] + 'Score'] = computeScore(res.data.result, index)
|
|
|
|
|
this.npmNetworkLastCycleData = res.data.result
|
|
|
|
|
let timer = null
|
|
|
|
|
if (timer) {
|
|
|
|
|
clearTimeout(timer)
|
|
|
|
|
}
|
|
|
|
|
timer = setTimeout(() => {
|
|
|
|
|
this.npmNetworkQuantity(this.npmNetworkCycleData, this.npmNetworkLastCycleData, 0)
|
|
|
|
|
}, 300)
|
2022-08-24 11:43:04 +08:00
|
|
|
} else {
|
2022-08-30 19:08:29 +08:00
|
|
|
res[keyPre[index] + 'Score'] = 0
|
|
|
|
|
}
|
|
|
|
|
scoreInfo.score = Math.ceil((scoreInfo.tcpScore + scoreInfo.httpScore + scoreInfo.sslScore + scoreInfo.tcpLostScore + scoreInfo.packetRetransScore) * 6)
|
|
|
|
|
if (scoreInfo.score > 6) {
|
|
|
|
|
scoreInfo.score = 6
|
2022-08-23 16:12:24 +08:00
|
|
|
}
|
2022-08-30 19:08:29 +08:00
|
|
|
if (!params.q && this.chart.id === 44) {
|
|
|
|
|
this.$store.commit('setNpmThirdLevelMenuScore', scoreInfo.score)
|
|
|
|
|
}
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
this.toggleLoading(false)
|
2022-08-23 16:12:24 +08:00
|
|
|
})
|
2022-08-30 19:08:29 +08:00
|
|
|
} else {
|
|
|
|
|
const tcp = get(api.npm.overview.tcpSessionDelay, params)
|
|
|
|
|
const http = get(api.npm.overview.httpResponseDelay, params)
|
|
|
|
|
const ssl = get(api.npm.overview.sslConDelay, params)
|
|
|
|
|
const tcpPercent = get(api.npm.overview.tcpLostlenPercent, params)
|
|
|
|
|
const packetPercent = get(api.npm.overview.packetRetransPercent, params)
|
|
|
|
|
this.toggleLoading(true)
|
|
|
|
|
Promise.all([tcp, http, ssl, tcpPercent, packetPercent]).then(res => {
|
|
|
|
|
res.forEach((t, i) => {
|
|
|
|
|
if (t.code === 200) {
|
|
|
|
|
this.npmNetworkLastCycleData.push(t.data.result)
|
|
|
|
|
this.npmNetworkQuantity(this.npmNetworkCycleData, this.npmNetworkLastCycleData, 1)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
this.toggleLoading(false)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
npmNetworkQuantity (cycle, lastCycle, num) {
|
|
|
|
|
if (num === 0) {
|
|
|
|
|
this.npmNetworkData[0] = {
|
2022-09-01 16:35:56 +08:00
|
|
|
establishLatencyMsAvg: Math.floor(cycle.establishLatencyMsAvg),
|
2022-08-30 19:08:29 +08:00
|
|
|
establishLatencyMsP99: cycle.establishLatencyMsP99,
|
|
|
|
|
establishLatencyMsP95: cycle.establishLatencyMsP95,
|
|
|
|
|
value: getChainRatio(cycle.establishLatencyMsAvg, lastCycle.establishLatencyMsAvg)
|
2022-08-24 11:43:04 +08:00
|
|
|
}
|
2022-08-30 19:08:29 +08:00
|
|
|
this.npmNetworkData[1] = {
|
2022-09-01 16:35:56 +08:00
|
|
|
httpResponseLatencyAvg: Math.floor(cycle.httpResponseLatencyAvg),
|
2022-08-30 19:08:29 +08:00
|
|
|
httpResponseLatencyP99: cycle.httpResponseLatencyP99,
|
|
|
|
|
httpResponseLatencyP95: cycle.httpResponseLatencyP95,
|
|
|
|
|
value: getChainRatio(cycle.httpResponseLatencyAvg, lastCycle.httpResponseLatencyAvg)
|
2022-08-24 14:33:39 +08:00
|
|
|
}
|
2022-08-30 19:08:29 +08:00
|
|
|
this.npmNetworkData[2] = {
|
2022-09-01 16:35:56 +08:00
|
|
|
sslConLatencyAvg: Math.floor(cycle.sslConLatencyAvg),
|
2022-08-30 19:08:29 +08:00
|
|
|
sslConLatencyP99: cycle.sslConLatencyP99,
|
|
|
|
|
sslConLatencyP95: cycle.sslConLatencyP95,
|
|
|
|
|
value: getChainRatio(cycle.sslConLatencyAvg, lastCycle.sslConLatencyAvg)
|
|
|
|
|
}
|
|
|
|
|
this.npmNetworkData[3] = {
|
|
|
|
|
tcpLostlenPercentAvg: cycle.tcpLostlenPercentAvg,
|
|
|
|
|
tcpLostlenPercentP99: cycle.tcpLostlenPercentP99,
|
|
|
|
|
tcpLostlenPercentP95: cycle.tcpLostlenPercentP95,
|
|
|
|
|
value: getChainRatio(cycle.tcpLostlenPercentAvg, lastCycle.tcpLostlenPercentAvg)
|
|
|
|
|
}
|
|
|
|
|
this.npmNetworkData[4] = {
|
|
|
|
|
pktRetransPercentAvg: cycle.pktRetransPercentAvg,
|
|
|
|
|
pktRetransPercentP99: cycle.pktRetransPercentP99,
|
|
|
|
|
pktRetransPercentP95: cycle.pktRetransPercentP95,
|
|
|
|
|
value: getChainRatio(cycle.pktRetransPercentAvg, lastCycle.pktRetransPercentAvg)
|
|
|
|
|
}
|
|
|
|
|
} else if (num === 1) {
|
|
|
|
|
cycle.forEach(t => {
|
|
|
|
|
lastCycle.forEach(e => {
|
|
|
|
|
Object.keys(t).forEach(r => {
|
|
|
|
|
Object.keys(e).forEach(d => {
|
|
|
|
|
if (r === d) {
|
|
|
|
|
t.value = getChainRatio(t[r], e[d])
|
|
|
|
|
}
|
|
|
|
|
})
|
2022-08-23 16:12:24 +08:00
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
2022-08-30 19:08:29 +08:00
|
|
|
this.npmNetworkData = cycle
|
|
|
|
|
}
|
2022-07-19 09:52:28 +08:00
|
|
|
}
|
2022-08-08 17:45:50 +08:00
|
|
|
},
|
|
|
|
|
mounted () {
|
2022-08-22 15:49:38 +08:00
|
|
|
if (this.chart) {
|
|
|
|
|
this.chartData = _.cloneDeep(this.chart)
|
|
|
|
|
}
|
2022-08-08 17:45:50 +08:00
|
|
|
this.npmNetworkCycleQuery()
|
2022-07-19 09:52:28 +08:00
|
|
|
}
|
2022-07-18 15:04:32 +08:00
|
|
|
}
|
|
|
|
|
</script>
|