perfstat_dump_all.c

Example A-1 shows how to combine all examples from 10.1.3, “Subroutines” on page 587 to access data provided by AIX 5.3 Perfstat API subroutines. Note that the error checking and memory management in this example must be enhanced for a production-type program.

Example A-1. AIX 5.3 Perfstat API complete example
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <libperfstat.h> 4 cpu() 5 { 6 perfstat_id_t name; 7 perfstat_cpu_t *ub; 8 int ncpu,i; 9 ncpu = perfstat_cpu (NULL,NULL,sizeof(perfstat_cpu_t),0); 10 ub = malloc(sizeof(perfstat_cpu_t)*ncpu); 11 strcpy(name.name,""); 12 if (perfstat_cpu(&name,ub,sizeof(perfstat_cpu_t),ncpu) >= 0) 13 for (i = 0; i < ncpu; i++) { 14 printf("name : %s\n", ub[i].name); 15 printf("\tuser ...

Get AIX 5L Practical Performance Tools and Tuning Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.