perfstat_disk_total Interface

The perfstat_disk_total interface returns a perfstat_disk_total_t structure, which is defined in the libperfstat.h file.

Selected fields from the perfstat_disk_total_t structure include:
Item Descriptor
number Number of disks
size Total disk size (in MB)
free Total free disk space (in MB)
xfers Total transfers to and from disk (in KB)
Several other disk-related metrics, such as number of blocks read from and written to disk, are also returned. For a complete list, see the perfstat_disk_total_t section in the libperfstat.h header file in Files Reference.
The following code shows an example of how perfstat_disk_total is used:
#include <stdio.h>
#include <libperfstat.h>

int main(int argc, char* argv[]) {
    perfstat_disk_total_t dinfo;
    int rc;
    rc = perfstat_disk_total(NULL, &dinfo, sizeof(perfstat_disk_total_t), 1);
    if (rc != 1)
    {
	perror("perfstat_disk_total");
        exit(-1);
    }  
    perfstat_disk_total(NULL, &dinfo, sizeof(perfstat_disk_total_t), 1);
    printf("Total disk statistics\n");
    printf("---------------------\n");
    printf("number of  disks         : %d\n",   dinfo.number);
    printf("total disk space         : %llu\n", dinfo.size);
    printf("total free space         : %llu\n", dinfo.free);
    printf("number of transfers      : %llu\n", dinfo.xfers);
    printf("number of blocks written : %llu\n", dinfo.wblks);
    printf("number of blocks read    : %llu\n", dinfo.rblks);
}
This program produces output such as the following:
Total disk statistics
---------------------
number of  disks         : 3
total disk space         : 4296
total free space         : 2912
number of transfers      : 77759
number of blocks written : 738016
number of blocks read    : 363120
The preceding program emulates iostat's behavior and also shows how perfstat_disk_total is used.