summaryrefslogtreecommitdiff
path: root/usr/src/cmd/ctstat
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/ctstat
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/ctstat')
-rw-r--r--usr/src/cmd/ctstat/Makefile29
-rw-r--r--usr/src/cmd/ctstat/ctstat.c26
2 files changed, 43 insertions, 12 deletions
diff --git a/usr/src/cmd/ctstat/Makefile b/usr/src/cmd/ctstat/Makefile
index 300f5dd395..8f84632dc6 100644
--- a/usr/src/cmd/ctstat/Makefile
+++ b/usr/src/cmd/ctstat/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,16 +19,23 @@
# 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.
#
-#pragma ident "%Z%%M% %I% %E% SMI"
-
PROG= ctstat
+OBJS = ctstat.o
+SRCS = $(OBJS:%.o=%.c)
include ../Makefile.cmd
+STATCOMMONDIR = $(SRC)/cmd/stat/common
+
+STAT_COMMON_OBJS = timestamp.o
+STAT_COMMON_SRCS = $(STAT_COMMON_OBJS:%.o=$(STATCOMMONDIR)/%.c)
+SRCS += $(STAT_COMMON_SRCS)
+
+CPPFLAGS += -I$(STATCOMMONDIR)
CFLAGS += -v
LDLIBS += -lcontract -luutil
@@ -37,10 +43,19 @@ LDLIBS += -lcontract -luutil
all: $(PROG)
+$(PROG): $(OBJS) $(STAT_COMMON_OBJS)
+ $(LINK.c) -o $(PROG) $(OBJS) $(STAT_COMMON_OBJS) $(LDLIBS)
+ $(POST_PROCESS)
+
+%.o : $(STATCOMMONDIR)/%.c
+ $(COMPILE.c) -o $@ $<
+ $(POST_PROCESS_O)
+
install: all $(ROOTPROG)
clean:
+ $(RM) $(OBJS) $(STAT_COMMON_OBJS)
-lint: lint_PROG
+lint: lint_SRCS
include ../Makefile.targ
diff --git a/usr/src/cmd/ctstat/ctstat.c b/usr/src/cmd/ctstat/ctstat.c
index 5f174195c4..5893a65118 100644
--- a/usr/src/cmd/ctstat/ctstat.c
+++ b/usr/src/cmd/ctstat/ctstat.c
@@ -19,12 +19,10 @@
* 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.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/types.h>
#include <sys/ctfs.h>
#include <stdio.h>
@@ -43,6 +41,10 @@
#include <locale.h>
#include <langinfo.h>
+#include "statcommon.h"
+
+static uint_t timestamp_fmt = NODATE;
+
static int opt_verbose = 0;
static int opt_showall = 0;
@@ -55,7 +57,7 @@ static void
usage(void)
{
(void) fprintf(stderr, gettext("Usage: %s [-a] [-i ctidlist] "
- "[-t typelist] [-v] [interval [count]]\n"), uu_getpname());
+ "[-t typelist] [-T d|u] [-v] [interval [count]]\n"), uu_getpname());
exit(UU_EXIT_USAGE);
}
@@ -770,7 +772,7 @@ main(int argc, char **argv)
(void) uu_setpname(argv[0]);
- while ((s = getopt(argc, argv, "ai:t:v")) != EOF) {
+ while ((s = getopt(argc, argv, "ai:T:t:v")) != EOF) {
switch (s) {
case 'a':
opt_showall = 1;
@@ -778,6 +780,18 @@ main(int argc, char **argv)
case 'i':
nids = parse_ids(optarg, (int **)&ids, nids);
break;
+ case 'T':
+ if (optarg) {
+ if (*optarg == 'u')
+ timestamp_fmt = UDATE;
+ else if (*optarg == 'd')
+ timestamp_fmt = DDATE;
+ else
+ usage();
+ } else {
+ usage();
+ }
+ break;
case 't':
ntypes = parse_types(optarg, &types, ntypes);
break;
@@ -814,6 +828,8 @@ main(int argc, char **argv)
for (i = 0; count == 0 || i < count; i++) {
if (i)
(void) sleep(interval);
+ if (timestamp_fmt != NODATE)
+ print_timestamp(timestamp_fmt);
print_header();
if (nids && ntypes)
scan_all(types, ntypes, ids, nids);