perfstat_tape_total Interface

The perfstat_tape_total interface returns a perfstat_tape_total_t structure, which is defined in the libperfstat.h file.

Selected fields from the perfstat_tape_total_t structure include:

Item Descriptor
number Total number of tapes
size Total size of all tapes(in MB)
free Total free portion of all tapes (in MB)
rxfers Total number of read transfers from/to tape
xfers Total number of transfers from/to tape

Several other tape-related metrics (such as number of bytes sent and received). For a complete list, see the perfstat_tape_total section in the libperfstat.h header file.

The following code shows examples of how to use the perfstat_tape_total function.
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>
int main(){
    perfstat_tape_total_t *tinfo;
    int rc,i;

    rc = perfstat_tape_total(NULL, NULL, sizeof(perfstat_tape_total_t), 0);
    if(rc<=0){
        perror("perfstat_tape_total");
        exit(-1);
    }

    /* allocate enough memory for all the structures */
    tinfo = calloc(rc, sizeof(perfstat_tape_t));
    if(tinfo==NULL){
        printf("No sufficient memory\n");
        exit(-1);
    }

    rc = perfstat_tape_total(NULL, tinfo, sizeof(perfstat_tape_total_t), rc);
    if (rc < 0)
    {
        perror("perfstat_tape_total");
        exit(-1);
    }

    if(rc==0){
        printf("No tape found on the system\n");
        exit(-1);
    }

    for(i=0;i<rc;i++){
        printf("Total number of tapes=%d\n",tinfo[i].number);
        printf("Total size of all tapes (in MB)=%lld\n",tinfo[i].size);
        printf("Free portion of all tapes(in MB)=%lld\n",tinfo[i].free);
        printf("Number of read transfers to/from tape=%lld\n",tinfo[i].rxfers);
        printf("Total number of transfers to/from tape=%lld\n",tinfo[i].xfers);
        printf("Blocks written to all tapes=%lld\n",tinfo[i].wblks);
        printf("Blocks read from all tapes=%lld\n",tinfo[i].rblks);
        printf("Amount of time tapes are active=%lld\n",tinfo[i].time);
    }

    return(0);
}

The preceding program emulates diskstat behavior and also shows how perfstat_tape_total is used.