/*
* 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 <locale.h>
#include <kstat.h>
#include "dsstat.h"
#include "multi_stats.h"
/* Globals */
int mode = 0;
int zflag = 0;
int linesout = 0;
short dflags = 0;
short rflags = 0;
void
{
}
void
usage()
{
"\ndsstat [-m <mode>[,<mode>]] [-f | -F] [-z] [-s <sets>] "
"[-r <flags>] \\\n[-d <flags>] [<interval> [<count>]]\n\n"));
}
void
help()
{
usage();
"-d <flags> Specifies the statistics to be displayed\n\n"));
" For 'cache' mode\n"));
" Valid <flags> are 'rwfsdc', default <flags> are 'sf'\n"));
" r=read, w=write, f=flags, s=summary,\n"));
" only available for cache mode, need to combine with '-m'\n"));
" d=destaged, c=write cancellations\n\n"));
" For 'ii' mode;\n"));
" Valid <flags> are 'rwtfps', default <flags> are 'sf'\n"));
" r=read, w=write, t=timing, f=flags, p=percentages,\n"));
" s=summary\n\n"));
" For 'sndr' mode;\n"));
" Valid <flags> are'rwtfpsq', default <flags> are 'spf'\n"));
" r=read, w=write, t=timing, f=flags, p=percentages,\n"));
" s=summary\n"));
" only available for sndr mode, need to combine with '-m'\n"));
" q=queue\n\n"));
"-f prints field headers once for each iteration\n\n"));
"-F prints field headers once, at the start of reporting\n\n"));
"-h prints detailed usage message\n\n"));
"-m <mode>[,<mode>] where mode is, 'cache', 'ii', or 'sndr'\n\n"));
" Multiple modes may be specified as a comma separated list,\n"));
" or multiple -m switches may be used.\n\n"));
"-r <flags> specifies components to be reported\n\n"));
" For 'cache' mode, this option is not used.\n\n"));
" For 'ii' mode;\n"));
" Valid <flags> are 'msbo', default <flags> are 'msbo'\n"));
" m=master, s=shadow, b=bitmap, o=overflow\n\n"));
" For 'sndr' mode;\n"));
" Valid <flags> are 'nb', default <flags> are 'nb'\n"));
" n=network, b=bitmap\n\n"));
"-s <sets> outputs specified sets\n"));
" Where <sets> is a comma delimited list of set names\n\n"));
"-z suppress reports with zero value (no activity)\n\n"));
"<interval> is the number of seconds between reports\n\n"));
"<count> is the number of reports to be generated\n\n"));
}
void
{
usage();
}
int
{
char *m;
int local_mode = 0;
if (local_mode != 0) {
local_mode |= MULTI;
}
local_mode |= SNDR;
continue;
}
local_mode |= IIMG;
continue;
}
local_mode |= SDBC;
continue;
}
}
return (local_mode);
}
short
{
int index;
short user_dflags = 0;
case 'r':
user_dflags |= READ;
break;
case 'w':
user_dflags |= WRITE;
break;
case 't':
user_dflags |= TIMING;
break;
case 'f':
user_dflags |= FLAGS;
break;
case 'p':
user_dflags |= PCTS;
break;
case 's':
user_dflags |= SUMMARY;
break;
case 'd':
user_dflags |= DESTAGED;
break;
case 'c':
user_dflags |= WRCANCEL;
break;
case 'h':
user_dflags |= RATIO;
break;
case 'q':
break;
default:
gettext("Invalid display-flags set\n"));
}
}
return (user_dflags);
}
short
{
int index;
short user_rflags = 0;
case 'm':
user_rflags |= IIMG_MST;
break;
case 's':
user_rflags |= IIMG_SHD;
break;
case 'b':
user_rflags |= IIMG_BMP;
user_rflags |= SNDR_BMP;
break;
case 'o':
user_rflags |= IIMG_OVR;
break;
case 'n':
user_rflags |= SNDR_NET;
break;
default:
gettext("Invalid report-flags set\n"));
}
}
return (user_rflags);
}
void
{
char *volume;
int dup = 0;
/* get user-specified set information */
} else {
*vn = '\0';
vn++;
}
/* check for duplicates */
dup = 0;
dup = 1;
} else {
dup = 1;
}
}
if (dup)
continue;
/* initialize new vslist record */
sizeof (char));
goto save;
sizeof (char));
save:
/* save record */
continue;
}
continue;
}
}
}
int
{
extern char *optarg;
extern int optind;
int c;
int error;
short user_dflags = 0;
short user_rflags = 0;
/* Parse command line */
switch (c) {
case 'd': /* what to display */
break;
case 'f':
break;
case 'F':
break;
case 'h': /* usage */
help();
exit(0);
break;
case 'm': /* Mode */
break;
case 'r': /* what to report on */
break;
case 's':
break;
case 'z':
zflag = 1;
break;
default:
"Invalid argument specified\n");
}
}
/* Parse additional arguments */
gettext("Invalid interval specified.\n"));
} else {
iterations = -1;
}
optind++;
gettext("Invalid count specified.\n"));
}
}
optind++;
}
gettext("Too many parameters specified.\n"));
}
if (mode == 0)
/* Select statistics to gather */
if (user_rflags & IIMG_BMP)
user_rflags ^= IIMG_BMP;
"display-flags for RemoteMirror\n"));
}
gettext("Invalid report-flags for "
"Remote Mirror\n"));
}
}
"statistics can not be displayed with mutiple "
"modes."));
}
if (user_dflags)
else
if (user_rflags)
else
}
if (user_rflags & SNDR_BMP)
user_rflags ^= SNDR_BMP;
gettext("Invalid display-flags for "
"Point-in-Time Copy\n"));
}
gettext("Invalid report-flags for "
"Point-in-Time Copy\n"));
}
}
if (user_dflags)
else
if (user_rflags)
else
}
"display-flags for CACHE\n"));
}
"report-flags for CACHE\n"));
}
} else {
if (user_dflags & DESTAGED)
"statistics can not be displayed with mutiple "
"modes."));
else
"cancellations "
"statistics can not be displayed with mutiple "
"modes."));
}
}
if (user_dflags)
else
else
if (user_rflags)
else
rflags |= user_rflags;
}
"specified mode(s).\n"));
}
gettext("Invalid kstat format detected.\n"));
}
gettext("Unable to open kstat device for reading.\n"));
}
if (error == -1) {
}
}
if (error) {
}
return (0);
}