diff --git a/src/main/java/com/genersoft/iot/vmp/common/SystemAllInfo.java b/src/main/java/com/genersoft/iot/vmp/common/SystemAllInfo.java index eb6a37db..48485da8 100644 --- a/src/main/java/com/genersoft/iot/vmp/common/SystemAllInfo.java +++ b/src/main/java/com/genersoft/iot/vmp/common/SystemAllInfo.java @@ -8,6 +8,10 @@ public class SystemAllInfo { private List mem; private List net; + private long netTotal; + + private Object disk; + public List getCpu() { return cpu; } @@ -31,4 +35,20 @@ public class SystemAllInfo { public void setNet(List net) { this.net = net; } + + public Object getDisk() { + return disk; + } + + public void setDisk(Object disk) { + this.disk = disk; + } + + public long getNetTotal() { + return netTotal; + } + + public void setNetTotal(long netTotal) { + this.netTotal = netTotal; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/common/SystemInfoDto.java b/src/main/java/com/genersoft/iot/vmp/common/SystemInfoDto.java deleted file mode 100644 index 81a93acf..00000000 --- a/src/main/java/com/genersoft/iot/vmp/common/SystemInfoDto.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.genersoft.iot.vmp.common; - -public class SystemInfoDto { - private String time; - private T data; - - public String getTime() { - return time; - } - - public void setTime(String time) { - this.time = time; - } - - public T getData() { - return data; - } - - public void setData(T data) { - this.data = data; - } -} diff --git a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java index 6d523084..47e51baa 100644 --- a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java +++ b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java @@ -27,11 +27,9 @@ public class VideoManagerConstants { public static final String KEEPLIVEKEY_PREFIX = "VMP_KEEPALIVE_"; - // 此处多了一个_,暂不修改 + // TODO 此处多了一个_,暂不修改 public static final String PLAYER_PREFIX = "VMP_PLAYER_"; public static final String PLAY_BLACK_PREFIX = "VMP_PLAYBACK_"; - public static final String PLAY_INFO_PREFIX = "VMP_PLAY_INFO_"; - public static final String DOWNLOAD_PREFIX = "VMP_DOWNLOAD_"; public static final String PLATFORM_KEEPALIVE_PREFIX = "VMP_PLATFORM_KEEPALIVE_"; @@ -70,6 +68,8 @@ public class VideoManagerConstants { public static final String SYSTEM_INFO_NET_PREFIX = "VMP_SYSTEM_INFO_NET_"; + public static final String SYSTEM_INFO_DISK_PREFIX = "VMP_SYSTEM_INFO_DISK_"; + diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SystemInfoTimerTask.java b/src/main/java/com/genersoft/iot/vmp/conf/SystemInfoTimerTask.java index 5a84e250..9bc86261 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/SystemInfoTimerTask.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/SystemInfoTimerTask.java @@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import java.util.List; import java.util.Map; /** @@ -31,6 +32,8 @@ public class SystemInfoTimerTask { redisCatchStorage.addMemInfo(memInfo); Map networkInterfaces = SystemInfoUtils.getNetworkInterfaces(); redisCatchStorage.addNetInfo(networkInterfaces); + List> diskInfo =SystemInfoUtils.getDiskInfo(); + redisCatchStorage.addDiskInfo(diskInfo); } catch (InterruptedException e) { logger.error("[获取系统信息失败] {}", e.getMessage()); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipDeviceRunner.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipDeviceRunner.java deleted file mode 100644 index 91d8c3da..00000000 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipDeviceRunner.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.task; - -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.service.IDeviceService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; - - -/** - * 系统启动时控制设备 - * @author lin - */ -@Component -@Order(value=4) -public class SipDeviceRunner implements CommandLineRunner { - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private UserSetting userSetting; - - @Autowired - private IDeviceService deviceService; - - @Override - public void run(String... args) throws Exception { - List deviceList = deviceService.getAllOnlineDevice(); - - for (Device device : deviceList) { - if (deviceService.expire(device)){ - deviceService.offline(device.getDeviceId()); - }else { - deviceService.online(device); - } - } - // 重置cseq计数 - redisCatchStorage.resetAllCSEQ(); - } -} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java new file mode 100644 index 00000000..e04bad95 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java @@ -0,0 +1,95 @@ +package com.genersoft.iot.vmp.gb28181.task; + +import com.alibaba.fastjson.JSONObject; +import com.genersoft.iot.vmp.conf.UserSetting; +import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; +import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; +import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; +import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; +import com.genersoft.iot.vmp.service.IDeviceService; +import com.genersoft.iot.vmp.service.IMediaServerService; +import com.genersoft.iot.vmp.service.IPlatformService; +import com.genersoft.iot.vmp.storager.IRedisCatchStorage; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * 系统启动时控制设备 + * @author lin + */ +@Component +@Order(value=4) +public class SipRunner implements CommandLineRunner { + + @Autowired + private IVideoManagerStorage storager; + + @Autowired + private IRedisCatchStorage redisCatchStorage; + + @Autowired + private UserSetting userSetting; + + @Autowired + private IDeviceService deviceService; + + @Autowired + private ZLMRESTfulUtils zlmresTfulUtils; + + @Autowired + private IMediaServerService mediaServerService; + + @Autowired + private IPlatformService platformService; + + @Autowired + private ISIPCommanderForPlatform commanderForPlatform; + + @Override + public void run(String... args) throws Exception { + List deviceList = deviceService.getAllOnlineDevice(); + + for (Device device : deviceList) { + if (deviceService.expire(device)){ + deviceService.offline(device.getDeviceId()); + }else { + deviceService.online(device); + } + } + // 重置cseq计数 + redisCatchStorage.resetAllCSEQ(); + // 清理redis + // 查找国标推流 + List sendRtpItems = redisCatchStorage.queryAllSendRTPServer(); + if (sendRtpItems.size() > 0) { + for (SendRtpItem sendRtpItem : sendRtpItems) { + MediaServerItem mediaServerItem = mediaServerService.getOne(sendRtpItem.getMediaServerId()); + redisCatchStorage.deleteSendRTPServer(sendRtpItem.getPlatformId(),sendRtpItem.getChannelId(), sendRtpItem.getCallId(),sendRtpItem.getStreamId()); + if (mediaServerItem != null) { + Map param = new HashMap<>(); + param.put("vhost","__defaultVhost__"); + param.put("app",sendRtpItem.getApp()); + param.put("stream",sendRtpItem.getStreamId()); + param.put("ssrc",sendRtpItem.getSsrc()); + JSONObject jsonObject = zlmresTfulUtils.stopSendRtp(mediaServerItem, param); + if (jsonObject != null && jsonObject.getInteger("code") == 0) { + ParentPlatform platform = platformService.queryPlatformByServerGBId(sendRtpItem.getPlatformId()); + if (platform != null) { + commanderForPlatform.streamByeCmd(platform, sendRtpItem.getCallId()); + } + } + } + } + } + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java b/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java index 9629e3a8..3f587358 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.service; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; import java.util.List; @@ -32,4 +33,9 @@ public interface IDeviceChannelService { */ int updateChannels(String deviceId, List channels); + /** + * 获取统计信息 + * @return + */ + ResourceBaceInfo getOverview(); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java b/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java index 24051b90..b87c9a73 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java @@ -4,6 +4,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.SyncStatus; import com.genersoft.iot.vmp.vmanager.bean.BaseTree; +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; import java.util.List; @@ -155,4 +156,11 @@ public interface IDeviceService { * @return */ boolean delete(String deviceId); + + /** + * 获取统计信息 + * @return + */ + ResourceBaceInfo getOverview(); + } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java b/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java index 0ecc717e..dd081017 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java @@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; +import com.genersoft.iot.vmp.service.bean.MediaServerLoad; import com.genersoft.iot.vmp.service.bean.SSRCInfo; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import java.util.List; +import java.util.Map; /** * 媒体服务节点 @@ -87,4 +89,10 @@ public interface IMediaServerService { void updateMediaServerKeepalive(String mediaServerId, JSONObject data); boolean checkRtpServer(MediaServerItem mediaServerItem, String rtp, String stream); + + /** + * 获取负载信息 + * @return + */ + MediaServerLoad getLoad(MediaServerItem mediaServerItem); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java b/src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java index 1395a526..a2678b83 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; import com.github.pagehelper.PageInfo; public interface IStreamProxyService { @@ -102,4 +103,11 @@ public interface IStreamProxyService { * 更新代理流 */ boolean updateStreamProxy(StreamProxyItem streamProxyItem); + + /** + * 获取统计信息 + * @return + */ + ResourceBaceInfo getOverview(); + } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java b/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java index 5dbba926..4bccc3f0 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java @@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis; +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto; import com.github.pagehelper.PageInfo; @@ -106,4 +107,10 @@ public interface IStreamPushService { * @return */ List getAllAppAndStream(); + + /** + * 获取统计信息 + * @return + */ + ResourceBaceInfo getOverview(); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/bean/MediaServerLoad.java b/src/main/java/com/genersoft/iot/vmp/service/bean/MediaServerLoad.java new file mode 100644 index 00000000..cb30f67a --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/bean/MediaServerLoad.java @@ -0,0 +1,50 @@ +package com.genersoft.iot.vmp.service.bean; + +public class MediaServerLoad { + + private String id; + private int push; + private int proxy; + private int gbReceive; + private int gbSend; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public int getPush() { + return push; + } + + public void setPush(int push) { + this.push = push; + } + + public int getProxy() { + return proxy; + } + + public void setProxy(int proxy) { + this.proxy = proxy; + } + + public int getGbReceive() { + return gbReceive; + } + + public void setGbReceive(int gbReceive) { + this.gbReceive = gbReceive; + } + + public int getGbSend() { + return gbSend; + } + + public void setGbSend(int gbSend) { + this.gbSend = gbSend; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java index 99ad3dee..41b55ddc 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java @@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; import com.genersoft.iot.vmp.storager.dao.DeviceMapper; import com.genersoft.iot.vmp.utils.DateUtil; +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -162,4 +163,9 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { } return addChannels.size() + updateChannels.size(); } + + @Override + public ResourceBaceInfo getOverview() { + return channelMapper.getOverview(); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index 23a342b7..16c9803e 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -19,6 +19,7 @@ import com.genersoft.iot.vmp.storager.dao.DeviceMapper; import com.genersoft.iot.vmp.storager.dao.PlatformChannelMapper; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.BaseTree; +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -620,4 +621,9 @@ public class DeviceServiceImpl implements IDeviceService { } return result; } + + @Override + public ResourceBaceInfo getOverview() { + return deviceMapper.getOverview(); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java index 7c5b1499..90a73b3e 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java @@ -10,6 +10,8 @@ import java.util.Set; import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.exception.ControllerException; +import com.genersoft.iot.vmp.service.bean.MediaServerLoad; +import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -90,6 +92,9 @@ public class MediaServerServiceImpl implements IMediaServerService { @Autowired private DynamicTask dynamicTask; + @Autowired + private IRedisCatchStorage redisCatchStorage; + /** * 初始化 */ @@ -691,4 +696,15 @@ public class MediaServerServiceImpl implements IMediaServerService { } return false; } + + @Override + public MediaServerLoad getLoad(MediaServerItem mediaServerItem) { + MediaServerLoad result = new MediaServerLoad(); + result.setId(mediaServerItem.getId()); + result.setPush(redisCatchStorage.getPushStreamCount(mediaServerItem.getId())); + result.setProxy(redisCatchStorage.getProxyStreamCount(mediaServerItem.getId())); + result.setGbReceive(redisCatchStorage.getGbReceiveCount(mediaServerItem.getId())); + result.setGbSend(redisCatchStorage.getGbSendCount(mediaServerItem.getId())); + return result; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java index f54147e7..6798b488 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java @@ -26,6 +26,7 @@ import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper; import com.genersoft.iot.vmp.service.IStreamProxyService; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.github.pagehelper.PageInfo; import org.slf4j.Logger; @@ -454,4 +455,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService { } } + + @Override + public ResourceBaceInfo getOverview() { + return streamProxyMapper.getOverview(); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java index 00980f9c..1bc8b2fb 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java @@ -18,6 +18,7 @@ import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.dao.*; import com.genersoft.iot.vmp.utils.DateUtil; +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.slf4j.Logger; @@ -507,6 +508,12 @@ public class StreamPushServiceImpl implements IStreamPushService { @Override public List getAllAppAndStream() { + return streamPushMapper.getAllAppAndStream(); } + + @Override + public ResourceBaceInfo getOverview() { + return streamPushMapper.getOverview(userSetting.isUsePushingAsStatus()); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java index 77bd61ca..e2f8fca5 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java @@ -244,4 +244,16 @@ public interface IRedisCatchStorage { SystemAllInfo getSystemInfo(); + int getPushStreamCount(String id); + + int getProxyStreamCount(String id); + + int getGbReceiveCount(String id); + + int getGbSendCount(String id); + + void addDiskInfo(List> diskInfo); + + List queryAllSendRTPServer(); + } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java index 9b2a099d..ff20cef3 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.storager.dao; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannelInPlatform; +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; @@ -347,4 +348,8 @@ public interface DeviceChannelMapper { @Select("select * from device_channel where deviceId = #{deviceId}") List queryAllChannels(String deviceId); + + + @Select("select count(1) as total, sum(status) as online from device_channel") + ResourceBaceInfo getOverview(); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java index 03dba381..b1210c62 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.storager.dao; import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; @@ -251,4 +252,8 @@ public interface DeviceMapper { "#{online}" + ")") void addCustomDevice(Device device); + + @Select("select count(1) as total, sum(online) as online from device") + ResourceBaceInfo getOverview(); + } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java index a9827ad3..448a358f 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.storager.dao; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; @@ -75,4 +76,7 @@ public interface StreamProxyMapper { @Select("SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.enable_remove_none_reader=true AND st.mediaServerId=#{mediaServerId} order by st.createTime desc") List selecAutoRemoveItemByMediaServerId(String mediaServerId); + + @Select("select count(1) as total, sum(status) as online from stream_proxy") + ResourceBaceInfo getOverview(); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java index 675a8bcd..ec51f112 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.storager.dao; import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis; +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; import org.apache.ibatis.annotations.*; // import org.omg.PortableInterceptor.INACTIVE; import org.springframework.stereotype.Repository; @@ -171,4 +172,10 @@ public interface StreamPushMapper { @Select("SELECT CONCAT(app,stream) FROM gb_stream") List getAllAppAndStream(); + + @Select(value = {" "}) + ResourceBaceInfo getOverview(boolean pushIngAsOnline); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java index 6178a3bb..b82ccf94 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java @@ -4,7 +4,6 @@ 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; import com.genersoft.iot.vmp.gb28181.bean.*; @@ -18,6 +17,7 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo; import com.genersoft.iot.vmp.utils.DateUtil; +import com.genersoft.iot.vmp.utils.SystemInfoUtils; import com.genersoft.iot.vmp.utils.redis.RedisUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -89,8 +89,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { */ @Override public boolean startPlay(StreamInfo stream) { - return RedisUtil.set(String.format("%S_%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), - stream.getStream(), stream.getDeviceID(), stream.getChannelId()), + + return RedisUtil.set(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), + stream.getMediaServerId(), stream.getStream(), stream.getDeviceID(), stream.getChannelId()), stream); } @@ -104,8 +105,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { if (streamInfo == null) { return false; } - return RedisUtil.del(String.format("%S_%s_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, + return RedisUtil.del(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), + streamInfo.getMediaServerId(), streamInfo.getStream(), streamInfo.getDeviceID(), streamInfo.getChannelId())); @@ -117,17 +119,17 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { */ @Override public StreamInfo queryPlay(StreamInfo streamInfo) { - return (StreamInfo)RedisUtil.get(String.format("%S_%s_%s_%s_%s", + return (StreamInfo)RedisUtil.get(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), + streamInfo.getMediaServerId(), streamInfo.getStream(), streamInfo.getDeviceID(), streamInfo.getChannelId())); } @Override public StreamInfo queryPlayByStreamId(String streamId) { - System.out.println(String.format("%S_%s_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId)); - List playLeys = RedisUtil.scan(String.format("%S_%s_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId)); + List playLeys = RedisUtil.scan(String.format("%S_%s_*_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId)); if (playLeys == null || playLeys.size() == 0) { return null; } @@ -136,7 +138,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public StreamInfo queryPlayByDevice(String deviceId, String channelId) { - List playLeys = RedisUtil.scan(String.format("%S_%s_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX, + List playLeys = RedisUtil.scan(String.format("%S_%s_*_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), deviceId, channelId)); @@ -149,8 +151,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public Map queryPlayByDeviceId(String deviceId) { Map streamInfos = new HashMap<>(); -// List playLeys = RedisUtil.keys(String.format("%S_*_%S_*", VideoManagerConstants.PLAYER_PREFIX, deviceId)); - List players = RedisUtil.scan(String.format("%S_%s_*_%S_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(),deviceId)); + List players = RedisUtil.scan(String.format("%S_%s_*_*_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(),deviceId)); if (players.size() == 0) { return streamInfos; } @@ -165,21 +166,19 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public boolean startPlayback(StreamInfo stream, String callId) { - System.out.println(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, - userSetting.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId)); - return RedisUtil.set(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, - userSetting.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream); + return RedisUtil.set(String.format("%S_%s_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, + userSetting.getServerId(), stream.getMediaServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream); } @Override public boolean startDownload(StreamInfo stream, String callId) { boolean result; if (stream.getProgress() == 1) { - result = RedisUtil.set(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, - userSetting.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream); + result = RedisUtil.set(String.format("%S_%s_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, + userSetting.getServerId(), stream.getMediaServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream); }else { - result = RedisUtil.set(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, - userSetting.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream, 60*60); + result = RedisUtil.set(String.format("%S_%s_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, + userSetting.getServerId(), stream.getMediaServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream, 60*60); } return result; } @@ -203,7 +202,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { if (callId == null) { callId = "*"; } - String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, + String key = String.format("%S_%s_*_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, userSetting.getServerId(), deviceId, channelId, @@ -239,7 +238,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { if (callId == null) { callId = "*"; } - String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, + String key = String.format("%S_%s_*_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, userSetting.getServerId(), deviceId, channelId, @@ -272,7 +271,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { if (callId == null) { callId = "*"; } - String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, + String key = String.format("%S_%s_*_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, userSetting.getServerId(), deviceId, channelId, @@ -304,7 +303,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { if (callId == null) { callId = "*"; } - String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, + String key = String.format("%S_%s_*_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, userSetting.getServerId(), deviceId, channelId, @@ -369,9 +368,14 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public void updateSendRTPSever(SendRtpItem sendRtpItem) { - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" - + sendRtpItem.getPlatformId() + "_" + sendRtpItem.getChannelId() + "_" - + sendRtpItem.getStreamId() + "_" + sendRtpItem.getCallId(); + + String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + + userSetting.getServerId() + "_" + + sendRtpItem.getMediaServerId() + "_" + + sendRtpItem.getPlatformId() + "_" + + sendRtpItem.getChannelId() + "_" + + sendRtpItem.getStreamId() + "_" + + sendRtpItem.getCallId(); RedisUtil.set(key, sendRtpItem); } @@ -389,8 +393,12 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { if (callId == null) { callId = "*"; } - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId - + "_" + channelId + "_" + streamId + "_" + callId; + String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + + userSetting.getServerId() + "_*_" + + platformGbId + "_" + + channelId + "_" + + streamId + "_" + + callId; List scan = RedisUtil.scan(key); if (scan.size() > 0) { return (SendRtpItem)RedisUtil.get((String)scan.get(0)); @@ -407,8 +415,12 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { String platformGbId = "*"; String callId = "*"; String streamId = "*"; - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId - + "_" + channelId + "_" + streamId + "_" + callId; + String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + + userSetting.getServerId() + "_*_" + + platformGbId + "_" + + channelId + "_" + + streamId + "_" + + callId; List scan = RedisUtil.scan(key); List result = new ArrayList<>(); for (Object o : scan) { @@ -425,8 +437,12 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { String platformGbId = "*"; String callId = "*"; String channelId = "*"; - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId - + "_" + channelId + "_" + stream + "_" + callId; + String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + + userSetting.getServerId() + "_*_" + + platformGbId + "_" + + channelId + "_" + + stream + "_" + + callId; List scan = RedisUtil.scan(key); List result = new ArrayList<>(); for (Object o : scan) { @@ -440,7 +456,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { if (platformGbId == null) { platformGbId = "*"; } - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId + "_*" + "_*" + "_*"; + String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + + userSetting.getServerId() + "_*_" + + platformGbId + "_*" + "_*" + "_*"; List queryResult = RedisUtil.scan(key); List result= new ArrayList<>(); @@ -465,8 +483,12 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { if (callId == null) { callId = "*"; } - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId - + "_" + channelId + "_" + streamId + "_" + callId; + String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + + userSetting.getServerId() + "_*_" + + platformGbId + "_" + + channelId + "_" + + streamId + "_" + + callId; List scan = RedisUtil.scan(key); if (scan.size() > 0) { for (Object keyStr : scan) { @@ -475,7 +497,20 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { } } + @Override + public List queryAllSendRTPServer() { + String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + + userSetting.getServerId() + "_*"; + List queryResult = RedisUtil.scan(key); + List result= new ArrayList<>(); + for (Object o : queryResult) { + String keyItem = (String) o; + result.add((SendRtpItem) RedisUtil.get(keyItem)); + } + + return result; + } /** * 查询某个通道是否存在上级点播(RTP推送) @@ -483,7 +518,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { */ @Override public boolean isChannelSendingRTP(String channelId) { - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + "*_" + channelId + "*_" + "*_"; + String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + + userSetting.getServerId() + "_*_*_" + + channelId + "*_" + "*_"; List RtpStreams = RedisUtil.scan(key); if (RtpStreams.size() > 0) { return true; @@ -503,7 +540,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { } } - List playBackers = RedisUtil.scan(String.format("%S_%s_%s_*_*_*", VideoManagerConstants.PLAY_BLACK_PREFIX, + List playBackers = RedisUtil.scan(String.format("%S_%s_*_%s_*_*_*", VideoManagerConstants.PLAY_BLACK_PREFIX, userSetting.getServerId(), deviceId)); if (playBackers.size() > 0) { @@ -569,7 +606,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { if (callId == null) { callId = "*"; } - String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, + String key = String.format("%S_%s_*_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, userSetting.getServerId(), deviceId, channelId, @@ -739,15 +776,26 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { } } + @Override + public void addDiskInfo(List> diskInfo) { + + String key = VideoManagerConstants.SYSTEM_INFO_DISK_PREFIX + userSetting.getServerId(); + RedisUtil.set(key, diskInfo); + } + @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(); + String diskKey = VideoManagerConstants.SYSTEM_INFO_DISK_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)); + + systemAllInfo.setDisk(RedisUtil.get(diskKey)); + systemAllInfo.setNetTotal(SystemInfoUtils.getNetworkTotal()); return systemAllInfo; } @@ -786,4 +834,32 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { jsonObject.put(key, key); RedisUtil.convertAndSend(key, jsonObject); } + + @Override + public int getPushStreamCount(String id) { + String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_PUSH_*_*_" + id; + return RedisUtil.scan(key).size(); + } + + @Override + public int getProxyStreamCount(String id) { + String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_PULL_*_*_" + id; + return RedisUtil.scan(key).size(); + } + + @Override + public int getGbReceiveCount(String id) { + String playKey = VideoManagerConstants.PLAYER_PREFIX + "_" + userSetting.getServerId() + "_" + id + "_*"; + String playBackKey = VideoManagerConstants.PLAY_BLACK_PREFIX + "_" + userSetting.getServerId() + "_" + id + "_*"; + String downloadKey = VideoManagerConstants.DOWNLOAD_PREFIX + "_" + userSetting.getServerId() + "_" + id + "_*"; + + return RedisUtil.scan(playKey).size() + RedisUtil.scan(playBackKey).size() + RedisUtil.scan(downloadKey).size(); + } + + @Override + public int getGbSendCount(String id) { + String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + + userSetting.getServerId() + "_*_" + id + "_*"; + return RedisUtil.scan(key).size(); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/utils/GitUtil.java b/src/main/java/com/genersoft/iot/vmp/utils/GitUtil.java index ca637dda..ed0e0fd4 100644 --- a/src/main/java/com/genersoft/iot/vmp/utils/GitUtil.java +++ b/src/main/java/com/genersoft/iot/vmp/utils/GitUtil.java @@ -13,7 +13,7 @@ public class GitUtil { @Value("${git.branch:}") private String branch; - @Value("${git.commit.id:}") + @Value("${git.commit.id.abbrev:}") private String gitCommitId; @Value("${git.remote.origin.url:}") private String gitUrl; diff --git a/src/main/java/com/genersoft/iot/vmp/utils/SystemInfoUtils.java b/src/main/java/com/genersoft/iot/vmp/utils/SystemInfoUtils.java index 3af4853e..d228787b 100644 --- a/src/main/java/com/genersoft/iot/vmp/utils/SystemInfoUtils.java +++ b/src/main/java/com/genersoft/iot/vmp/utils/SystemInfoUtils.java @@ -1,14 +1,14 @@ package com.genersoft.iot.vmp.utils; +import org.springframework.util.ObjectUtils; import oshi.SystemInfo; -import oshi.hardware.CentralProcessor; -import oshi.hardware.GlobalMemory; -import oshi.hardware.HardwareAbstractionLayer; -import oshi.hardware.NetworkIF; +import oshi.hardware.*; import oshi.software.os.OperatingSystem; import oshi.util.FormatUtil; +import java.io.File; import java.text.DecimalFormat; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -85,6 +85,19 @@ public class SystemInfoUtils { return map; } + /** + * 获取带宽总值 + * @return + */ + public static long getNetworkTotal() { + SystemInfo si = new SystemInfo(); + HardwareAbstractionLayer hal = si.getHardware(); + List recvNetworkIFs = hal.getNetworkIFs(); + NetworkIF networkIF= recvNetworkIFs.get(recvNetworkIFs.size() - 1); + + return networkIF.getSpeed()/1048576L/8L; + } + public static double formatUnits(long value, long prefix) { return (double)value / (double)prefix; } @@ -100,4 +113,31 @@ public class SystemInfoUtils { int processCount = os.getProcessCount(); return processCount; } + + public static List> getDiskInfo() { + List> result = new ArrayList<>(); + + String osName = System.getProperty("os.name"); + List pathArray = new ArrayList<>(); + if (osName.startsWith("Mac OS")) { + // 苹果 + pathArray.add("/"); + } else if (osName.startsWith("Windows")) { + // windows + pathArray.add("C:"); + } else { + pathArray.add("/"); + pathArray.add("/home"); + } + for (String path : pathArray) { + Map infoMap = new HashMap<>(); + infoMap.put("path", path); + File partitionFile = new File(path); + // 单位: GB + infoMap.put("use", (partitionFile.getTotalSpace() - partitionFile.getFreeSpace())/1024/1024/1024D); + infoMap.put("free", partitionFile.getFreeSpace()/1024/1024/1024D); + result.add(infoMap); + } + return result; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ResourceBaceInfo.java b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ResourceBaceInfo.java new file mode 100644 index 00000000..b50d97a0 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ResourceBaceInfo.java @@ -0,0 +1,22 @@ +package com.genersoft.iot.vmp.vmanager.bean; + +public class ResourceBaceInfo { + private int total; + private int online; + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public int getOnline() { + return online; + } + + public void setOnline(int online) { + this.online = online; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ResourceInfo.java b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ResourceInfo.java new file mode 100644 index 00000000..b8d7009f --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ResourceInfo.java @@ -0,0 +1,41 @@ +package com.genersoft.iot.vmp.vmanager.bean; + +public class ResourceInfo { + + private ResourceBaceInfo device; + private ResourceBaceInfo channel; + private ResourceBaceInfo push; + private ResourceBaceInfo proxy; + + public ResourceBaceInfo getDevice() { + return device; + } + + public void setDevice(ResourceBaceInfo device) { + this.device = device; + } + + public ResourceBaceInfo getChannel() { + return channel; + } + + public void setChannel(ResourceBaceInfo channel) { + this.channel = channel; + } + + public ResourceBaceInfo getPush() { + return push; + } + + public void setPush(ResourceBaceInfo push) { + this.push = push; + } + + public ResourceBaceInfo getProxy() { + return proxy; + } + + public void setProxy(ResourceBaceInfo proxy) { + this.proxy = proxy; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java index ef2d748d..ed6f44da 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java @@ -12,10 +12,13 @@ import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; import com.genersoft.iot.vmp.media.zlm.dto.IHookSubscribe; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.service.IMediaServerService; +import com.genersoft.iot.vmp.service.*; +import com.genersoft.iot.vmp.service.bean.MediaServerLoad; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.utils.SpringBeanFactory; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; +import com.genersoft.iot.vmp.vmanager.bean.ResourceInfo; import gov.nist.javax.sip.SipStackImpl; import io.swagger.v3.oas.annotations.Operation; @@ -30,8 +33,7 @@ import org.springframework.web.bind.annotation.*; import javax.sip.ListeningPoint; import javax.sip.ObjectInUseException; import javax.sip.SipProvider; -import java.util.Iterator; -import java.util.List; +import java.util.*; @SuppressWarnings("rawtypes") @Tag(name = "服务控制") @@ -55,6 +57,20 @@ public class ServerController { @Autowired private UserSetting userSetting; + @Autowired + private IDeviceService deviceService; + + @Autowired + private IDeviceChannelService channelService; + + @Autowired + private IStreamPushService pushService; + + + @Autowired + private IStreamProxyService proxyService; + + @Value("${server.port}") private int serverPort; @@ -213,6 +229,40 @@ public class ServerController { @Operation(summary = "获取系统信息") public SystemAllInfo getSystemInfo() { SystemAllInfo systemAllInfo = redisCatchStorage.getSystemInfo(); + return systemAllInfo; } + + @GetMapping(value = "/media_server/load") + @ResponseBody + @Operation(summary = "获取负载信息") + public List getMediaLoad() { + List result = new ArrayList<>(); + List allOnline = mediaServerService.getAllOnline(); + if (allOnline.size() == 0) { + return result; + }else { + for (MediaServerItem mediaServerItem : allOnline) { + result.add(mediaServerService.getLoad(mediaServerItem)); + } + } + return result; + } + + @GetMapping(value = "/resource/info") + @ResponseBody + @Operation(summary = "获取负载信息") + public ResourceInfo getResourceInfo() { + ResourceInfo result = new ResourceInfo(); + ResourceBaceInfo deviceInfo = deviceService.getOverview(); + result.setDevice(deviceInfo); + ResourceBaceInfo channelInfo = channelService.getOverview(); + result.setChannel(channelInfo); + ResourceBaceInfo pushInfo = pushService.getOverview(); + result.setPush(pushInfo); + ResourceBaceInfo proxyInfo = proxyService.getOverview(); + result.setProxy(proxyInfo); + + return result; + } } diff --git a/web_src/src/components/console.vue b/web_src/src/components/console.vue index f663aaa1..352989f3 100644 --- a/web_src/src/components/console.vue +++ b/web_src/src/components/console.vue @@ -2,6 +2,10 @@
@@ -14,7 +18,7 @@
- +
@@ -28,26 +32,25 @@
- + +
- +
- +
- -
@@ -57,6 +60,9 @@ import uiHeader from '../layout/UiHeader.vue' import consoleCPU from './console/ConsoleCPU.vue' import consoleMem from './console/ConsoleMEM.vue' import consoleNet from './console/ConsoleNet.vue' +import consoleNodeLoad from './console/ConsoleNodeLoad.vue' +import consoleDisk from './console/ConsoleDisk.vue' +import consoleResource from './console/ConsoleResource.vue' import echarts from 'echarts'; @@ -67,7 +73,10 @@ export default { uiHeader, consoleCPU, consoleMem, - consoleNet + consoleNet, + consoleNodeLoad, + consoleDisk, + consoleResource, }, data() { return { @@ -76,7 +85,10 @@ export default { }, created() { this.getSystemInfo(); + this.getLoad(); + this.getResourceInfo(); this.loopForSystemInfo(); + }, destroyed() { }, @@ -87,8 +99,10 @@ export default { } this.timer = setTimeout(()=>{ this.getSystemInfo(); + this.getLoad(); this.timer = null; this.loopForSystemInfo() + this.getResourceInfo() }, 2000) }, getSystemInfo: function (){ @@ -99,11 +113,38 @@ export default { if (res.data.code === 0) { this.$refs.consoleCPU.setData(res.data.data.cpu) this.$refs.consoleMem.setData(res.data.data.mem) - this.$refs.consoleNet.setData(res.data.data.net) + this.$refs.consoleNet.setData(res.data.data.net, res.data.data.netTotal) + this.$refs.consoleDisk.setData(res.data.data.disk) } }).catch( (error)=> { }); + }, + getLoad: function (){ + this.$axios({ + method: 'get', + url: `/api/server/media_server/load`, + }).then( (res)=> { + if (res.data.code === 0) { + this.$refs.consoleNodeLoad.setData(res.data.data) + } + }).catch( (error)=> { + }); + }, + getResourceInfo: function (){ + this.$axios({ + method: 'get', + url: `/api/server/resource/info`, + }).then( (res)=> { + if (res.data.code === 0) { + this.$refs.consoleResource.setData(res.data.data) + } + }).catch( (error)=> { + }); + }, + showInfo: function (){ + } + } }; diff --git a/web_src/src/components/console/ConsoleCPU.vue b/web_src/src/components/console/ConsoleCPU.vue index 0b4ecb20..5aed07ed 100644 --- a/web_src/src/components/console/ConsoleCPU.vue +++ b/web_src/src/components/console/ConsoleCPU.vue @@ -1,6 +1,6 @@ @@ -59,7 +59,8 @@ export default { trigger: 'axis', formatter: (data)=>{ console.log(data) - return moment(data[0].data[0]).format("HH:mm:ss") + "
使用:" + (data[0].data[1]*100).toFixed(2) + "%"; + return moment(data[0].data[0]).format("HH:mm:ss") + "
" + + data[0].marker + "使用:" + (data[0].data[1]*100).toFixed(2) + "%"; } }, series: { @@ -84,14 +85,17 @@ export default { } } }; + }, + created() { + + }, mounted() { - // setInterval(()=>{ - // // console.log(111111) - // for (let i = 0; i < this.chartData.rows.length; i++) { - // this.chartData.rows[i].销售额 += 1000; - // } - // },1000) + this.$nextTick(_ => { + setTimeout(()=>{ + this.$refs.consoleCPU.echarts.resize() + }, 100) + }) }, destroyed() { }, diff --git a/web_src/src/components/console/ConsoleDisk.vue b/web_src/src/components/console/ConsoleDisk.vue new file mode 100644 index 00000000..ed69cc3f --- /dev/null +++ b/web_src/src/components/console/ConsoleDisk.vue @@ -0,0 +1,81 @@ + + + diff --git a/web_src/src/components/console/ConsoleMEM.vue b/web_src/src/components/console/ConsoleMEM.vue index beaa38cc..566b469b 100644 --- a/web_src/src/components/console/ConsoleMEM.vue +++ b/web_src/src/components/console/ConsoleMEM.vue @@ -1,6 +1,6 @@ @@ -59,7 +59,7 @@ export default { trigger: 'axis', formatter: (data)=>{ console.log(data) - return moment(data[0].data[0]).format("HH:mm:ss") + "
使用:" + (data[0].data[1]*100).toFixed(2) + "%"; + return moment(data[0].data[0]).format("HH:mm:ss") + "
"+ data[0].marker +" 使用:" + (data[0].data[1]*100).toFixed(2) + "%"; } }, series: { @@ -86,12 +86,11 @@ export default { }; }, mounted() { - // setInterval(()=>{ - // // console.log(111111) - // for (let i = 0; i < this.chartData.rows.length; i++) { - // this.chartData.rows[i].销售额 += 1000; - // } - // },1000) + this.$nextTick(_ => { + setTimeout(()=>{ + this.$refs.ConsoleMEM.echarts.resize() + }, 100) + }) }, destroyed() { }, @@ -99,7 +98,6 @@ export default { setData: function(data) { this.chartData .rows = data; } - } }; diff --git a/web_src/src/components/console/ConsoleMediaServer.vue b/web_src/src/components/console/ConsoleMediaServer.vue index 810ee39e..a842b503 100644 --- a/web_src/src/components/console/ConsoleMediaServer.vue +++ b/web_src/src/components/console/ConsoleMediaServer.vue @@ -1,6 +1,6 @@ @@ -66,12 +66,11 @@ export default { }; }, mounted() { - // setInterval(()=>{ - // // console.log(111111) - // for (let i = 0; i < this.chartData.rows.length; i++) { - // this.chartData.rows[i].销售额 += 1000; - // } - // },1000) + this.$nextTick(_ => { + setTimeout(()=>{ + this.$refs.ConsoleMEM.echarts.resize() + }, 100) + }) }, destroyed() { }, diff --git a/web_src/src/components/console/ConsoleNet.vue b/web_src/src/components/console/ConsoleNet.vue index a6d7111a..22d4f343 100644 --- a/web_src/src/components/console/ConsoleNet.vue +++ b/web_src/src/components/console/ConsoleNet.vue @@ -1,6 +1,6 @@ @@ -14,7 +14,7 @@ export default { data() { return { chartData: { - columns: ['time', 'in', 'out'], + columns: ['time','out','in'], rows: [] }, chartSettings: { @@ -48,13 +48,18 @@ export default { showMaxLabel: true, }, }, + yAxis: { + type: 'value', + min: 0, + max: 1000, + splitNumber: 6, + position: "left", + silent: true, + }, tooltip: { trigger: 'axis', formatter: (data)=>{ - console.log(parseFloat(data[0].data[1]).toFixed(2)) - console.log(parseFloat(data[1].data[1]).toFixed(2)) - console.log("############") - return "下载:" + parseFloat(data[0].data[1]).toFixed(2) + "Mbps" + "
上传:" + parseFloat(data[1].data[1]).toFixed(2) + "Mbps"; + return data[1].marker + "下载:" + parseFloat(data[1].data[1]).toFixed(2) + "Mbps" + "
"+ data[0].marker +" 上传:" + parseFloat(data[0].data[1]).toFixed(2) + "Mbps"; } }, legend: { @@ -65,19 +70,18 @@ export default { }; }, mounted() { - // setInterval(()=>{ - // // console.log(111111) - // for (let i = 0; i < this.chartData.rows.length; i++) { - // this.chartData.rows[i].销售额 += 1000; - // } - // },1000) + this.$nextTick(_ => { + setTimeout(()=>{ + this.$refs.ConsoleNet.echarts.resize() + }, 100) + }) }, destroyed() { }, methods: { - setData: function(data) { - console.log(data) + setData: function(data, total) { this.chartData .rows = data; + this.extend.yAxis.max= total; } } diff --git a/web_src/src/components/console/ConsoleNodeLoad.vue b/web_src/src/components/console/ConsoleNodeLoad.vue new file mode 100644 index 00000000..0596c41e --- /dev/null +++ b/web_src/src/components/console/ConsoleNodeLoad.vue @@ -0,0 +1,63 @@ + + + diff --git a/web_src/src/components/console/ConsoleResource.vue b/web_src/src/components/console/ConsoleResource.vue new file mode 100644 index 00000000..c76b270d --- /dev/null +++ b/web_src/src/components/console/ConsoleResource.vue @@ -0,0 +1,86 @@ + + + + + diff --git a/web_src/src/layout/UiHeader.vue b/web_src/src/layout/UiHeader.vue index 42d617e9..fa9be3ef 100644 --- a/web_src/src/layout/UiHeader.vue +++ b/web_src/src/layout/UiHeader.vue @@ -4,7 +4,7 @@ - 控制台 + 控制台 分屏监控 国标设备 电子地图 diff --git a/web_src/src/layout/index.vue b/web_src/src/layout/index.vue index dccf6627..d6afcf64 100644 --- a/web_src/src/layout/index.vue +++ b/web_src/src/layout/index.vue @@ -24,6 +24,9 @@ export default { }