1
2
3
4
5 package oshi.driver.windows.perfmon;
6
7 import static oshi.driver.windows.perfmon.PerfmonConstants.PAGING_FILE;
8 import static oshi.driver.windows.perfmon.PerfmonConstants.WIN32_PERF_RAW_DATA_PERF_OS_PAGING_FILE;
9
10 import java.util.Collections;
11 import java.util.Map;
12
13 import oshi.annotation.concurrent.ThreadSafe;
14 import oshi.util.platform.windows.PerfCounterQuery;
15 import oshi.util.platform.windows.PerfCounterQuery.PdhCounterProperty;
16
17
18
19
20 @ThreadSafe
21 public final class PagingFile {
22
23
24
25
26 public enum PagingPercentProperty implements PdhCounterProperty {
27 PERCENTUSAGE(PerfCounterQuery.TOTAL_INSTANCE, "% Usage");
28
29 private final String instance;
30 private final String counter;
31
32 PagingPercentProperty(String instance, String counter) {
33 this.instance = instance;
34 this.counter = counter;
35 }
36
37 @Override
38 public String getInstance() {
39 return instance;
40 }
41
42 @Override
43 public String getCounter() {
44 return counter;
45 }
46 }
47
48 private PagingFile() {
49 }
50
51
52
53
54
55
56 public static Map<PagingPercentProperty, Long> querySwapUsed() {
57 if (PerfmonDisabled.PERF_OS_DISABLED) {
58 return Collections.emptyMap();
59 }
60 return PerfCounterQuery.queryValues(PagingPercentProperty.class, PAGING_FILE,
61 WIN32_PERF_RAW_DATA_PERF_OS_PAGING_FILE);
62 }
63 }