perfstat_tape Interface

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

Selected fields from the perfstat_tape_t structure include:
Item Descriptor
size Size of the tape (in MB)
free Free portion of the tape (in MB)
bsize Tape block size (in bytes)
paths_count Number of paths to the tape
Several other paging-space-related metrics (such as name, type, and active) are also returned. For a complete list of paging-space-related metrics, see the perfstat_pagingspace_t section in the libperfstat.h header file in Files Reference.
The following code shows an example of how the perfstat_tape interface is used:
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>

int main(){
    int ret, tot, i;
    perfstat_tape_t *statp;
    perfstat_id_t first;

    /* check how many perfstat_tape_t structures are available */
    tot =  perfstat_tape(NULL, NULL, sizeof(perfstat_tape_t), 0);
    
    /* check for error */
    if (tot < 0)
    {
	  perror("perfstat_tape");
	  exit(-1);
    }
    if (tot == 0)
    {

        printf("No tape found in the system\n");
        exit(-1);
    }
	
    /* allocate enough memory for all the structures */
    statp = calloc(tot, sizeof(perfstat_tape_t));
    if(statp==NULL){
	printf("No sufficient memory\n");
	exit(-1);
    }
    
    /* set name to first interface */
    strcpy(first.name, FIRST_TAPE);
    
    /* ask to get all the structures available in one call */
    /* return code is number of structures returned */
    ret = perfstat_tape(&first, statp,
                        sizeof(perfstat_tape_t), tot);

    
    /* check for error */
    if (ret <= 0)
    {
	  perror("perfstat_tape");
	  exit(-1);
    }
   
    for(i=0;i<ret;i++){
        
        printf("Name of the tape=%s\n",statp[i].name); 
        printf("Tape description=%s\n",statp[i].description);
        printf("Size of the tape (in MB)=%lld\n",statp[i].size);
        printf("Free portion of the tape (in MB)=%lld\n",statp[i].free);
        printf("Tape block size (in bytes)=%lld\n",statp[i].bsize);
        printf("Number of transfers to/from tape=%lld\n",statp[i].xfers);
        printf("Number of read transfers to/from tape=%lld\n",statp[i].rxfers);
        printf("Number of blocks written to tape=%lld\n",statp[i].wblks);
        printf("Number of blocks read from tape=%lld\n",statp[i].rblks);
        printf("Amount of time tape is active=%lld\n",statp[i].time);
        printf("Tape adapter name =%s\n",statp[i].adapter);
        printf("Number of paths to this tape=%d\n",statp[i].paths_count);
        printf("\n"); 
    }
}