| | |
| | | import { getPollConfig, changeRunType, getCamerasByServer, statisticRunInfo, updateChannelCount } from "@/api/pollConfig"; |
| | | import { getSystemSummaryInfo, getSysThresholds } from "@/api/system" |
| | | import { getPollConfig, changeRunType, getCamerasByServer, updateChannelCount } from "@/api/pollConfig"; |
| | | import { getSysThresholds } from "@/api/system" |
| | | import { |
| | | clusterStatisticRunInfo, |
| | | deviceStatisticRunInfo, |
| | | devicesSysInfo, |
| | | clusterSysInfo |
| | | } from "@/api/clusterManage"; |
| | | |
| | | export default class PollData { |
| | | public Config: Object = {}; |
| | |
| | | //算力配置中滑块数据 |
| | | public sliderList: Array<any> = []; |
| | | |
| | | |
| | | public init() { |
| | | this.fetchPollConfig(); |
| | | this.fetchPollList(); |
| | |
| | | } |
| | | } |
| | | public async statistics() { |
| | | let list = [] |
| | | // let list = [] |
| | | |
| | | let rsp: any = await getCamerasByServer({ cameraName: "" }); |
| | | if (rsp && rsp.success) { |
| | | list = list.concat(rsp.data); |
| | | } |
| | | // let rsp: any = await getCamerasByServer({ cameraName: "" }); |
| | | // if (rsp && rsp.success) { |
| | | // list = list.concat(rsp.data); |
| | | // } |
| | | |
| | | let RealTimeSum = 0, RealTimeRun = 0, PollSum = 0, PollRun = 0; |
| | | // let RealTimeSum = 0, RealTimeRun = 0, PollSum = 0, PollRun = 0; |
| | | |
| | | list.forEach((cam: any) => { |
| | | if (cam.run_type === 1) { |
| | | RealTimeSum++ |
| | | if (cam.is_running) { |
| | | RealTimeRun++ |
| | | } |
| | | } |
| | | // list.forEach((cam: any) => { |
| | | // if (cam.run_type === 1) { |
| | | // RealTimeSum++ |
| | | // if (cam.is_running) { |
| | | // RealTimeRun++ |
| | | // } |
| | | // } |
| | | |
| | | if (cam.run_type === 0) { |
| | | PollSum++ |
| | | if (cam.is_running) { |
| | | PollRun++ |
| | | } |
| | | } |
| | | }) |
| | | // if (cam.run_type === 0) { |
| | | // PollSum++ |
| | | // if (cam.is_running) { |
| | | // PollRun++ |
| | | // } |
| | | // } |
| | | // }) |
| | | |
| | | this.Running = RealTimeRun + PollRun |
| | | this.Idle = RealTimeSum + PollSum - this.Running |
| | | // this.Running = RealTimeRun + PollRun |
| | | // this.Idle = RealTimeSum + PollSum - this.Running |
| | | |
| | | // 计算系统信息 |
| | | rsp = await getSystemSummaryInfo() |
| | | if (rsp && rsp.success && rsp.data.cpu) { |
| | | let sysinfo = rsp.data |
| | | |
| | | // cpu |
| | | if (sysinfo.cpu) { |
| | | let cpuLoad = sysinfo.cpu.reduce((pre, item) => { |
| | | return pre + item; |
| | | }, 0) |
| | | |
| | | this.CpuUsedPercent = Number((cpuLoad / sysinfo.cpu.length).toFixed(2)) |
| | | } |
| | | |
| | | // 内存 |
| | | this.MemUsedPercent = Number(sysinfo.mem.usedPercent.toFixed(2)) |
| | | // 硬盘使用情况 |
| | | this.DiskUsePercent = Number(sysinfo.disk.usedPercent.toFixed(2)) |
| | | |
| | | if (sysinfo.gpu) { |
| | | let gpuLoad = 0, gpuTotal = 0; |
| | | |
| | | for (let i = 0; i < sysinfo.gpu.length; i++) { |
| | | gpuLoad += sysinfo.gpu[i].used; |
| | | gpuTotal += sysinfo.gpu[i].memory; |
| | | } |
| | | this.GpuUsedPercent = Number((gpuLoad / gpuTotal * 100).toFixed(2)) |
| | | } |
| | | this.barCharts = [this.DiskUsePercent,this.CpuUsedPercent,this.GpuUsedPercent,this.MemUsedPercent] |
| | | let res: any |
| | | if(sessionStorage.getItem("clusterId")) { |
| | | res = await clusterSysInfo({ |
| | | clusterId: "", |
| | | }); |
| | | } |
| | | |
| | | console.log(this); |
| | | |
| | | else { |
| | | res = await devicesSysInfo({ |
| | | deviceId:[sessionStorage.getItem('devId')], |
| | | }); |
| | | } |
| | | if (res && res.success ) { |
| | | this.CpuUsedPercent =res.data.cpu.usedPercent.toFixed(2) |
| | | this.MemUsedPercent = res.data.mem.usedPercent.toFixed(2) |
| | | this.DiskUsePercent =res.data.disk.usedPercent.toFixed(2) |
| | | this.GpuUsedPercent = res.data.gpu.usedPercent.toFixed(2) |
| | | this.barCharts = [this.DiskUsePercent,this.CpuUsedPercent,this.GpuUsedPercent,this.MemUsedPercent] |
| | | console.log(this.barCharts); |
| | | |
| | | } |
| | | } |
| | | |
| | | public async statisticTaskInfo() { |
| | | let res: any = await statisticRunInfo({}); |
| | | let res: any |
| | | if(sessionStorage.getItem("clusterId")) { |
| | | res = await clusterStatisticRunInfo({}); |
| | | } |
| | | else { |
| | | res = await deviceStatisticRunInfo({ |
| | | deviceId:[sessionStorage.getItem('devId')], |
| | | userId:'' |
| | | }); |
| | | } |
| | | |
| | | if (res && res.success) { |
| | | // console.log(res,'统计实时、轮询数量') |
| | | this.RealTimeSum = res.data.realTotal |