--- projects/libstatgrab/src/libstatgrab/swap_stats.c 2007/07/05 16:46:06 1.25 +++ projects/libstatgrab/src/libstatgrab/swap_stats.c 2010/10/03 18:35:58 1.26 @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA * - * $Id: swap_stats.c,v 1.25 2007/07/05 16:46:06 tdb Exp $ + * $Id: swap_stats.c,v 1.26 2010/10/03 18:35:58 tdb Exp $ */ #ifdef HAVE_CONFIG_H @@ -59,6 +59,10 @@ #include #define SWAP_BATCH 5 #endif +#ifdef AIX +#include +#include +#endif #ifdef WIN32 #include #endif @@ -95,6 +99,10 @@ sg_swap_stats *sg_get_swap_stats(){ #if defined(NETBSD) || defined(OPENBSD) struct uvmexp *uvm; #endif +#ifdef AIX + perfstat_memory_total_t mem; + long long pagesize; +#endif #ifdef WIN32 MEMORYSTATUSEX memstats; #endif @@ -135,6 +143,22 @@ sg_swap_stats *sg_get_swap_stats(){ } swapidx = pstat_swapinfo[num - 1].pss_idx + 1; } +#endif +#ifdef AIX + if ((pagesize = sysconf(_SC_PAGESIZE)) == -1) { + sg_set_error_with_errno(SG_ERROR_SYSCONF, "_SC_PAGESIZE"); + return NULL; + } + + /* return code is number of structures returned */ + if(perfstat_memory_total(NULL, &mem, sizeof(perfstat_memory_total_t), 1) != 1) { + sg_set_error_with_errno(SG_ERROR_SYSCTLBYNAME, "perfstat_memory_total"); + return NULL; + } + + swap_stat.total = ((long long)mem.pgsp_total) * pagesize; + swap_stat.free = ((long long)mem.pgsp_free) * pagesize; + swap_stat.used = swap_stat.total - swap_stat.free; #endif #ifdef SOLARIS if((pagesize=sysconf(_SC_PAGESIZE)) == -1){