1
2
3
4
5 package oshi.driver.windows.perfmon;
6
7 import static oshi.driver.windows.perfmon.PerfmonConstants.PHYSICAL_DISK;
8 import static oshi.driver.windows.perfmon.PerfmonConstants.WIN32_PERF_RAW_DATA_PERF_DISK_PHYSICAL_DISK_WHERE_NAME_NOT_TOTAL;
9
10 import java.util.Collections;
11 import java.util.List;
12 import java.util.Map;
13
14 import oshi.annotation.concurrent.ThreadSafe;
15 import oshi.util.platform.windows.PerfCounterQuery;
16 import oshi.util.platform.windows.PerfCounterWildcardQuery;
17 import oshi.util.platform.windows.PerfCounterWildcardQuery.PdhCounterWildcardProperty;
18 import oshi.util.tuples.Pair;
19
20
21
22
23 @ThreadSafe
24 public final class PhysicalDisk {
25
26
27
28
29 public enum PhysicalDiskProperty implements PdhCounterWildcardProperty {
30
31 NAME(PerfCounterQuery.NOT_TOTAL_INSTANCE),
32
33 DISKREADSPERSEC("Disk Reads/sec"),
34 DISKREADBYTESPERSEC("Disk Read Bytes/sec"),
35 DISKWRITESPERSEC("Disk Writes/sec"),
36 DISKWRITEBYTESPERSEC("Disk Write Bytes/sec"),
37 CURRENTDISKQUEUELENGTH("Current Disk Queue Length"),
38 PERCENTDISKTIME("% Disk Time");
39
40 private final String counter;
41
42 PhysicalDiskProperty(String counter) {
43 this.counter = counter;
44 }
45
46 @Override
47 public String getCounter() {
48 return counter;
49 }
50 }
51
52 private PhysicalDisk() {
53 }
54
55
56
57
58
59
60 public static Pair<List<String>, Map<PhysicalDiskProperty, List<Long>>> queryDiskCounters() {
61 if (PerfmonDisabled.PERF_DISK_DISABLED) {
62 return new Pair<>(Collections.emptyList(), Collections.emptyMap());
63 }
64 return PerfCounterWildcardQuery.queryInstancesAndValues(PhysicalDiskProperty.class, PHYSICAL_DISK,
65 WIN32_PERF_RAW_DATA_PERF_DISK_PHYSICAL_DISK_WHERE_NAME_NOT_TOTAL);
66 }
67 }