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-07-19 09:52:28 +08:00
|
|
|
import SingleValue from '@/views/charts2/charts/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-08-24 16:58:34 +08:00
|
|
|
let condition = ''
|
|
|
|
|
if (this.$store.getters.getQueryCondition.indexOf('OR') > -1) {
|
|
|
|
|
condition = this.$store.getters.getQueryCondition.split(/["|'](.*?)["|']/)
|
|
|
|
|
} else {
|
|
|
|
|
condition = this.$store.getters.getQueryCondition
|
|
|
|
|
}
|
2022-08-22 15:49:38 +08:00
|
|
|
const type = this.$store.getters.getDimensionType
|
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-24 16:58:34 +08:00
|
|
|
} else if (this.chartData.id === 24) {
|
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
|
|
|
|
|
} 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-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]}'`
|
|
|
|
|
} else if (type === 'idcRenter') {
|
|
|
|
|
params.q = `idc_renter='${condition[1]}'`
|
|
|
|
|
} else {
|
|
|
|
|
params.q = `${condition[0]}'${condition[1]}'`
|
|
|
|
|
}
|
2022-08-22 15:49:38 +08:00
|
|
|
}
|
2022-08-09 11:39:08 +08:00
|
|
|
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)
|
2022-08-21 22:11:53 +08:00
|
|
|
this.toggleLoading(true)
|
2022-08-09 11:39:08 +08:00
|
|
|
Promise.all([tcp, http, ssl, tcpPercent, packetPercent]).then(res => {
|
|
|
|
|
res.forEach(t => {
|
|
|
|
|
if (t.code === 200) {
|
|
|
|
|
this.npmNetworkCycleData.push(t.data.result)
|
|
|
|
|
}
|
|
|
|
|
})
|
2022-08-21 22:11:53 +08:00
|
|
|
}).finally(() => {
|
|
|
|
|
this.toggleLoading(false)
|
2022-08-09 11:39:08 +08:00
|
|
|
})
|
2022-08-23 16:12:24 +08:00
|
|
|
},
|
|
|
|
|
npmNetworkLastCycleQuery () {
|
2022-08-24 16:58:34 +08:00
|
|
|
let condition = ''
|
|
|
|
|
if (this.$store.getters.getQueryCondition.indexOf('OR') > -1) {
|
|
|
|
|
condition = this.$store.getters.getQueryCondition.split(/["|'](.*?)["|']/)
|
|
|
|
|
} else {
|
|
|
|
|
condition = this.$store.getters.getQueryCondition
|
|
|
|
|
}
|
2022-08-23 16:12:24 +08:00
|
|
|
const type = this.$store.getters.getDimensionType
|
|
|
|
|
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
|
|
|
|
|
} 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-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]}'`
|
|
|
|
|
} else if (type === 'idcRenter') {
|
|
|
|
|
params.q = `idc_renter='${condition[1]}'`
|
|
|
|
|
} else {
|
|
|
|
|
params.q = `${condition[0]}'${condition[1]}'`
|
|
|
|
|
}
|
2022-08-23 16:12:24 +08:00
|
|
|
}
|
|
|
|
|
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-08-24 11:43:04 +08:00
|
|
|
const keyPre = ['tcp', 'http', 'ssl', 'tcpLost', 'packetRetrans']
|
|
|
|
|
const scoreInfo = {}
|
|
|
|
|
res.forEach((t, i) => {
|
2022-08-23 16:12:24 +08:00
|
|
|
if (t.code === 200) {
|
2022-08-24 11:43:04 +08:00
|
|
|
if (t.data.result.establishLatencyAvg || t.data.result.establishLatencyAvg === 0) {
|
|
|
|
|
t.data.result.establishLatencyMs = t.data.result.establishLatencyAvg
|
|
|
|
|
}
|
|
|
|
|
if (t.data.result.httpResponseLatencyAvg || t.data.result.httpResponseLatencyAvg === 0) {
|
|
|
|
|
t.data.result.httpResponseLatency = t.data.result.httpResponseLatencyAvg
|
|
|
|
|
}
|
|
|
|
|
if (t.data.result.sequenceGapLossAvg || t.data.result.sequenceGapLossAvg === 0) {
|
|
|
|
|
t.data.result.tcpLostlenPercent = t.data.result.sequenceGapLossAvg
|
|
|
|
|
}
|
|
|
|
|
if (t.data.result.pktRetransAvg || t.data.result.pktRetransAvg === 0) {
|
|
|
|
|
t.data.result.pktRetransPercent = t.data.result.pktRetransAvg
|
|
|
|
|
}
|
|
|
|
|
if (t.data.result.sslConLatencyAvg || t.data.result.sslConLatencyAvg === 0) {
|
|
|
|
|
t.data.result.sslConLatency = t.data.result.sslConLatencyAvg
|
|
|
|
|
}
|
|
|
|
|
scoreInfo[keyPre[i] + 'Score'] = computeScore(t.data.result, i)
|
2022-08-23 16:12:24 +08:00
|
|
|
this.npmNetworkLastCycleData.push(t.data.result)
|
|
|
|
|
this.npmNetworkQuantity(this.npmNetworkCycleData, this.npmNetworkLastCycleData)
|
2022-08-24 11:43:04 +08:00
|
|
|
} else {
|
|
|
|
|
t[keyPre[i] + 'Score'] = 0
|
2022-08-23 16:12:24 +08:00
|
|
|
}
|
|
|
|
|
})
|
2022-08-24 11:43:04 +08:00
|
|
|
scoreInfo.score = Math.ceil((scoreInfo.tcpScore + scoreInfo.httpScore + scoreInfo.sslScore + scoreInfo.tcpLostScore + scoreInfo.packetRetransScore) * 6)
|
|
|
|
|
if (scoreInfo.score > 6) {
|
|
|
|
|
scoreInfo.score = 6
|
|
|
|
|
}
|
2022-08-24 14:33:39 +08:00
|
|
|
if (!params.q && this.chart.id === 44) {
|
|
|
|
|
this.$store.commit('setNpmThirdLevelMenuScore', scoreInfo.score)
|
|
|
|
|
}
|
2022-08-23 16:12:24 +08:00
|
|
|
}).finally(() => {
|
|
|
|
|
this.toggleLoading(false)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
npmNetworkQuantity (cycle, lastCycle) {
|
|
|
|
|
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])
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
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-08-23 16:12:24 +08:00
|
|
|
this.npmNetworkLastCycleQuery()
|
2022-07-19 09:52:28 +08:00
|
|
|
}
|
2022-07-18 15:04:32 +08:00
|
|
|
}
|
|
|
|
|
</script>
|