tcpdump探测ip剔除223.5.5.5。
磁盘增加磁盘健康状态采集。
This commit is contained in:
@@ -49,6 +49,9 @@ public class DiskVO implements Serializable {
|
||||
private String type;
|
||||
@Schema(description = "已用空间")
|
||||
private long usedSpace;
|
||||
/** 健康状态 0 不健康,1健康 */
|
||||
@Schema(description = "健康状态")
|
||||
private long healthStatus;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -313,9 +313,13 @@ public class SpecificTimeTaskService {
|
||||
*/
|
||||
private List<IpCount> mergeIpCounts(List<IpCount> allIpCountList) {
|
||||
Map<String, Double> ipCountMap = new HashMap<>();
|
||||
|
||||
final String excludedIp = "223.5.5.5";
|
||||
for (IpCount ipCount : allIpCountList) {
|
||||
String ip = ipCount.getIp();
|
||||
// 跳过要排除的IP
|
||||
if (excludedIp.equals(ip)) {
|
||||
continue;
|
||||
}
|
||||
Double count = ipCount.getCount();
|
||||
|
||||
if (ipCountMap.containsKey(ip)) {
|
||||
|
||||
@@ -31,6 +31,13 @@ public class DiskServiceImpl implements DiskService {
|
||||
|
||||
// 处理磁盘名称:去掉/dev/前缀
|
||||
String diskFullName = disk.getName();
|
||||
// 获取磁盘是否健康
|
||||
boolean isHealth = isDiskHealthy(diskFullName);
|
||||
if(isHealth){
|
||||
diskVO.setHealthStatus(1);
|
||||
}else{
|
||||
diskVO.setHealthStatus(0);
|
||||
}
|
||||
String diskName = diskFullName.replace("/dev/", "");
|
||||
diskVO.setName(diskName); // 保持原样存储
|
||||
diskVO.setSerial(disk.getSerial()); // 序列号
|
||||
@@ -218,6 +225,26 @@ public class DiskServiceImpl implements DiskService {
|
||||
}
|
||||
return partitionToDiskMap;
|
||||
}
|
||||
|
||||
public boolean isDiskHealthy(String diskDevice) {
|
||||
try {
|
||||
Process process = new ProcessBuilder("smartctl", "-H", diskDevice)
|
||||
.redirectErrorStream(true)
|
||||
.start();
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(process.getInputStream()))) {
|
||||
|
||||
return reader.lines()
|
||||
.anyMatch(line -> line.contains("PASSED") || line.contains("OK"))
|
||||
&& process.waitFor() == 0;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PointVO> pointList(long timestamp) {
|
||||
List<PointVO> list = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user