package cn.reghao.autodop.dmaster.machine.model.vo;

import cn.reghao.autodop.common.util.ByteConverter;
import cn.reghao.autodop.common.util.ByteType;
import cn.reghao.jdkutil.machine.Disk;
import lombok.Data;

/**
 * @author reghao
 * @date 2020-10-20 10:51:59
 */
@Data
public class DiskUsage {
    private String mountedOn;
    private String fsType;
    private String total;
    private String used;
    private String avail;
    private int inodeTotal;
    private int inodeFree;

    public DiskUsage(Disk.DiskDetail diskDetail) {
        this.mountedOn = diskDetail.getMountedOn();
        this.fsType = diskDetail.getFsType();
        this.inodeTotal = diskDetail.getInodeTotal();
        this.inodeFree = diskDetail.getInodeFree();

        ByteConverter converter = new ByteConverter();
        this.total = converter.convert(ByteType.Bytes, diskDetail.getSize());
        this.used = converter.convertStr(ByteType.Bytes, ByteType.MiB, diskDetail.getUsed());
        this.avail = converter.convertStr(ByteType.Bytes, ByteType.MiB, diskDetail.getAvail());
    }
}
