diff options
author | Krishnendu Sadhukhan - Sun Microsystems <Krishnendu.Sadhukhan@Sun.COM> | 2009-08-05 20:39:41 -0700 |
---|---|---|
committer | Krishnendu Sadhukhan - Sun Microsystems <Krishnendu.Sadhukhan@Sun.COM> | 2009-08-05 20:39:41 -0700 |
commit | 26fd77009b17f8c8fb32eb362584cfd635e87ad9 (patch) | |
tree | 6d69403d719d85f7ed8586b733a77f04743e25f4 /usr/src/cmd/intrstat/intrstat.c | |
parent | 7ff836697c120cb94bd30d5c2204eb9b74718e4c (diff) | |
download | illumos-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/intrstat/intrstat.c')
-rw-r--r-- | usr/src/cmd/intrstat/intrstat.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/usr/src/cmd/intrstat/intrstat.c b/usr/src/cmd/intrstat/intrstat.c index 0b17211f67..55dab8f4a8 100644 --- a/usr/src/cmd/intrstat/intrstat.c +++ b/usr/src/cmd/intrstat/intrstat.c @@ -34,12 +34,21 @@ #include <strings.h> #include <termio.h> #include <signal.h> +#include <locale.h> + +#include "statcommon.h" #define INTRSTAT_COLUMN_OFFS 14 #define INTRSTAT_COLUMNS_PER_CPU 15 #define INTRSTAT_CPUS_PER_LINE(w) \ (((w) - INTRSTAT_COLUMN_OFFS) / INTRSTAT_COLUMNS_PER_CPU) -#define INTRSTAT_OPTSTR "x:c:C:" +#define INTRSTAT_OPTSTR "x:c:C:T:" + +static uint_t timestamp_fmt = NODATE; + +#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ +#define TEXT_DOMAIN "SYS_TEST" /* Use this only if it isn't */ +#endif static dtrace_hdl_t *g_dtp; static int *g_present; @@ -78,7 +87,7 @@ usage(void) { (void) fprintf(stderr, "usage: intrstat [ -C psrset | -c cpulist ] [-x opt[=val]] " - "[interval [ count]]\n"); + "[-T d|u] [interval [ count]]\n"); exit(EXIT_FAILURE); } @@ -358,6 +367,9 @@ main(int argc, char **argv) hrtime_t last, now; dtrace_optval_t statustime; + (void) setlocale(LC_ALL, ""); + (void) textdomain(TEXT_DOMAIN); + (void) sigemptyset(&act.sa_mask); act.sa_flags = 0; act.sa_handler = set_width; @@ -452,6 +464,19 @@ main(int argc, char **argv) break; } + case 'T': + if (optarg) { + if (*optarg == 'u') + timestamp_fmt = UDATE; + else if (*optarg == 'd') + timestamp_fmt = DDATE; + else + usage(); + } else { + usage(); + } + break; + default: if (strchr(INTRSTAT_OPTSTR, c) == NULL) usage(); @@ -580,6 +605,9 @@ main(int argc, char **argv) g_start = g_end = 0; + if (timestamp_fmt != NODATE) + print_timestamp(timestamp_fmt); + do { g_header = 1; |