O'Reilly logo

AIX 5L Practical Performance Tools and Tuning Guide by IBM Redbooks

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required