55 |
|
#include <sys/pstat.h> |
56 |
|
#include <sys/dk.h> |
57 |
|
#endif |
58 |
+ |
#ifdef AIX |
59 |
+ |
#include <strings.h> |
60 |
+ |
#include <sys/proc.h> |
61 |
+ |
#include <libperfstat.h> |
62 |
+ |
#endif |
63 |
|
#ifdef WIN32 |
64 |
|
#include <pdh.h> |
65 |
|
#include "win32.h" |
74 |
|
struct pst_dynamic pstat_dynamic; |
75 |
|
int i; |
76 |
|
#endif |
77 |
+ |
#ifdef AIX |
78 |
+ |
perfstat_cpu_total_t all_cpu_info; |
79 |
+ |
int rc; |
80 |
+ |
#endif |
81 |
|
#ifdef SOLARIS |
82 |
|
kstat_ctl_t *kc; |
83 |
|
kstat_t *ksp; |
104 |
|
cpu_now.iowait=0; |
105 |
|
cpu_now.kernel=0; |
106 |
|
cpu_now.idle=0; |
107 |
< |
/* Not stored in linux, freebsd, hpux or windows */ |
107 |
> |
/* Not stored in linux, freebsd, hpux, aix or windows */ |
108 |
|
cpu_now.swap=0; |
109 |
|
cpu_now.total=0; |
110 |
|
/* Not stored in solaris or windows */ |
123 |
|
for (i = 0; i < PST_MAX_CPUSTATES; i++) { |
124 |
|
cpu_now.total += pstat_dynamic.psd_cpu_time[i]; |
125 |
|
} |
126 |
+ |
#endif |
127 |
+ |
#ifdef AIX |
128 |
+ |
rc = perfstat_cpu_total( NULL, &all_cpu_info, sizeof(all_cpu_info), 1); |
129 |
+ |
if( -1 == rc ) { |
130 |
+ |
sg_set_error_with_errno(SG_ERROR_PSTAT, "perfstat_cpu_total"); |
131 |
+ |
return NULL; |
132 |
+ |
} |
133 |
+ |
|
134 |
+ |
cpu_now.user = all_cpu_info.user; |
135 |
+ |
cpu_now.iowait = all_cpu_info.wait; |
136 |
+ |
cpu_now.kernel = all_cpu_info.sys; |
137 |
+ |
cpu_now.idle = all_cpu_info.idle; |
138 |
+ |
cpu_now.total = all_cpu_info.user + all_cpu_info.wait + all_cpu_info.sys + all_cpu_info.idle; |
139 |
|
#endif |
140 |
|
#ifdef SOLARIS |
141 |
|
if ((kc = kstat_open()) == NULL) { |