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.28 by tdb, Tue Jun 17 15:52:52 2008 UTC vs.
Revision 1.29 by tdb, Sun Oct 3 18:35:57 2010 UTC

# Line 55 | Line 55
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"
# Line 69 | Line 74 | sg_cpu_stats *sg_get_cpu_stats(){
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;
# Line 95 | Line 104 | sg_cpu_stats *sg_get_cpu_stats(){
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 */
# Line 114 | Line 123 | sg_cpu_stats *sg_get_cpu_stats(){
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) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines