[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1


perfstat_cpu Subroutine

Purpose

Retrieves individual CPU usage statistics.

Library

perfstat library (libperfstat.a)

Syntax

#include <libperfstat.h>

int perfstat_cpu (name, userbuff, sizeof_struct, desired_number)
perfstat_id_t * name;
perfstat_cpu_t * userbuff;
int sizeof_struct;
int desired_number;

Parameters


name

Contains a name identifying the first CPU for which statistics are desired. "" is used to indicate the first available CPU. For example:

cpu0, cpu1,...
userbuff Points to the memory area that is to be filled with one or more perfstat_cpu_t structures.
sizeof_struct Specifies the size of the perfstat_cpu_t structure: sizeof(perfstat_cpu_t).
desired_number Specifies the number of perfstat_cpu_t structures to copy to userbuff.

Description

The perfstat_cpu subroutine retrieves one or more individual CPU usage statistics. The same function can be used to retrieve the number of available sets of CPU statistics.

To get one or more sets of CPU usage metrics, set the name parameter to the name of the first CPU for which statistics are desired, and set the desired_number parameter. To start from the first CPU, specify "" as the name. The userbuff parameter must always point to a memory area big enough to contain the desired number of perfstat_cpu_t structures that will be copied by this function. Upon return, the name parameter will be set to either the name of the next CPU, or to "" after all structures have been copied.

To retrieve the number of available sets of CPU usage metrics, set the name and userbuff parameters to NULL, and desired_number to 0 (zero). The returned value will be the number of available sets.

Return Values

Unless the function is used to retrieve the number of available structures, the number of structures filled is returned upon successful completion. Otherwise, a value of -1 is returned and the errno variable is set.

Error Codes

The perfstat_cpu subroutine is unsuccessful if the following is true:

EINVAL One of the parameters is not valid.

Implementation Specifics

The perfstat_cpu subroutine is part of the Base Operating System (BOS) runtime.

Files

/usr/include/libperfstat.h Defines standard macros, data types and subroutines.

Related Information

The perfstat_cpu_total subroutine, perfstat_memory_total subroutine, perfstat_disk subroutine, perfstat_disk_total subroutine, perfstat_netinterface subroutine, and perfstat_netinterface_total subroutine.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]