50 |
|
#include <sys/sysctl.h> |
51 |
|
#include <sys/dkstat.h> |
52 |
|
#endif |
53 |
+ |
#ifdef HPUX |
54 |
+ |
#include <sys/param.h> |
55 |
+ |
#include <sys/pstat.h> |
56 |
+ |
#include <sys/dk.h> |
57 |
+ |
#endif |
58 |
|
|
59 |
|
static sg_cpu_stats cpu_now; |
60 |
|
static int cpu_now_uninit=1; |
61 |
|
|
62 |
|
sg_cpu_stats *sg_get_cpu_stats(){ |
63 |
|
|
64 |
+ |
#ifdef HPUX |
65 |
+ |
struct pst_dynamic pstat_dynamic; |
66 |
+ |
int i; |
67 |
+ |
#endif |
68 |
|
#ifdef SOLARIS |
69 |
|
kstat_ctl_t *kc; |
70 |
|
kstat_t *ksp; |
90 |
|
cpu_now.iowait=0; |
91 |
|
cpu_now.kernel=0; |
92 |
|
cpu_now.idle=0; |
93 |
< |
/* Not stored in linux or freebsd */ |
93 |
> |
/* Not stored in linux, freebsd, or hpux */ |
94 |
|
cpu_now.swap=0; |
95 |
|
cpu_now.total=0; |
96 |
|
/* Not stored in solaris */ |
97 |
|
cpu_now.nice=0; |
98 |
|
|
99 |
+ |
#ifdef HPUX |
100 |
+ |
if (pstat_getdynamic(&pstat_dynamic, sizeof(pstat_dynamic), 1, 0) == -1) { |
101 |
+ |
sg_set_error_with_errno(SG_ERROR_PSTAT, "pstat_dynamic"); |
102 |
+ |
return NULL; |
103 |
+ |
} |
104 |
+ |
cpu_now.user = pstat_dynamic.psd_cpu_time[CP_USER]; |
105 |
+ |
cpu_now.iowait = pstat_dynamic.psd_cpu_time[CP_WAIT]; |
106 |
+ |
cpu_now.kernel = pstat_dynamic.psd_cpu_time[CP_SSYS] + pstat_dynamic.psd_cpu_time[CP_SYS]; |
107 |
+ |
cpu_now.idle = pstat_dynamic.psd_cpu_time[CP_IDLE]; |
108 |
+ |
cpu_now.nice = pstat_dynamic.psd_cpu_time[CP_NICE]; |
109 |
+ |
for (i = 0; i < PST_MAX_CPUSTATES; i++) { |
110 |
+ |
cpu_now.total += pstat_dynamic.psd_cpu_time[i]; |
111 |
+ |
} |
112 |
+ |
#endif |
113 |
|
#ifdef SOLARIS |
114 |
|
if ((kc = kstat_open()) == NULL) { |
115 |
|
sg_set_error(SG_ERROR_KSTAT_OPEN, NULL); |