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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.