This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
cyber-narrator-cn-ui/src/mock/linkMonitor.js

183 lines
6.1 KiB
JavaScript
Raw Normal View History

2022-09-10 23:13:42 +08:00
import Mock from 'mockjs'
2022-10-11 20:10:04 +08:00
const openMock = false
2022-09-10 23:13:42 +08:00
if (openMock) {
Mock.mock(new RegExp(BASE_CONFIG.baseUrl + 'interface/link/overview/analysis.*'), 'get', function (requestObj) {
2022-09-10 23:13:42 +08:00
const linkData = []
const ingressLinkIds = ['256', '512', '768', '1024', '1280', '1536', '1792', '2048', '2304', '2816']
const egressLinkIds = ['257', '513', '769', '1025', '1281', '1537', '1793', '2049', '2305', '2817']
for (let i = 0; i < 10; i++) {
linkData.push({ linkId: ingressLinkIds[i], egressBytes: Math.floor(Math.pow(1.11, i) * 10000000000), ingressBytes: Math.floor(Math.pow(1.1, i) * 10000000000) })
linkData.push({ linkId: egressLinkIds[i], egressBytes: Math.floor(Math.pow(1.2, i) * 10000000000), ingressBytes: Math.floor(Math.pow(1.15, i) * 10000000000) })
2022-09-10 23:13:42 +08:00
}
return {
msg: 'success',
code: 200,
data: {
result: linkData
}
}
})
2022-09-15 15:51:00 +08:00
Mock.mock(new RegExp(BASE_CONFIG.baseUrl + 'interface/linkMonitor/linkTrafficDirection.*'), 'get', function (requestObj) {
const data = []
const ingressLinkIds = ['256', '512', '768', '1024', '1280', '1536', '1792', '2048', '2304', '2816']
const egressLinkIds = ['257', '513', '769', '1025', '1281', '1537', '1793', '2049', '2305', '2817']
ingressLinkIds.forEach(ingress => {
egressLinkIds.forEach(egress => {
data.push({ egressLinkId: egress, ingressLinkId: ingress, egressBytes: 12800000000, ingressBytes: 52800000000, totalBytes: 98541200, score: 6, tcpConnectionEstablishLatency: 50, httpResponseLatency: 50, sslResponseLatency: 50, packetsLoss: 0.2, packetRetrans: 0.1 })
2022-09-15 15:51:00 +08:00
})
})
return {
msg: 'success',
code: 200,
data: {
result: data
}
}
})
Mock.mock(new RegExp(BASE_CONFIG.baseUrl + 'interface/link/overview/quadrupleIngressAnalysis.*'), 'get', function (requestObj) {
const data = [
{
clientCity: 'beijing',
commonEgressLinkId: 257,
ingressLinkDirection: 'xian',
serverCity: 'taiyuan',
ingressBytes: 10000000000
},
{
clientCity: 'xingjiang',
commonEgressLinkId: 513,
ingressLinkDirection: 'xian',
serverCity: 'liaoning',
ingressBytes: 20000000000
},
{
clientCity: 'shanghai',
commonEgressLinkId: 769,
ingressLinkDirection: 'xian',
serverCity: 'anhui',
ingressBytes: 30000000000
},
{
clientCity: 'tianjing',
commonEgressLinkId: 1025,
ingressLinkDirection: 'xian',
serverCity: 'taiyuan',
ingressBytes: 30000000000
}
]
return {
msg: 'success',
code: 200,
data: {
result: data
}
}
})
Mock.mock(new RegExp(BASE_CONFIG.baseUrl + 'interface/link/overview/quadrupleEgressAnalysis.*'), 'get', function (requestObj) {
const data = [
{
clientCity: 'beijing',
commonEgressLinkId: 256,
egressLinkDirection: 'xian',
serverCity: 'taiyuan',
egressBytes: 10000000000
},
{
clientCity: 'xingjiang',
commonEgressLinkId: 512,
egressLinkDirection: 'xian',
serverCity: 'liaoning',
egressBytes: 20000000000
},
{
clientCity: 'shanghai',
commonEgressLinkId: 768,
egressLinkDirection: 'xian',
serverCity: 'anhui',
egressBytes: 30000000000
},
{
clientCity: 'tianjing',
commonEgressLinkId: 1024,
egressLinkDirection: 'xian',
serverCity: 'taiyuan',
egressBytes: 30000000000
}
]
return {
msg: 'success',
code: 200,
data: {
result: data
}
}
})
2023-06-01 14:05:25 +08:00
Mock.mock(new RegExp(BASE_CONFIG.baseUrl + 'interface/linkMonitor/bigramAnalysis.*'), 'get', function (requestObj) {
const data = []
const ingressLinkIds = ['256', '512', '768', '1024', '1280', '1536', '1792', '2048', '2304', '2816']
const egressLinkIds = ['257', '513', '769', '1025', '1281', '1537', '1793', '2049', '2305', '2817']
ingressLinkIds.forEach(ingress => {
egressLinkIds.forEach(egress => {
data.push({ egressLinkId: egress, ingressLinkId: ingress, egressBytes: 12800000000, ingressBytes: 52800000000, totalBytes: 98541200, establishLatencyMs: 50, httpResponseLatency: 50, sslConLatency: 50, tcpLostlenPercent: 0.2, pktRetransPercent: 0.1 })
})
})
return {
msg: 'success',
code: 200,
data: {
result: data
}
}
})
2023-06-01 14:05:25 +08:00
Mock.mock(new RegExp(BASE_CONFIG.baseUrl + 'interface/linkMonitor/bigramNextHopAnalysis.*'), 'get', function (requestObj) {
const data = []
const ingressLinkIds = ['西安', '太原', '西宁']
const egressLinkIds = ['西安', '太原', '西宁']
ingressLinkIds.forEach(ingress => {
egressLinkIds.forEach(egress => {
data.push({ egressLinkDirection: egress, ingressLinkDirection: ingress, egressBytes: 12800000000, ingressBytes: 52800000000, totalBytes: 98541200, establishLatencyMs: 50, httpResponseLatency: 50, sslConLatency: 50, tcpLostlenPercent: 0.2, pktRetransPercent: 0.1 })
})
})
return {
msg: 'success',
code: 200,
data: {
result: data
}
}
})
2022-09-30 14:16:23 +08:00
2023-06-01 14:05:25 +08:00
Mock.mock(new RegExp(BASE_CONFIG.baseUrl + 'interface/linkMonitor/analysis.*'), 'get', function (requestObj) {
2022-09-30 14:16:23 +08:00
const linkData = []
for (let i = 0; i < 10; i++) {
linkData.push({ linkId: 'Hundredgige' + (i + 1), egressBytes: Math.floor(Math.pow(1.3, i) * 1000000000), ingressBytes: Math.floor(Math.pow(1.5, i) * 1000000000) })
}
return {
msg: 'success',
code: 200,
data: {
result: linkData
}
}
})
2023-06-01 14:05:25 +08:00
Mock.mock(new RegExp(BASE_CONFIG.baseUrl + 'interface/linkMonitor/nextHopAnalysis.*'), 'get', function (requestObj) {
2022-09-30 14:16:23 +08:00
const linkData = [
{ linkDirection: '西安', egressBytes: 1024000000000, ingressBytes: 1224000000000 },
{ linkDirection: '太原', egressBytes: 102400000000, ingressBytes: 142400000000 },
{ linkDirection: '西宁', egressBytes: 1024000000, ingressBytes: 1024000000 }
]
return {
msg: 'success',
code: 200,
data: {
result: linkData
}
}
})
2022-09-10 23:13:42 +08:00
}