Commit 8da97950 authored by Mike Hibler's avatar Mike Hibler
Browse files

Add -L option to capture to print out how long it has been since last output.

We currently put out a time stamp when we detect output after being idle for
a long time. But the time stamp is the time at which we started getting output
again, so it doesn't give us any idea how long it was idle (i.e., when the
last previous output happened).

So -L changes the format of the stamp from "STAMP{ctime-string}" to
"STAMP{idle@ctime-string}", where "idle" is the number of seconds it has been
since the last output.
parent 09b1ba5d
.\" .\"
.\" EMULAB-COPYRIGHT .\" EMULAB-COPYRIGHT
.\" Copyright (c) 2000 University of Utah and the Flux Group. .\" Copyright (c) 2000, 2012 University of Utah and the Flux Group.
.\" All rights reserved. .\" All rights reserved.
.\" .\"
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
.Nm capture .Nm capture
.Op Fl s Ar speed .Op Fl s Ar speed
.Op Fl H .Op Fl H
.Op Fl T Ar seconds
.Ar remote-name .Ar remote-name
.Ar dev-name .Ar dev-name
.Sh DESCRIPTION .Sh DESCRIPTION
...@@ -29,6 +30,16 @@ The options are as follows: ...@@ -29,6 +30,16 @@ The options are as follows:
Set the speed in bps (2400, 9600, 115200, etc) Set the speed in bps (2400, 9600, 115200, etc)
.It Fl H .It Fl H
Use hardware flow control Use hardware flow control
.It Fl T Ar sinterval
If more than
.Ar sinterval
seconds have elapsed since the
last output to the device, put out a timestamp of the form "STAMP{time}"
reflecting the current time.
If
.Fl L
is also specified, then the stamp will be of the form "STAMP{delta@time}"
where delta reflects the actual number of seconds since the last output.
.Sh CONFIGURATION .Sh CONFIGURATION
You should run one copy of You should run one copy of
.Nm capture .Nm capture
......
/* /*
* EMULAB-COPYRIGHT * EMULAB-COPYRIGHT
* Copyright (c) 2000-2008 University of Utah and the Flux Group. * Copyright (c) 2000-2012 University of Utah and the Flux Group.
* All rights reserved. * All rights reserved.
*/ */
...@@ -124,6 +124,7 @@ char *Machine; ...@@ -124,6 +124,7 @@ char *Machine;
int logfd = -1, runfd, devfd = -1, ptyfd = -1; int logfd = -1, runfd, devfd = -1, ptyfd = -1;
int hwflow = 0, speed = B9600, debug = 0, runfile = 0, standalone = 0; int hwflow = 0, speed = B9600, debug = 0, runfile = 0, standalone = 0;
int stampinterval = -1; int stampinterval = -1;
int stamplast = 0;
sigset_t actionsigmask; sigset_t actionsigmask;
sigset_t allsigmask; sigset_t allsigmask;
int powermon = 0; int powermon = 0;
...@@ -325,7 +326,7 @@ main(int argc, char **argv) ...@@ -325,7 +326,7 @@ main(int argc, char **argv)
else else
Progname = *argv; Progname = *argv;
while ((op = getopt(argc, argv, "rds:Hb:ip:c:T:aou:v:Pm")) != EOF) while ((op = getopt(argc, argv, "rds:Hb:ip:c:T:aou:v:PmL")) != EOF)
switch (op) { switch (op) {
#ifdef USESOCKETS #ifdef USESOCKETS
#ifdef WITHSSL #ifdef WITHSSL
...@@ -366,6 +367,9 @@ main(int argc, char **argv) ...@@ -366,6 +367,9 @@ main(int argc, char **argv)
(speed = val2speed(i)) == 0) (speed = val2speed(i)) == 0)
usage(); usage();
break; break;
case 'L':
stamplast = 1;
break;
case 'T': case 'T':
stampinterval = atoi(optarg); stampinterval = atoi(optarg);
if (stampinterval < 0) if (stampinterval < 0)
...@@ -894,17 +898,26 @@ dropped: ...@@ -894,17 +898,26 @@ dropped:
if (stampinterval >= 0) { if (stampinterval >= 0) {
static time_t laststamp; static time_t laststamp;
struct timeval tv; struct timeval tv;
char stampbuf[40], *cts; char stampbuf[64], *cts;
time_t now; time_t now, delta;
gettimeofday(&tv, 0); gettimeofday(&tv, 0);
now = tv.tv_sec; now = tv.tv_sec;
delta = now - laststamp;
if (stampinterval == 0 || if (stampinterval == 0 ||
now > laststamp + stampinterval) { delta > stampinterval) {
cts = ctime(&now); cts = ctime(&now);
cts[24] = 0; cts[24] = 0;
snprintf(stampbuf, sizeof stampbuf, if (stamplast && laststamp)
"\nSTAMP{%s}\n", cts); snprintf(stampbuf,
sizeof stampbuf,
"\nSTAMP{%u@%s}\n",
(unsigned)delta, cts);
else
snprintf(stampbuf,
sizeof stampbuf,
"\nSTAMP{%s}\n",
cts);
write(logfd, stampbuf, write(logfd, stampbuf,
strlen(stampbuf)); strlen(stampbuf));
} }
...@@ -1182,7 +1195,7 @@ char *optstr = ...@@ -1182,7 +1195,7 @@ char *optstr =
#endif #endif
"[-b bossnode] [-p bossport] [-i] " "[-b bossnode] [-p bossport] [-i] "
#endif #endif
"-HdraoP [-s speed] [-T stampinterval]"; "-HdraoPL [-s speed] [-T stampinterval]";
void void
usage(void) usage(void)
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment