report.c revision fcf3ce441efd61da9bb2884968af01cb7c1452cc
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern short dflags;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return the number of ticks delta between two hrtime_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * values. Attempt to cater for various kinds of overflow
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in hrtime_t - no matter how improbable.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We've overflowed the positive portion of an
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The new value is negative. Handle the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * case where the old value is positive or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Either we've just gone from being negative
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to positive *or* the last entry was positive
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and the new entry is also positive but *less*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * than the old entry. This implies we waited
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * quite a few days on a very fast system between
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iostat displays.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Take the difference of an unsigned 32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bit int attempting to cater for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Take the difference of an unsigned 64
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bit int attempting to cater for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * io_report() - diffs and reports data contained in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * kstat_io_t structures.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * kstat_io_t *cur - pointer to current data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * kstat_io_t *pre - pointer to data as it was
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * at the beginning of an interval.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteio_report(kstat_io_t *cur, kstat_io_t *pre, sdbcstat_t *sdbcstat)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_getvalues(sdbcstat, &vals, (SDBC_KBYTES | SDBC_INTAVG)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hr_etime = hrtime_delta(pre->wlastupdate, cur->wlastupdate);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Read count */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rd_cnt = (double)u32_delta(pre->reads, cur->reads);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Bytes read */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rd_kb = (double)u64_delta(pre->nread, cur->nread) / KILOBYTE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Write count */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wr_cnt = (double)u32_delta(pre->writes, cur->writes);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Bytes written */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wr_kb = (double)u64_delta(pre->nwritten, cur->nwritten) / KILOBYTE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Calculate service times */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte avs = (double)hrtime_delta(pre->rlentime, cur->rlentime) / hr_etime;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Output */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf(TPS_INF_FMT, (uint32_t)(rd_cnt + wr_cnt));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cd_report() - reports cache desriptor related statistics
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * based on the dflags global variable
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sdbcstat_t *sdbcstat - pointer to the cache structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to be reported on.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Extract statistics, average for time */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sdbc_getvalues(sdbcstat, &vals, (SDBC_KBYTES | SDBC_INTAVG)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Output */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(DATA_I32, vals.write_cancellations);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * header() - outputs an appropriate header by referencing the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * global variables dflsgs and rflags