/* * @(#)print_counters.c 1.3 03/23/98 SMI * * Copyright 1997 by Sun Microsystems, Inc. * All rights reserved * * prints the counters for the specified channel. * * Syntax: * print_counters -c channel */ #include #include #include #include static void usage() { printf("Usage:\n print_counters -c channel\n\n"); return; } main ( int argc, char **argv) { char *chan; char channel[IM_CHANNEL_LEN+1]; int count, stored, received, delivered, submitted, i; imctr_t ctr; char c; /* interpret the command line */ *channel = 0; while ((c = getopt(argc, argv, "c:")) != EOF) { switch (c) { case 'c': /* the channel name */ strcpy(channel, optarg); break; default: usage(); exit( EX_USAGE); } } /* if the channel is not set, ask for all */ if ( *channel == 0 ) strcpy(channel, "*"); /* initialize */ imta_init( NULL); /* get the counters and display them */ if ( (count = imctr_load( &ctr, channel)) > 0 ) { for ( i = 0 ; i < count ; i++ ) { stored = imctr_get( ctr, i, IMCTR_STORED_MSGS, &chan); delivered = imctr_get( ctr, i, IMCTR_DELIVERED_MSGS, &chan); submitted = imctr_get( ctr, i, IMCTR_SUBMITTED_MSGS, &chan); received = imctr_get( ctr, i, IMCTR_RECEIVED_MSGS, &chan); printf( "%s : \n\t%d messages stored, \n\t%d messages received, \n\t%d messages submitted, \n\t%d messages delivered\n\n", chan, stored, received, submitted, delivered); } } else if ( count < 0 ) { printf("%s\n", imta_error(count)); } /* free the counters */ imctr_free(ctr); imta_end(); exit( EX_OK); }