sdbc_stats.c revision 570de38f63910201fdd77246630b7aa8f9dc5661
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <inttypes.h>
#include <kstat.h>
#include "sdbc_stats.h"
#include "dsstat.h"
#include "common.h"
#include "report.h"
static sdbcstat_t *sdbc_top;
void sdbc_header();
int sdbc_value_check(sdbcstat_t *);
int sdbc_validate(kstat_t *);
void sdbc_addstat(sdbcstat_t *);
void center(int, char *);
/*
* sdbc_discover() - looks for new statistics to be monitored.
* Verifies that any statistics found are now already being
* monitored.
*
*/
int
{
static int validated = 0;
int kinst;
continue;
continue;
/*
* Validate kstat structure
*/
if (! validated) {
if (sdbc_validate(ksp))
return (EINVAL);
validated++;
}
/*
* Duplicate check
*/
goto next;
}
/*
* Initialize new record
*/
/*
* Set kstat
*/
goto next;
/*
* I/O kstat
*/
goto next;
next:
/*
* Check if we got a complete set of stats
*/
continue;
(void) sdbc_delstat(sdbcstat);
continue;
}
}
return (EAGAIN);
return (0);
}
/*
* sdbc_update() - updates all of the statistics currently being monitored.
*
*/
int
{
/* Update global kstat information */
return (EAGAIN);
if (sdbc_global)
int kinst;
/*
* Age off old stats
*/
}
/*
* Update set kstat
*/
continue;
/*
* Validate set
*/
continue;
/*
* Update I/O kstat
*/
continue;
}
return (0);
}
/*
* sdbc_report() - outputs statistics for the statistics currently being
* monitored. Deletes statistics for volumes that have been disabled.
*
*/
int
{
return (0);
char rmode[STAT_HDR_SIZE];
char wmode[STAT_HDR_SIZE];
/* Parse volume name */
/* Check to see if the user specified this volume */
break;
goto next;
/* Check if volume is offline and zflag applies */
goto next;
/* Output volume name */
sdbc_header();
if (! pre)
else
(void) printf(" <<volume disabled>>\n");
continue;
}
if (*offline) {
(void) printf(" <<volume offline>>\n");
linesout++;
goto next;
}
if (! nhint)
return (EINVAL);
if (hints & NSC_NOCACHE)
else
else
}
/* Output set information */
next:
}
return (0);
}
/*
* sdbc_header() - outputs an appropriate header by referencing the
* global variables dflsgs
*
*/
void
{
int rcount = 0;
if (hflags == HEADERS_EXL)
if ((linesout % DISPLAY_LINES) != 0)
return;
if (hflags == HEADERS_BOR)
if (linesout != 0)
return;
if (hflags & HEADERS_ATT)
if (hflags & HEADERS_OUT)
return;
else
hflags |= HEADERS_OUT;
if (linesout)
(void) printf("\n");
/* first line header */
}
int size;
rcount++;
}
int size;
rcount++;
}
(void) printf("\n");
}
/* second line header */
}
goto out;
}
}
}
out:
(void) printf("\n");
}
/*
* sdbc_getstat() - find cache stat by name matching
*
* paraemters
* char *vn - the volume name to match against
* returns
* sdbcstat_t * - the matching strcture, NULL if not found
*/
sdbc_getstat(char *vn)
{
char *volname =
if (! pre)
else
continue;
}
return (cur);
}
return (NULL);
}
/*
* sdbc_addstat() - adds a fully populated sdbcstat_t structure
* to the linked list of currently monitored kstats. The structure
* will be added in alphabetical order, using the volume name as the
* key.
*
* parameters
* sdbcstat_t *sdbcstat - to be added to the list.
*
*/
void
{
return;
}
return;
}
/*
* If we get to the last item in the list, then just
* add this one to the end
*/
return;
}
return;
}
}
}
/*
* sdbc_delstat() - deallocate memory for the structure being
* passed in.
*
* parameters
* sdbcstat_t *sdbcstat - structure to be deallocated
*
* returns
* sdbcstat_t * - pointer to the "next" structures in the
* linked list. May be NULL if we are removing the last
* structure in the linked list.
*/
{
return (next);
}
/*
* sdbc_value_check() - Checks for activity, supports -z switch
*
* parameters
* sdbcstat_t *sdbcstat - structure to be checked
*
* returns
* 1 - activity
* 0 - no activity
*/
int
{
return (1);
return (1);
return (1);
return (1);
return (1);
return (1);
return (1);
return (0);
}
/*
* sdbc_validate() - validates the structure of the kstats by attempting to
* lookup fields used by this module
*
* parameters
* kstat_t *ksp - kstat to be examined
*
* returns
* 1 - one or more fields missing
* 0 - all fields present
*/
int
{
return (1);
return (0);
}
/*
* sdbc_getvalues() - populates a values structure with data obtained from the
* kstat
*
* parameters
* sdbcstat_t *sdbcstat - pointer to the structure containing the kstats
* sdbcvals_t *vals - pointer to the structure that will receive the values
* int flags - flags that describe adjustments made to the values
*
* returns
* 1 - failure
* 0 - success
*/
int
{
int divisor = 0;
int factors;
double etime;
return (1);
/* read data */
vals->cache_read =
if (vals->cache_read == 0)
else
/* write data */
vals->cache_write =
vals->disk_write =
if (vals->cache_write == 0)
else
/* miscellaneous */
/* total cache hit calculation */
factors = 0;
if (vals->cache_read != 0) {
factors++;
}
if (vals->cache_write != 0) {
factors++;
}
/* adjustments */
divisor = 1;
if (flags & SDBC_KBYTES)
if (divisor != 1) {
}
return (0);
}
/*
* sdbc_getdelta() - calculates the difference between two kstat fields
*
* parameters
* sdbcstat_t *sdbcstat - the SDBC stat strcture containing the two fields
* char *name - the name of the fields
* returns
* uint32_t value of the differences adjusted for overflow of the data type
*/
{
}
void
{
int lpad = 0;
int rpad = 0;
char fmt[10];
if (size == 0)
return;
lpad++;
}
}