package cd.casic.framework.commons.util.monitor;

import cd.casic.framework.commons.util.number.ArithUtil;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 *
 * @author mian-bin
 * @Description Mem
 * @date 2025/1/10 15:31
 */
@Setter
@Accessors(chain = true)
public class Mem {
    /**
     * 内存总量
     */
    private double total;

    /**
     * 已用内存
     */
    private double used;

    /**
     * 剩余内存
     */
    private double free;

    public double getTotal() {
        return ArithUtil.div(total, (1024 * 1024 * 1024), 2);
    }

    public double getUsed() {
        return ArithUtil.div(used, (1024 * 1024 * 1024), 2);
    }

    public double getFree() {
        return ArithUtil.div(free, (1024 * 1024 * 1024), 2);
    }

    public double getUsage() {
        return ArithUtil.mul(ArithUtil.div(used, total, 4), 100);
    }
}
