/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* bos720 src/bos/usr/ccs/lib/libperfstat/simplesspstat.c 1.3 */ /* */ /* Licensed Materials - Property of IBM */ /* */ /* Restricted Materials of IBM */ /* */ /* COPYRIGHT International Business Machines Corp. 2012,2013 */ /* 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 = "@(#)69 1.3 src/bos/usr/ccs/lib/libperfstat/simplesspstat.c, libperfstat, bos720 5/8/13 05:42:28 "; /* The sample program used to Display * * the shared storage pool 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; /* * NAME: showusage * to display the usage * */ void showusage() { printf("Usage:simplesspstat -s | -d | -l [-i interval] [-c count]\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() { returned_count = perfstat_ssp(NULL, NULL, sizeof(perfstat_ssp_t),0,flag); if(returned_count <= 0){ perror("perfstat_ssp_t:"); 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; while (count) { /* Obtain cluster name, ssp name and vtd list*/ rc=perfstat_ssp(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 == 1){ fprintf(stdout, "Total Space : %lld\n", sspstats->u.global.total_space); fprintf(stdout, "Total Used Space : %lld\n", sspstats->u.global.total_used_space); } if(flag == 2){ if(rc!=0) fprintf(stdout, "Disk name :\n"); else fprintf(stdout, "There are no disks in the storage pool\n"); for(i=0; i