package cn.reghao.devops.common.machine;

import cn.reghao.jutil.jdk.machine.data.MachineData;
import cn.reghao.jutil.jdk.machine.data.detail.CpuDetail;
import cn.reghao.jutil.jdk.machine.data.stat.CpuStat;
import oshi.hardware.CentralProcessor;

/**
 * @author reghao
 * @date 2019-10-25 13:12:36
 */
public class Cpu implements MachineData<CpuDetail, CpuStat> {
    private CentralProcessor processor;

    public Cpu(CentralProcessor processor) {
        this.processor = processor;
    }

    @Override
    public CpuDetail detail() {
        CentralProcessor.ProcessorIdentifier processorIdentifier = processor.getProcessorIdentifier();
        String vendor = processorIdentifier.getVendor();
        String name = processorIdentifier.getName();
        int physicalCore = processor.getPhysicalProcessorCount();
        int logicalCore = processor.getLogicalProcessorCount();
        return new CpuDetail(vendor, name, physicalCore, logicalCore);
    }

    @Override
    public CpuStat stat() {
        return null;
    }
}
