package cn.reghao.devops.mgr.machine.model.vo;

import cn.reghao.jutil.jdk.converter.ByteConverter;
import cn.reghao.jutil.jdk.converter.ByteType;
import cn.reghao.jutil.jdk.machine.data.detail.DiskDetail;
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 long inodeTotal;
    private long inodeAvail;

    public DiskUsage(DiskDetail diskDetail) {
        this.mountedOn = diskDetail.getMountedOn();
        this.fsType = diskDetail.getFsType();
        this.inodeTotal = diskDetail.getInodeTotal();
        this.inodeAvail = diskDetail.getInodeAvail();

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