ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/cpu_stats.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/cpu_stats.c (file contents):
Revision 1.1 by pajs, Tue Feb 18 19:28:30 2003 UTC vs.
Revision 1.5 by pajs, Mon Mar 3 13:14:25 2003 UTC

# Line 23 | Line 23
23   #endif
24  
25   #include <stdio.h>
26 #include <ukcprog.h>
26   #include <unistd.h>
27   #include <stdlib.h>
29 #include <sys/types.h>
28   #include <time.h>
29   #include <string.h>
30   #include "statgrab.h"
# Line 34 | Line 32
32   #include <kstat.h>
33   #include <sys/sysinfo.h>
34   #endif
37 #ifdef FREEBSD
38 #include <sys/sysctl.h>
39 #include <sys/dkstat.h>
40 #endif
35  
36   static cpu_states_t cpu_now;
37   static int cpu_now_uninit=1;
38  
45
39   cpu_states_t *get_cpu_totals(){
40  
41   #ifdef SOLARIS
# Line 67 | Line 60 | cpu_states_t *get_cpu_totals(){
60                  if (kstat_read(kc, ksp, &cs) == -1) {
61                          continue;
62                  }
63 <                cpu_now.user+=cs.cpu_sysinfo.cpu[CPU_USER];
64 <                cpu_now.iowait+=cs.cpu_sysinfo.cpu[CPU_WAIT];
65 <                cpu_now.kernel+=cs.cpu_sysinfo.cpu[CPU_KERNEL];
66 <                cpu_now.idle+=cs.cpu_sysinfo.cpu[CPU_IDLE];
67 <                cpu_now.swap+=cs.cpu_sysinfo.cpu[CPU_STATES];
63 >                cpu_now.user+=(long long)cs.cpu_sysinfo.cpu[CPU_USER];
64 >                cpu_now.iowait+=(long long)cs.cpu_sysinfo.cpu[CPU_WAIT];
65 >                cpu_now.kernel+=(long long)cs.cpu_sysinfo.cpu[CPU_KERNEL];
66 >                cpu_now.idle+=(long long)cs.cpu_sysinfo.cpu[CPU_IDLE];
67 >                cpu_now.swap+=(long long)cs.cpu_sysinfo.cpu[CPU_STATES];
68          }
69  
70          cpu_now.total=cpu_now.user+cpu_now.iowait+cpu_now.kernel+cpu_now.idle+cpu_now.swap;
71          cpu_now_uninit=0;
72  
73 <        if((kstat_close(kc)) != 0){
81 <                return NULL;
82 <        }
83 <
73 >        kstat_close(kc);
74   #endif
75  
76          cpu_now.systime=time(NULL);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines