--- projects/libstatgrab/src/libstatgrab/cpu_stats.c 2008/06/17 15:52:52 1.28 +++ projects/libstatgrab/src/libstatgrab/cpu_stats.c 2010/10/03 18:35:57 1.29 @@ -17,7 +17,7 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: cpu_stats.c,v 1.28 2008/06/17 15:52:52 tdb Exp $ + * $Id: cpu_stats.c,v 1.29 2010/10/03 18:35:57 tdb Exp $ */ #ifdef HAVE_CONFIG_H @@ -55,6 +55,11 @@ #include #include #endif +#ifdef AIX +#include +#include +#include +#endif #ifdef WIN32 #include #include "win32.h" @@ -69,6 +74,10 @@ sg_cpu_stats *sg_get_cpu_stats(){ struct pst_dynamic pstat_dynamic; int i; #endif +#ifdef AIX + perfstat_cpu_total_t all_cpu_info; + int rc; +#endif #ifdef SOLARIS kstat_ctl_t *kc; kstat_t *ksp; @@ -95,7 +104,7 @@ sg_cpu_stats *sg_get_cpu_stats(){ cpu_now.iowait=0; cpu_now.kernel=0; cpu_now.idle=0; - /* Not stored in linux, freebsd, hpux or windows */ + /* Not stored in linux, freebsd, hpux, aix or windows */ cpu_now.swap=0; cpu_now.total=0; /* Not stored in solaris or windows */ @@ -114,6 +123,19 @@ sg_cpu_stats *sg_get_cpu_stats(){ for (i = 0; i < PST_MAX_CPUSTATES; i++) { cpu_now.total += pstat_dynamic.psd_cpu_time[i]; } +#endif +#ifdef AIX + rc = perfstat_cpu_total( NULL, &all_cpu_info, sizeof(all_cpu_info), 1); + if( -1 == rc ) { + sg_set_error_with_errno(SG_ERROR_PSTAT, "perfstat_cpu_total"); + return NULL; + } + + cpu_now.user = all_cpu_info.user; + cpu_now.iowait = all_cpu_info.wait; + cpu_now.kernel = all_cpu_info.sys; + cpu_now.idle = all_cpu_info.idle; + cpu_now.total = all_cpu_info.user + all_cpu_info.wait + all_cpu_info.sys + all_cpu_info.idle; #endif #ifdef SOLARIS if ((kc = kstat_open()) == NULL) {