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

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
.\" Copyright (c) 2000 University of Utah and the Flux Group.
.\" Copyright (c) 2000, 2012 University of Utah and the Flux Group.
.\" All rights reserved.
.\"
......@@ -14,6 +14,7 @@
.Nm capture
.Op Fl s Ar speed
.Op Fl H
.Op Fl T Ar seconds
.Ar remote-name
.Ar dev-name
.Sh DESCRIPTION
......@@ -29,6 +30,16 @@ The options are as follows:
Set the speed in bps (2400, 9600, 115200, etc)
.It Fl H
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
You should run one copy of
.Nm capture
......
/*
* 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.
*/
......@@ -124,6 +124,7 @@ char *Machine;
int logfd = -1, runfd, devfd = -1, ptyfd = -1;
int hwflow = 0, speed = B9600, debug = 0, runfile = 0, standalone = 0;
int stampinterval = -1;
int stamplast = 0;
sigset_t actionsigmask;
sigset_t allsigmask;
int powermon = 0;
......@@ -325,7 +326,7 @@ main(int argc, char **argv)
else
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) {
#ifdef USESOCKETS
#ifdef WITHSSL
......@@ -366,6 +367,9 @@ main(int argc, char **argv)
(speed = val2speed(i)) == 0)
usage();
break;
case 'L':
stamplast = 1;
break;
case 'T':
stampinterval = atoi(optarg);
if (stampinterval < 0)
......@@ -894,17 +898,26 @@ dropped:
if (stampinterval >= 0) {
static time_t laststamp;
struct timeval tv;
char stampbuf[40], *cts;
time_t now;
char stampbuf[64], *cts;
time_t now, delta;
gettimeofday(&tv, 0);
now = tv.tv_sec;
delta = now - laststamp;
if (stampinterval == 0 ||
now > laststamp + stampinterval) {
delta > stampinterval) {
cts = ctime(&now);
cts[24] = 0;
snprintf(stampbuf, sizeof stampbuf,
"\nSTAMP{%s}\n", cts);
if (stamplast && laststamp)
snprintf(stampbuf,
sizeof stampbuf,
"\nSTAMP{%u@%s}\n",
(unsigned)delta, cts);
else
snprintf(stampbuf,
sizeof stampbuf,
"\nSTAMP{%s}\n",
cts);
write(logfd, stampbuf,
strlen(stampbuf));
}
......@@ -1182,7 +1195,7 @@ char *optstr =
#endif
"[-b bossnode] [-p bossport] [-i] "
#endif
"-HdraoP [-s speed] [-T stampinterval]";
"-HdraoPL [-s speed] [-T stampinterval]";
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