On Thu, Oct 13, 2016 at 08:01:22AM +0200, Otto Moerbeek wrote:

> On Thu, Oct 13, 2016 at 12:15:34AM -0400, Ted Unangst wrote:
> 
> > Theo de Raadt wrote:
> > > > On Wed, Oct 12, 2016 at 03:20:00PM +0200, Otto Moerbeek wrote:
> > > > > simple diff to show the hostname on the second line. OK?
> > > > 
> > > > OK bluhm@
> > > > 
> > > > > 
> > > > > BTW, batch mode doesn't function here as expected. Need to look into 
> > > > > that,
> > > 
> > > I hoped this would look more like top(1) so I did it a different way.
> > > This does not work quite right for long hostnames, but then.. neither
> > > does top.
> > 
> > this truncates hostname to always display time.
> 
> If the line grows (because of multiple pages and/or PAUSED mode), the
> line wraps now.... Also, we have hostname already available in a
> buffer. 
> 
>       -Otto
> 

new diff against current:

Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/systat/main.c,v
retrieving revision 1.65
diff -u -p -r1.65 main.c
--- main.c      13 Oct 2016 05:46:20 -0000      1.65
+++ main.c      13 Oct 2016 06:20:30 -0000
@@ -67,7 +67,6 @@ int   ut, hz, stathz;
 char    hostname[HOST_NAME_MAX+1];
 WINDOW  *wnd;
 int    CMDLINE;
-char   hostbuf[26];
 char   timebuf[26];
 char   uloadbuf[TIMEPOS];
 
@@ -110,8 +109,6 @@ print_header(void)
                    "%5d users    Load %.2f %.2f %.2f", 
                    ucount(), avenrun[0], avenrun[1], avenrun[2]);
 
-               gethostname(hostbuf, sizeof hostbuf);
-
                time(&now);
                ctim = ctime(&now);
                ctim[11+8] = '\0';
@@ -127,7 +124,8 @@ print_header(void)
                    "%s %s", uloadbuf,
                    paused ? "PAUSED" : "");
                
-       snprintf(header, sizeof(header), "%-45s%25.25s %s", tmpbuf, hostbuf, 
timebuf);
+       snprintf(header, sizeof(header), "%-44s %15.15s %s", tmpbuf, hostname,
+           timebuf);
 
        if (rawmode)
                printf("\n\n%s\n", header);

Reply via email to