summaryrefslogtreecommitdiff
path: root/usr/src/cmd/pools
diff options
context:
space:
mode:
authorKrishnendu Sadhukhan - Sun Microsystems <Krishnendu.Sadhukhan@Sun.COM>2009-08-05 20:39:41 -0700
committerKrishnendu Sadhukhan - Sun Microsystems <Krishnendu.Sadhukhan@Sun.COM>2009-08-05 20:39:41 -0700
commit26fd77009b17f8c8fb32eb362584cfd635e87ad9 (patch)
tree6d69403d719d85f7ed8586b733a77f04743e25f4 /usr/src/cmd/pools
parent7ff836697c120cb94bd30d5c2204eb9b74718e4c (diff)
downloadillumos-joyent-26fd77009b17f8c8fb32eb362584cfd635e87ad9.tar.gz
6824918 timestamp option for xxstat commands
PSARC/2009/307 Time Stamp Option for xxstat Commands Phase II Contributed by Chad Mynhier <cmynhier@gmail.com>
Diffstat (limited to 'usr/src/cmd/pools')
-rw-r--r--usr/src/cmd/pools/poolstat/Makefile29
-rw-r--r--usr/src/cmd/pools/poolstat/poolstat.c25
2 files changed, 39 insertions, 15 deletions
diff --git a/usr/src/cmd/pools/poolstat/Makefile b/usr/src/cmd/pools/poolstat/Makefile
index f45f974697..bcb4f27f9d 100644
--- a/usr/src/cmd/pools/poolstat/Makefile
+++ b/usr/src/cmd/pools/poolstat/Makefile
@@ -2,9 +2,8 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
+# 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
# or http://www.opensolaris.org/os/licensing.
@@ -20,11 +19,9 @@
# CDDL HEADER END
#
#
-# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-#ident "%Z%%M% %I% %E% SMI"
-#
# cmd/pools/poolstat/Makefile
PROG = poolstat
@@ -35,30 +32,40 @@ POFILES = $(OBJS:.o=.po)
include ../../Makefile.cmd
include ../Makefile.pools
-CFLAGS += -I$(POOLSCOMMONDIR) $(EXTRA_CFLAGS)
+STATCOMMONDIR = $(SRC)/cmd/stat/common
+
+STAT_COMMON_OBJS = timestamp.o
+STAT_COMMON_SRCS = $(STAT_COMMON_OBJS:%.o=$(STATCOMMONDIR)/%.c)
+SRCS += $(STAT_COMMON_SRCS)
+
+CFLAGS += -I$(POOLSCOMMONDIR) -I$(STATCOMMONDIR) $(EXTRA_CFLAGS)
sparc_COPTFLAG=
LDLIBS += -lpool -lkstat
XGETFLAGS = -a
CLOBBERFILES += $(POFILES)
-lint := LINTFLAGS += -I$(POOLSCOMMONDIR)
+lint := LINTFLAGS += -I$(POOLSCOMMONDIR) -I$(STATCOMMONDIR)
.KEEP_STATE:
all: $(PROG)
-$(PROG): $(OBJS) $(COMMON_OBJS)
- $(LINK.c) -o $@ $(OBJS) $(COMMON_OBJS) $(LDLIBS)
+$(PROG): $(OBJS) $(COMMON_OBJS) $(STAT_COMMON_OBJS)
+ $(LINK.c) -o $@ $(OBJS) $(COMMON_OBJS) $(STAT_COMMON_OBJS) $(LDLIBS)
$(POST_PROCESS)
%.o : $(POOLSCOMMONDIR)/%.c
$(COMPILE.c) -o $@ $<
$(POST_PROCESS_O)
+%.o : $(STATCOMMONDIR)/%.c
+ $(COMPILE.c) -o $@ $<
+ $(POST_PROCESS_O)
+
install: all $(ROOTPROG)
clean:
- $(RM) $(OBJS) $(COMMON_OBJS) $(POFILES)
+ $(RM) $(OBJS) $(COMMON_OBJS) $(STAT_COMMON_OBJS) $(POFILES)
lint: lint_SRCS
diff --git a/usr/src/cmd/pools/poolstat/poolstat.c b/usr/src/cmd/pools/poolstat/poolstat.c
index 3b557c271d..ce6ba51d4a 100644
--- a/usr/src/cmd/pools/poolstat/poolstat.c
+++ b/usr/src/cmd/pools/poolstat/poolstat.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -40,6 +40,7 @@
#include "utils.h"
#include "poolstat.h"
#include "poolstat_utils.h"
+#include "statcommon.h"
#ifndef TEXT_DOMAIN
#define TEXT_DOMAIN "SYS_TEST"
@@ -55,6 +56,8 @@
typedef int (* formatter) (char *, int, int, poolstat_field_format_t *, char *);
+static uint_t timestamp_fmt = NODATE;
+
/* available field formatters */
static int default_f(char *, int, int, poolstat_field_format_t *, char *);
static int bigno_f(char *, int, int, poolstat_field_format_t *, char *);
@@ -163,8 +166,8 @@ usage(void)
{
(void) fprintf(stderr, gettext(
"Usage:\n"
-"poolstat [-p pool-list] [-r rset-list] [interval [count]]\n"
-"poolstat [-p pool-list] [-o format -r rset-list] [interval [count]]\n"
+"poolstat [-p pool-list] [-r rset-list] [-T d|u] [interval [count]]\n"
+"poolstat [-p pool-list] [-o format -r rset-list] [-T d|u] [interval [count]]\n"
" \'pool-list\' is a space-separated list of pool IDs or names\n"
" \'rset-list\' is \'all\' or \'pset\'\n"
" \'format\' for all resource types is one or more of:\n"
@@ -211,7 +214,7 @@ main(int argc, char *argv[])
/* Don't let buffering interfere with piped output. */
(void) setvbuf(stdout, NULL, _IOLBF, 0);
- while ((c = getopt(argc, argv, ":p:r:o:")) != EOF) {
+ while ((c = getopt(argc, argv, ":p:r:o:T:")) != EOF) {
switch (c) {
case 'p': /* pool name specification */
pflag++;
@@ -230,6 +233,18 @@ main(int argc, char *argv[])
usage();
break;
}
+ case 'T':
+ if (optarg) {
+ if (*optarg == 'u')
+ timestamp_fmt = UDATE;
+ else if (*optarg == 'd')
+ timestamp_fmt = DDATE;
+ else
+ usage();
+ } else {
+ usage();
+ }
+ break;
case ':': {
(void) fprintf(stderr,
gettext(ERR_OPTION_ARGS), optopt);
@@ -287,6 +302,8 @@ main(int argc, char *argv[])
/* collect and print out statistics */
while (count-- != 0) {
sa_update(pool_sbag, SA_REFRESH);
+ if (timestamp_fmt != NODATE)
+ print_timestamp(timestamp_fmt);
if (pool_sbag->sb_changed & POU_POOL)
(void) printf(
"<<State change>>\n");