首页改造,完成cpu,内存,网络图

This commit is contained in:
648540858
2022-10-20 18:03:40 +08:00
parent 95d367702a
commit 3ffe205082
18 changed files with 711 additions and 758 deletions

View File

@@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.storager;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.common.SystemAllInfo;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.media.zlm.dto.*;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
@@ -196,7 +197,7 @@ public interface IRedisCatchStorage {
void addMemInfo(double memInfo);
void addNetInfo(Map<String, String> networkInterfaces);
void addNetInfo(Map<String, Double> networkInterfaces);
void sendMobilePositionMsg(JSONObject jsonObject);
@@ -240,4 +241,7 @@ public interface IRedisCatchStorage {
List<SendRtpItem> querySendRTPServerByChnnelId(String channelId);
List<SendRtpItem> querySendRTPServerByStream(String stream);
SystemAllInfo getSystemInfo();
}

View File

@@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.storager.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.common.SystemAllInfo;
import com.genersoft.iot.vmp.common.SystemInfoDto;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.UserSetting;
@@ -694,12 +695,12 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
@Override
public void addCpuInfo(double cpuInfo) {
String key = VideoManagerConstants.SYSTEM_INFO_CPU_PREFIX + userSetting.getServerId();
SystemInfoDto<Double> systemInfoDto = new SystemInfoDto<>();
systemInfoDto.setTime(DateUtil.getNow());
systemInfoDto.setData(cpuInfo);
RedisUtil.lSet(key, systemInfoDto);
Map<String, String> infoMap = new HashMap<>();
infoMap.put("time", DateUtil.getNow());
infoMap.put("data", cpuInfo + "");
RedisUtil.lSet(key, infoMap);
// 每秒一个最多只存30个
if (RedisUtil.lGetListSize(key) > 30) {
if (RedisUtil.lGetListSize(key) >= 30) {
for (int i = 0; i < RedisUtil.lGetListSize(key) - 30; i++) {
RedisUtil.lLeftPop(key);
}
@@ -709,12 +710,12 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
@Override
public void addMemInfo(double memInfo) {
String key = VideoManagerConstants.SYSTEM_INFO_MEM_PREFIX + userSetting.getServerId();
SystemInfoDto<Double> systemInfoDto = new SystemInfoDto<>();
systemInfoDto.setTime(DateUtil.getNow());
systemInfoDto.setData(memInfo);
RedisUtil.lSet(key, systemInfoDto);
Map<String, String> infoMap = new HashMap<>();
infoMap.put("time", DateUtil.getNow());
infoMap.put("data", memInfo + "");
RedisUtil.lSet(key, infoMap);
// 每秒一个最多只存30个
if (RedisUtil.lGetListSize(key) > 30) {
if (RedisUtil.lGetListSize(key) >= 30) {
for (int i = 0; i < RedisUtil.lGetListSize(key) - 30; i++) {
RedisUtil.lLeftPop(key);
}
@@ -722,20 +723,34 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
}
@Override
public void addNetInfo(Map<String, String> networkInterfaces) {
public void addNetInfo(Map<String, Double> networkInterfaces) {
String key = VideoManagerConstants.SYSTEM_INFO_NET_PREFIX + userSetting.getServerId();
SystemInfoDto<Map<String, String>> systemInfoDto = new SystemInfoDto<>();
systemInfoDto.setTime(DateUtil.getNow());
systemInfoDto.setData(networkInterfaces);
RedisUtil.lSet(key, systemInfoDto);
Map<String, Object> infoMap = new HashMap<>();
infoMap.put("time", DateUtil.getNow());
for (String netKey : networkInterfaces.keySet()) {
infoMap.put(netKey, networkInterfaces.get(netKey));
}
RedisUtil.lSet(key, infoMap);
// 每秒一个最多只存30个
if (RedisUtil.lGetListSize(key) > 30) {
if (RedisUtil.lGetListSize(key) >= 30) {
for (int i = 0; i < RedisUtil.lGetListSize(key) - 30; i++) {
RedisUtil.lLeftPop(key);
}
}
}
@Override
public SystemAllInfo getSystemInfo() {
String cpuKey = VideoManagerConstants.SYSTEM_INFO_CPU_PREFIX + userSetting.getServerId();
String memKey = VideoManagerConstants.SYSTEM_INFO_MEM_PREFIX + userSetting.getServerId();
String netKey = VideoManagerConstants.SYSTEM_INFO_NET_PREFIX + userSetting.getServerId();
SystemAllInfo systemAllInfo = new SystemAllInfo();
systemAllInfo.setCpu(RedisUtil.lGet(cpuKey, 0, -1));
systemAllInfo.setMem(RedisUtil.lGet(memKey, 0, -1));
systemAllInfo.setNet(RedisUtil.lGet(netKey, 0, -1));
return systemAllInfo;
}
@Override
public void sendMobilePositionMsg(JSONObject jsonObject) {
String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_MOBILE_POSITION;