sd_stats.c revision 570de38f63910201fdd77246630b7aa8f9dc5661
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void total_display(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void display_cache(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int is_dirty(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int dual_stats(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int zero_nic(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define USEC_INIT() usec_ptr = (unsigned int *)timer_init()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else /* !m88k */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int Usec_started = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int higher(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic unsigned int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (unsigned)((tv.tv_sec - Usec_time.tv_sec) * 1000000
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* m88k */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *range;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int had_r_option = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "[-d delay_time] [-l logfile] [-r range]");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("cannot get maxfiles\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dual_on_off = calloc(sdbc_max_devices, sizeof (int));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte updates_prev = calloc(sdbc_max_devices, sizeof (int));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte samples = calloc(sdbc_max_devices, sizeof (int));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rate_prev = calloc(sdbc_max_devices, sizeof (double));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!on_off || !dual_on_off || !updates_prev || !samples ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !rate_prev || !cs_cur || !cs_prev || !cs_persec || !range) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("no free memory\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((c = getopt(argc, argv, "DMzd:l:r:h")) != EOF) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (c) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte logfd = open(optarg, O_CREAT|O_WRONLY|O_TRUNC, 0644);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sizeof (char));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (!prev) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A few curses routines to setup screen and tty interface
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set signal handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Wait one second before reading the new values
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*CONSTCOND*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If less that 1 second, force it to one second
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((period = (currtime - lasttime) / 1000000) <= 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Calculate new per/period values for statistics
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Display new statistics
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) move(0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (select(fd + 1, &readfds, (fd_set *)0, (fd_set *)0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#pragma error_messages(off, E_STATEMENT_NOT_REACHED)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#pragma error_messages(default, E_STATEMENT_NOT_REACHED)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (c) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print sample count in upper left corner
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get time and print it in upper right corner
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) mvprintw(0, 79 - 10, "%-8.8s\n", &(ctime(&tim)[11]));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clear(); */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default: /* ignore any unknown characters */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* switch */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (got_colon) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (got_comma) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* while */