> 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.

Shrug.

Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/systat/main.c,v
retrieving revision 1.64
diff -u -p -u -r1.64 main.c
--- main.c      2 Jan 2016 15:02:05 -0000       1.64
+++ main.c      13 Oct 2016 03:50:16 -0000
@@ -67,7 +67,7 @@ int   ut, hz, stathz;
 char    hostname[HOST_NAME_MAX+1];
 WINDOW  *wnd;
 int    CMDLINE;
-char   timebuf[26];
+char   hostbuf[26];
 char   uloadbuf[TIMEPOS];
 
 
@@ -101,14 +101,21 @@ print_header(void)
        tb_start();
 
        if (!paused) {
+               char *ctim;
+
                getloadavg(avenrun, sizeof(avenrun) / sizeof(avenrun[0]));
 
                snprintf(uloadbuf, sizeof(uloadbuf),
                    "%5d users    Load %.2f %.2f %.2f", 
                    ucount(), avenrun[0], avenrun[1], avenrun[2]);
 
+               gethostname(hostbuf, sizeof hostbuf);
+               strlcat(hostbuf, " ", sizeof hostbuf);
+
                time(&now);
-               strlcpy(timebuf, ctime(&now), sizeof(timebuf));
+               ctim = ctime(&now);
+               ctim[11+8] = '\0';
+               strlcat(hostbuf, ctim + 11, sizeof(hostbuf));
        }
 
        if (num_disp && (start > 1 || end != num_disp))
@@ -120,7 +127,7 @@ print_header(void)
                    "%s %s", uloadbuf,
                    paused ? "PAUSED" : "");
                
-       snprintf(header, sizeof(header), "%-55s%s", tmpbuf, timebuf);
+       snprintf(header, sizeof(header), "%-55s%s", tmpbuf, hostbuf);
 
        if (rawmode)
                printf("\n\n%s\n", header);

Reply via email to