/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* bos72D src/bos/usr/ccs/lib/libperfstat/simplesspextstat.c 1.2 */ /* */ /* Licensed Materials - Property of IBM */ /* */ /* Restricted Materials of IBM */ /* */ /* COPYRIGHT International Business Machines Corp. 2015,2016 */ /* All Rights Reserved */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /* */ /* IBM_PROLOG_END_TAG */ static char *sccsid = "@(#)85 1.2 src/bos/usr/ccs/lib/libperfstat/simplesspextstat.c, libperfstat, bos72D, d2016_10B7 3/6/16 20:59:25 "; /* The sample program used to Display * * the shared storage pool Tier/FG/PV information */ #include #include #include /* define default interval and count values */ #define INTERVAL_DEFAULT 1 #define COUNT_DEFAULT 1 /* Check value returned by malloc for NULL */ #define CHECK_FOR_MALLOC_NULL(X) { if ((X) == NULL) {\ perror ("malloc");\ exit(2);\ }\ } int count = COUNT_DEFAULT, interval = INTERVAL_DEFAULT; /* store the data structures */ perfstat_ssp_t *sspstats = NULL; int rc, returned_count, flag = 0; char tiername[VIOS_STR_128]; char fgname[VIOS_STR_128]; char diskname[VIOS_STR_128]; char nodename[MAXHOSTNAMELEN]; perfstat_ssp_id_t sspid = {0}; int tflag = 0, dflag = 0,fflag = 0,nflag = 0; /* * NAME: showusage * to display the usage * */ void showusage() { printf("Usage:simplesspstat -T | -F | -D | -N [-i interval] [-c count][-t ][-f ] [-d ] [-n ] \n"); exit(1); } /* * NAME: do_initialization * This function initializes the data structues. * It also collects initial set of values. * * RETURNS: * On successful completion: * - returns 0. * In case of error * - exits with code 1. */ int do_initialization() { int nofilter = 0; if(fflag || dflag || tflag || nflag) sspid.spec |= PERFFILT_NAME; else nofilter = 1; if(fflag) { sspid.spec |= PERFFILT_FG; strncpy(sspid.fg.name,fgname,VIOS_STR_128); } if(dflag) { sspid.spec |= PERFFILT_PHYSV; strncpy(sspid.pv.name,diskname,VIOS_STR_128); } if(tflag) { sspid.spec |= PERFFILT_TIER; strncpy(sspid.tier.name,tiername,VIOS_STR_128); } if(nflag) { sspid.spec |= PERFFILT_NODE; strncpy(sspid.node.name,nodename,VIOS_STR_128); } if(!nofilter) returned_count = perfstat_ssp_ext(&sspid, NULL, sizeof(perfstat_ssp_t),0,flag); else returned_count = perfstat_ssp_ext(NULL, NULL, sizeof(perfstat_ssp_t),0 ,flag); if(returned_count <= 0){ printf("perfstat_ssp_exit failed with error:%d",errno); exit(-1); } /* Allocate memory for the structure*/ sspstats=( perfstat_ssp_t *) malloc(sizeof(perfstat_ssp_t) * returned_count); CHECK_FOR_MALLOC_NULL(sspstats); return(0); } static void do_cleanup() { free(sspstats); } /* *Name: display_metrics * collect the metrics and display them * */ void display_metrics() { int i,rc; int nofilter = 0; if(!fflag && !dflag && !tflag && !nflag) nofilter = 1; while (count) { /* Obtain SSP COnfig stats for tier/failure group or PV stats based on the flag*/ if(!nofilter) rc=perfstat_ssp_ext(&sspid, sspstats, sizeof(perfstat_ssp_t),returned_count,flag); else rc=perfstat_ssp_ext(NULL, sspstats, sizeof(perfstat_ssp_t),returned_count,flag); if(rc<0) { perror("perfstat_ssp_t:"); exit(-1); } sleep (interval); fprintf(stdout, "\nCluster Name : %s\n", sspstats->cluster_name); fprintf(stdout, "Storage Pool Name : %s\n", sspstats->spool_name); if(flag == SSPPV){ if(rc!=0) fprintf(stdout, "Disk name \t Tier Name\t Failure Group:\n"); else fprintf(stdout, "There are no disks in the storage pool\n"); for(i=0; i