perfstat_wpar_total Interface

The perfstat_wpar_total interface returns a set of structures of type perfstat_wpar_total_t, which is defined in the libperfstat.h file.

Selected fields from the perfstat_wpar_total_t structure include:
Item Descriptor
Type WPAR type.
online_cpus The number of virtual processors currently allocated to the partition rset or the number of virtual processors currently allocated to the system partition.
online_memory The amount of memory currently allocated to the system partition.
cpu_limit The maximum limit of processor resources this WPAR consumes. The processor limit is in 100ths of percentage units.

Several other paging-space-related metrics (such as number of system calls, number of reads, writes, forks, execs, and load average) are also returned. For a complete list of other paging-space-relate metrics, see the perfstat_wpar_total_t section in the libperfstat.h header file in Files Reference.

The following program emulates wparstat behavior and also shows an example of how perfstat_wpar_total is used from the global environment:
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>
int main(){
    perfstat_wpar_total_t *winfo;
    perfstat_id_wpar_t wparid;
    int tot, rc, i;

    tot = perfstat_wpar_total(NULL, NULL, sizeof(perfstat_wpar_total_t), 0);

    if (tot < 0) {
        perror("Error in perfstat_wpar_total");
        exit(-1);
    }

    if (tot == 0) {
	 printf("No WPARs found in the system\n");
	 exit(-1);
    }
    
    /* allocate enough memory for all the structures */
    winfo = calloc(tot,sizeof(perfstat_wpar_total_t));    
    if(winfo==NULL){
	printf("No sufficient memory\n");
	exit(-1);
    }

    /* Retrieve all WPARs */
    bzero(&wparid, sizeof(perfstat_id_wpar_t));
    wparid.spec = WPARNAME;
    strcpy(wparid.u.wparname,FIRST_WPARNAME);
    rc = perfstat_wpar_total(&wparid, winfo, sizeof(perfstat_wpar_total_t), tot);

    if (rc < 0) {
        perror("Error in perfstat_wpar_total");
        exit(-1);
    }

    for(i=0;i<tot;i++){
        printf("Name of the Workload Partition=%s\n",winfo[i].name);
	printf("Workload partition identifier=%u\n",winfo[i].wpar_id);
	printf("Number of Virtual CPUs in partition rset=%d\n",winfo[i].online_cpus);
	printf("Amount of memory currently online in Global Partition=%lld\n",winfo[i].online_memory);
	printf("Number of processor units this partition is entitled to receive=%d\n",winfo[i].entitled_proc_capacity);
	printf("\n");
    }

    return(0);
}
The program displays an output that is similar to the following example output:
Name of the Workload Partition=test
Workload partition identifier=1
Number of Virtual CPUs in partition rset=2
Amount of memory currently online in Global Partition=4096
Number of processor units this partition is entitled to receive=100
The following code shows an example of how perfstat_wpar_total is used from the WPAR environment:
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>
int main(){
    perfstat_wpar_total_t *winfo;
    perfstat_id_wpar_t wparid;
    int tot, rc, i;

    tot = perfstat_wpar_total(NULL, NULL, sizeof(perfstat_wpar_total_t), 0);

    if (tot < 0) {
        perror("Error in perfstat_wpar_total");
        exit(-1);
    }

    if (tot == 0) {
	 printf("No WPARs found in the system\n");
	 exit(-1);
    }
    
    /* allocate enough memory for all the structures */
    winfo = calloc(tot,sizeof(perfstat_wpar_total_t));    
    if(winfo==NULL){
	printf("No sufficient memory\n");
	exit(-1);
    }

   rc = perfstat_wpar_total(NULL, winfo, sizeof(perfstat_wpar_total_t), tot);

    if (rc < 0) {
        perror("Error in perfstat_wpar_total");
        exit(-1);
    }

    for(i=0;i<tot;i++){
        printf("Name of the Workload Partition=%s\n",winfo[i].name);
	printf("Workload partition identifier=%u\n",winfo[i].wpar_id);
	printf("Number of Virtual CPUs in partition rset=%d\n",winfo[i].online_cpus);
	printf("Amount of memory currently online in Global Partition=%lld\n",winfo[i].online_memory);
	printf("Number of processor units this partition is entitled to receive=%d\n",winfo[i].entitled_proc_capacity);
	printf("\n");
    }

    return(0);
}