22 |
|
#include "config.h" |
23 |
|
#endif |
24 |
|
|
25 |
– |
#include <stdio.h> |
26 |
– |
#include <ukcprog.h> |
27 |
– |
#include <unistd.h> |
28 |
– |
#include <stdlib.h> |
29 |
– |
#include <sys/types.h> |
25 |
|
#include <time.h> |
31 |
– |
#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 |
37 |
– |
#ifdef FREEBSD |
38 |
– |
#include <sys/sysctl.h> |
39 |
– |
#include <sys/dkstat.h> |
40 |
– |
#endif |
32 |
|
|
33 |
|
static cpu_states_t cpu_now; |
34 |
|
static int cpu_now_uninit=1; |
35 |
|
|
45 |
– |
|
36 |
|
cpu_states_t *get_cpu_totals(){ |
37 |
|
|
38 |
|
#ifdef SOLARIS |
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; |
68 |
|
cpu_now_uninit=0; |
69 |
|
|
70 |
< |
if((kstat_close(kc)) != 0){ |
81 |
< |
return NULL; |
82 |
< |
} |
83 |
< |
|
70 |
> |
kstat_close(kc); |
71 |
|
#endif |
72 |
|
|
73 |
|
cpu_now.systime=time(NULL); |