summaryrefslogtreecommitdiff
path: root/usr/src/cmd/rcap/rcapstat
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd/rcap/rcapstat')
-rw-r--r--usr/src/cmd/rcap/rcapstat/Makefile24
-rw-r--r--usr/src/cmd/rcap/rcapstat/rcapstat.c26
2 files changed, 39 insertions, 11 deletions
diff --git a/usr/src/cmd/rcap/rcapstat/Makefile b/usr/src/cmd/rcap/rcapstat/Makefile
index afea8d5c91..87e58eb043 100644
--- a/usr/src/cmd/rcap/rcapstat/Makefile
+++ b/usr/src/cmd/rcap/rcapstat/Makefile
@@ -19,10 +19,9 @@
# CDDL HEADER END
#
#
-# Copyright 2007 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"
.KEEP_STATE:
.SUFFIXES:
@@ -34,19 +33,25 @@ SRCS = rcapstat.c \
utils.c
LINTSRCS = $(COMMON_DIR)/utils.c \
- rcapstat.c
+ rcapstat.c \
+ $(STAT_COMMON_SRCS)
+
+STATCOMMONDIR = $(SRC)/cmd/stat/common
+
+STAT_COMMON_OBJS = timestamp.o
+STAT_COMMON_SRCS = $(STAT_COMMON_OBJS:%.o=$(STATCOMMONDIR)/%.c)
$(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG
-CPPFLAGS += -I$(COMMON_DIR)
+CPPFLAGS += -I$(COMMON_DIR) -I$(STATCOMMONDIR)
LDLIBS += -lumem -lzonecfg -lscf
LDFLAGS += $(MAPFILE.NGB:%=-M%)
LINTFLAGS += $(LDLIBS) -mnu
PROG = rcapstat
-OBJS = $(SRCS:%.c=%.o) rcapd_conf.o
+OBJS = $(SRCS:%.c=%.o) rcapd_conf.o $(STAT_COMMON_OBJS)
-POFILES = $(OBJS:%.o=%.po)
+POFILES = $(OBJS:%.o=%.po) $(STAT_COMMON_OBJS:%.o=%.po)
POFILE = p$(PROG).po
CLOBBERFILES += rcapd_conf.c $(POFILES) $(POFILE)
@@ -62,10 +67,17 @@ $(PROG): $(OBJS)
$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
$(POST_PROCESS)
+%.o : $(STATCOMMONDIR)/%.c
+ $(COMPILE.c) -o $@ $<
+ $(POST_PROCESS_O)
+
$(POFILE): $(POFILES)
$(RM) $@
$(CAT) $(POFILES) > $@
+%.po: $(STATCOMMONDIR)/%.c
+ $(COMPILE.cpp) $< > $<.i
+ $(BUILD.po)
clean:
$(RM) $(OBJS)
diff --git a/usr/src/cmd/rcap/rcapstat/rcapstat.c b/usr/src/cmd/rcap/rcapstat/rcapstat.c
index a22a40f50d..edac6dd56d 100644
--- a/usr/src/cmd/rcap/rcapstat/rcapstat.c
+++ b/usr/src/cmd/rcap/rcapstat/rcapstat.c
@@ -19,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 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/stat.h>
#include <stdlib.h>
@@ -40,6 +38,7 @@
#include "rcapd.h"
#include "utils.h"
#include "rcapd_stat.h"
+#include "statcommon.h"
static char mode[RC_MODE_LEN];
static rcapd_stat_hdr_t hdr;
@@ -47,6 +46,8 @@ static int global;
static int unformatted;
static time_t stat_mod = 0;
+static uint_t timestamp_fmt = NODATE;
+
typedef struct col {
rcid_t col_id;
char col_name[LC_NAME_LEN];
@@ -119,7 +120,8 @@ static void
usage()
{
(void) fprintf(stderr,
- gettext("usage: rcapstat [-g] [-p | -z] [interval [count]]\n"));
+ gettext("usage: rcapstat [-g] [-p | -z] [-T d|u] "
+ "[interval [count]]\n"));
exit(E_USAGE);
}
@@ -366,7 +368,7 @@ main(int argc, char *argv[])
(void) setprogname("rcapstat");
global = unformatted = 0;
- while ((opt = getopt(argc, argv, "gpuz")) != (int)EOF) {
+ while ((opt = getopt(argc, argv, "gpuzT:")) != (int)EOF) {
switch (opt) {
case 'g':
global = 1;
@@ -382,6 +384,18 @@ main(int argc, char *argv[])
stat_type = RCIDT_ZONE;
zones = 1;
break;
+ case 'T':
+ if (optarg) {
+ if (*optarg == 'u')
+ timestamp_fmt = UDATE;
+ else if (*optarg == 'd')
+ timestamp_fmt = DDATE;
+ else
+ usage();
+ } else {
+ usage();
+ }
+ break;
default:
usage();
}
@@ -401,6 +415,8 @@ main(int argc, char *argv[])
while (always || count-- > 0) {
if (read_stats(stat_type) != E_SUCCESS)
return (E_ERROR);
+ if (timestamp_fmt != NODATE)
+ print_timestamp(timestamp_fmt);
if (!unformatted) {
print_stats(stat_type);
(void) fflush(stdout);