From e2678f39e32239f6b7a7f3472f433752d8d8db32 Mon Sep 17 00:00:00 2001 From: lin <648540858@qq.com> Date: Fri, 25 Apr 2025 18:04:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/common/StatisticsInfo.java | 97 +++++++++++++++++++ .../iot/vmp/conf/CivilCodeFileConf.java | 2 +- .../iot/vmp/conf/StatisticsInfoTask.java | 54 +++++++++++ .../gb28181/service/impl/PlayServiceImpl.java | 4 +- .../vmp/media/zlm/ZLMHttpHookListener.java | 2 + .../service/impl/RecordPlanServiceImpl.java | 3 +- .../iot/vmp/utils/SystemInfoUtils.java | 17 ++++ 7 files changed, 174 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/genersoft/iot/vmp/common/StatisticsInfo.java create mode 100644 src/main/java/com/genersoft/iot/vmp/conf/StatisticsInfoTask.java diff --git a/src/main/java/com/genersoft/iot/vmp/common/StatisticsInfo.java b/src/main/java/com/genersoft/iot/vmp/common/StatisticsInfo.java new file mode 100644 index 000000000..8d7ab2817 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/common/StatisticsInfo.java @@ -0,0 +1,97 @@ +package com.genersoft.iot.vmp.common; + +import lombok.Data; + +/** + * 统计信息 + */ +@Data +public class StatisticsInfo { + + private long id; + + /** + * ID + */ + private String deviceId; + + /** + * 分支 + */ + private String branch; + + /** + * git提交版本ID + */ + private String gitCommitId; + + /** + * git地址 + */ + private String gitUrl; + + /** + * 构建版本 + */ + private String version; + + /** + * 操作系统名称 + */ + private String osName; + + /** + * 是否是docker环境 + */ + private Boolean docker; + + /** + * 架构 + */ + private String arch; + + /** + * jdk版本 + */ + private String jdkVersion; + + /** + * redis版本 + */ + private String redisVersion; + + /** + * sql数据库版本 + */ + private String sqlVersion; + + /** + * sql数据库类型, mysql/postgresql/金仓等 + */ + private String sqlType; + + /** + * 创建时间 + */ + private String time; + + @Override + public String toString() { + return "StatisticsInfo{" + + "id=" + id + + ", deviceId='" + deviceId + '\'' + + ", branch='" + branch + '\'' + + ", gitCommitId='" + gitCommitId + '\'' + + ", gitUrl='" + gitUrl + '\'' + + ", version='" + version + '\'' + + ", osName='" + osName + '\'' + + ", docker=" + docker + + ", arch='" + arch + '\'' + + ", jdkVersion='" + jdkVersion + '\'' + + ", redisVersion='" + redisVersion + '\'' + + ", sqlVersion='" + sqlVersion + '\'' + + ", sqlType='" + sqlType + '\'' + + ", time='" + time + '\'' + + '}'; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java b/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java index 28e68fb3d..15dd874a3 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java @@ -23,7 +23,7 @@ import java.nio.file.Files; */ @Slf4j @Configuration -@Order(value=14) +@Order(value=15) public class CivilCodeFileConf implements CommandLineRunner { @Autowired diff --git a/src/main/java/com/genersoft/iot/vmp/conf/StatisticsInfoTask.java b/src/main/java/com/genersoft/iot/vmp/conf/StatisticsInfoTask.java new file mode 100644 index 000000000..7bd728d6e --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/conf/StatisticsInfoTask.java @@ -0,0 +1,54 @@ +package com.genersoft.iot.vmp.conf; + +import com.genersoft.iot.vmp.common.StatisticsInfo; +import com.genersoft.iot.vmp.utils.GitUtil; +import com.genersoft.iot.vmp.utils.SystemInfoUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.core.annotation.Order; +import org.springframework.data.redis.connection.RedisConnection; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; + +import java.io.File; + +@Component +@Order(value=100) +public class StatisticsInfoTask implements CommandLineRunner { + + @Autowired + private GitUtil gitUtil; + + @Autowired + private RedisTemplate redisTemplate; + + @Override + public void run(String... args) throws Exception { + StatisticsInfo statisticsInfo = new StatisticsInfo(); + statisticsInfo.setDeviceId(SystemInfoUtils.getHardwareId()); + statisticsInfo.setBranch(gitUtil.getBranch()); + statisticsInfo.setGitCommitId(gitUtil.getGitCommitId()); + statisticsInfo.setGitUrl(gitUtil.getGitUrl()); + + statisticsInfo.setOsName(System.getProperty("os.name")); + statisticsInfo.setArch(System.getProperty("os.arch")); + statisticsInfo.setJdkVersion(System.getProperty("java.version")); + + statisticsInfo.setDocker(new File("/.dockerenv").exists()); + + statisticsInfo.setRedisVersion(getRedisVersion()); + +// statisticsInfo.setSqlVersion(); + } + + public String getRedisVersion() { + if (redisTemplate.getConnectionFactory() == null) { + return null; + } + RedisConnection connection = redisTemplate.getConnectionFactory().getConnection(); + if (connection.info() == null) { + return null; + } + return connection.info().getProperty("redis_version"); + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java index f952041f3..6a27dd816 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java @@ -1048,8 +1048,8 @@ public class PlayServiceImpl implements IPlayService { null); return; } - log.info("[录像下载] deviceId: {}, channelId: {}, 下载速度:{}, 收流端口:{}, 收流模式:{}, SSRC: {}({}), SSRC校验:{}", - device.getDeviceId(), channel.getDeviceId(), downloadSpeed, ssrcInfo.getPort(), device.getStreamMode(), + log.info("[录像下载] deviceId: {}, channelId: {}, 开始时间: {}, 结束时间: {}, 下载速度:{}, 收流端口:{}, 收流模式:{}, SSRC: {}({}), SSRC校验:{}", + device.getDeviceId(), channel.getDeviceId(), startTime, endTime, downloadSpeed, ssrcInfo.getPort(), device.getStreamMode(), ssrcInfo.getSsrc(), String.format("%08x", Long.parseLong(ssrcInfo.getSsrc())).toUpperCase(), device.isSsrcCheck()); diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java index 399d4cac7..95dcf514e 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java @@ -189,6 +189,8 @@ public class ZLMHttpHookListener { JSONObject ret = new JSONObject(); boolean close = mediaService.closeStreamOnNoneReader(param.getMediaServerId(), param.getApp(), param.getStream(), param.getSchema()); + log.info("[ZLM HOOK]流无人观看是否触发关闭:{}, {}->{}->{}/{}", close, param.getMediaServerId(), param.getSchema(), + param.getApp(), param.getStream()); ret.put("code", 0); ret.put("close", close); return ret; diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java index 6f8783f9f..05c4d5fa2 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java @@ -81,7 +81,6 @@ public class RecordPlanServiceImpl implements IRecordPlanService { @Scheduled(fixedRate = 1, timeUnit = TimeUnit.MINUTES) public void execution() { - log.info("[录制计划] 执行"); // 查询现在需要录像的通道Id List startChannelIdList = queryCurrentChannelRecord(); @@ -221,7 +220,7 @@ public class RecordPlanServiceImpl implements IRecordPlanService { } } // TODO 更新录像队列 - + } @Override 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 534384e11..b389d69e0 100755 --- a/src/main/java/com/genersoft/iot/vmp/utils/SystemInfoUtils.java +++ b/src/main/java/com/genersoft/iot/vmp/utils/SystemInfoUtils.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.utils; import lombok.extern.slf4j.Slf4j; +import org.springframework.util.DigestUtils; import oshi.SystemInfo; import oshi.hardware.CentralProcessor; import oshi.hardware.GlobalMemory; @@ -9,6 +10,7 @@ import oshi.hardware.NetworkIF; import oshi.software.os.OperatingSystem; import java.io.File; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -142,4 +144,19 @@ public class SystemInfoUtils { } return result; } + + public static String getHardwareId(){ + SystemInfo systemInfo = new SystemInfo(); + HardwareAbstractionLayer hardware = systemInfo.getHardware(); + // CPU ID + String cpuId = hardware.getProcessor().getProcessorIdentifier().getProcessorID(); + // 主板序号 + String serialNumber = hardware.getComputerSystem().getSerialNumber(); + + return DigestUtils.md5DigestAsHex( + ( + DigestUtils.md5DigestAsHex(cpuId.getBytes(StandardCharsets.UTF_8)) + + DigestUtils.md5DigestAsHex(serialNumber.getBytes(StandardCharsets.UTF_8)) + ).getBytes(StandardCharsets.UTF_8)); + } }