提交 | 用户 | 时间
|
1ac2bc
|
1 |
package cn.stylefeng.guns.base.oshi.model; |
懒 |
2 |
|
|
3 |
import cn.hutool.core.util.NumberUtil; |
|
4 |
import lombok.Setter; |
|
5 |
|
|
6 |
/** |
|
7 |
* CPU相关信息 |
|
8 |
* |
|
9 |
* @author fengshuonan |
|
10 |
* @Date 2019-07-13 13:42 |
|
11 |
*/ |
|
12 |
@Setter |
|
13 |
public class CpuInfo { |
|
14 |
|
|
15 |
/** |
|
16 |
* 核心数 |
|
17 |
*/ |
|
18 |
private int cpuNum; |
|
19 |
|
|
20 |
/** |
|
21 |
* CPU总的使用率 |
|
22 |
*/ |
|
23 |
private double total; |
|
24 |
|
|
25 |
/** |
|
26 |
* CPU系统使用率 |
|
27 |
*/ |
|
28 |
private double sys; |
|
29 |
|
|
30 |
/** |
|
31 |
* CPU用户使用率 |
|
32 |
*/ |
|
33 |
private double used; |
|
34 |
|
|
35 |
/** |
|
36 |
* CPU当前等待率 |
|
37 |
*/ |
|
38 |
private double wait; |
|
39 |
|
|
40 |
/** |
|
41 |
* CPU当前空闲率 |
|
42 |
*/ |
|
43 |
private double free; |
|
44 |
|
|
45 |
public int getCpuNum() { |
|
46 |
return cpuNum; |
|
47 |
} |
|
48 |
|
|
49 |
public double getTotal() { |
|
50 |
return NumberUtil.round(NumberUtil.mul(total, 100), 2).doubleValue(); |
|
51 |
} |
|
52 |
|
|
53 |
public double getSys() { |
|
54 |
return NumberUtil.round(NumberUtil.mul(sys / total, 100), 2).doubleValue(); |
|
55 |
} |
|
56 |
|
|
57 |
public double getUsed() { |
|
58 |
return NumberUtil.round(NumberUtil.mul(used / total, 100), 2).doubleValue(); |
|
59 |
} |
|
60 |
|
|
61 |
public double getWait() { |
|
62 |
return NumberUtil.round(NumberUtil.mul(wait / total, 100), 2).doubleValue(); |
|
63 |
} |
|
64 |
|
|
65 |
public double getFree() { |
|
66 |
return NumberUtil.round(NumberUtil.mul(free / total, 100), 2).doubleValue(); |
|
67 |
} |
|
68 |
|
|
69 |
} |