提交 | 用户 | 时间
|
1ac2bc
|
1 |
package cn.stylefeng.guns.base.oshi.model; |
懒 |
2 |
|
|
3 |
import cn.hutool.core.util.NumberUtil; |
|
4 |
import lombok.Setter; |
|
5 |
|
|
6 |
/** |
|
7 |
* 內存相关信息 |
|
8 |
* |
|
9 |
* @author fengshuonan |
|
10 |
* @Date 2019-07-13 13:42 |
|
11 |
*/ |
|
12 |
@Setter |
|
13 |
public class MemInfo { |
|
14 |
/** |
|
15 |
* 内存总量 |
|
16 |
*/ |
|
17 |
private double total; |
|
18 |
|
|
19 |
/** |
|
20 |
* 已用内存 |
|
21 |
*/ |
|
22 |
private double used; |
|
23 |
|
|
24 |
/** |
|
25 |
* 剩余内存 |
|
26 |
*/ |
|
27 |
private double free; |
|
28 |
|
|
29 |
public double getTotal() { |
|
30 |
return NumberUtil.div(total, (1024 * 1024 * 1024), 2); |
|
31 |
} |
|
32 |
|
|
33 |
public double getUsed() { |
|
34 |
return NumberUtil.div(used, (1024 * 1024 * 1024), 2); |
|
35 |
} |
|
36 |
|
|
37 |
|
|
38 |
public double getFree() { |
|
39 |
return NumberUtil.div(free, (1024 * 1024 * 1024), 2); |
|
40 |
} |
|
41 |
|
|
42 |
public double getUsage() { |
|
43 |
return NumberUtil.mul(NumberUtil.div(used, total, 4), 100); |
|
44 |
} |
|
45 |
} |