1
2
3
4
5 package oshi.driver.unix.aix.perfstat;
6
7 import com.sun.jna.platform.unix.aix.Perfstat;
8 import com.sun.jna.platform.unix.aix.Perfstat.perfstat_disk_t;
9 import com.sun.jna.platform.unix.aix.Perfstat.perfstat_id_t;
10
11 import oshi.annotation.concurrent.ThreadSafe;
12
13
14
15
16 @ThreadSafe
17 public final class PerfstatDisk {
18
19 private static final Perfstat PERF = Perfstat.INSTANCE;
20
21 private PerfstatDisk() {
22 }
23
24
25
26
27
28
29 public static perfstat_disk_t[] queryDiskStats() {
30 perfstat_disk_t diskStats = new perfstat_disk_t();
31
32 int total = PERF.perfstat_disk(null, null, diskStats.size(), 0);
33 if (total > 0) {
34 perfstat_disk_t[] statp = (perfstat_disk_t[]) diskStats.toArray(total);
35 perfstat_id_t firstdiskStats = new perfstat_id_t();
36 int ret = PERF.perfstat_disk(firstdiskStats, statp, diskStats.size(), total);
37 if (ret > 0) {
38 return statp;
39 }
40 }
41 return new perfstat_disk_t[0];
42 }
43 }