#
Junjie
2024-12-06 b78564935a4e1005403e82a0e8649c562ab70ba7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.zy.asrs.wms.system.license.entity.license;
 
import java.net.InetAddress;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * 用于获取客户Windows服务器的基本信息
 */
public class LinuxServerInfos extends AbstractServerInfos {
 
    @Override
    protected List<String> getIpAddress() throws Exception {
        List<String> result = null;
        //获取所有网络接口
        List<InetAddress> inetAddresses = getLocalAllInetAddress();
        if(inetAddresses != null && inetAddresses.size() > 0){
            result = inetAddresses.stream().map(InetAddress::getHostAddress).distinct().map(String::toLowerCase).collect(Collectors.toList());
        }
        return result;
    }
 
    @Override
    protected List<String> getMacAddress() throws Exception {
        List<String> result = null;
 
        //1. 获取所有网络接口
        List<InetAddress> inetAddresses = getLocalAllInetAddress();
 
        if (inetAddresses != null && inetAddresses.size() > 0) {
            //2. 获取所有网络接口的Mac地址
            result = inetAddresses.stream().map(this::getMacByInetAddress).distinct().collect(Collectors.toList());
        }
 
        return result;
    }
 
    @Override
    protected String getCPUSerial() throws Exception {
        return SerialNumberUtil.getSerialNumber("dmidecode -t processor | grep 'ID'", "ID", ":");
    }
 
    @Override
    protected String getMainBoardSerial() throws Exception {
        return SerialNumberUtil.getSerialNumber("dmidecode |grep 'Serial Number'", "Serial Number", ":");
    }
}