22 |
|
#include "config.h" |
23 |
|
#endif |
24 |
|
|
25 |
– |
#include <stdio.h> |
26 |
– |
#include <unistd.h> |
27 |
– |
#include <stdlib.h> |
25 |
|
#include <time.h> |
29 |
– |
#include <string.h> |
26 |
|
#include "statgrab.h" |
27 |
|
#ifdef SOLARIS |
28 |
|
#include <kstat.h> |
29 |
|
#include <sys/sysinfo.h> |
30 |
+ |
#include <string.h> |
31 |
|
#endif |
32 |
|
|
33 |
|
static cpu_states_t cpu_now; |
57 |
|
if (kstat_read(kc, ksp, &cs) == -1) { |
58 |
|
continue; |
59 |
|
} |
60 |
< |
cpu_now.user+=cs.cpu_sysinfo.cpu[CPU_USER]; |
61 |
< |
cpu_now.iowait+=cs.cpu_sysinfo.cpu[CPU_WAIT]; |
62 |
< |
cpu_now.kernel+=cs.cpu_sysinfo.cpu[CPU_KERNEL]; |
63 |
< |
cpu_now.idle+=cs.cpu_sysinfo.cpu[CPU_IDLE]; |
64 |
< |
cpu_now.swap+=cs.cpu_sysinfo.cpu[CPU_STATES]; |
60 |
> |
cpu_now.user+=(long long)cs.cpu_sysinfo.cpu[CPU_USER]; |
61 |
> |
cpu_now.iowait+=(long long)cs.cpu_sysinfo.cpu[CPU_WAIT]; |
62 |
> |
cpu_now.kernel+=(long long)cs.cpu_sysinfo.cpu[CPU_KERNEL]; |
63 |
> |
cpu_now.idle+=(long long)cs.cpu_sysinfo.cpu[CPU_IDLE]; |
64 |
> |
cpu_now.swap+=(long long)cs.cpu_sysinfo.cpu[CPU_STATES]; |
65 |
|
} |
66 |
|
|
67 |
|
cpu_now.total=cpu_now.user+cpu_now.iowait+cpu_now.kernel+cpu_now.idle+cpu_now.swap; |