summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2016-10-13 05:46:20 +0000
committertedu <tedu@openbsd.org>2016-10-13 05:46:20 +0000
commit619a3eb850fb786fc3d86b39561fd432f5eb7ddc (patch)
tree268adf741323d24b65cc919ad631cf89ae0b78e6
parentFix races during syslogd startup and shutdown in privsep tests. (diff)
downloadwireguard-openbsd-619a3eb850fb786fc3d86b39561fd432f5eb7ddc.tar.xz
wireguard-openbsd-619a3eb850fb786fc3d86b39561fd432f5eb7ddc.zip
add the hostname to the display. started by otto, then deraadt. ok deraadt
-rw-r--r--usr.bin/systat/main.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/usr.bin/systat/main.c b/usr.bin/systat/main.c
index 4f625559781..bade124729b 100644
--- a/usr.bin/systat/main.c
+++ b/usr.bin/systat/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.64 2016/01/02 15:02:05 benno Exp $ */
+/* $Id: main.c,v 1.65 2016/10/13 05:46:20 tedu Exp $ */
/*
* Copyright (c) 2001, 2007 Can Erkin Acar
* Copyright (c) 2001 Daniel Hartmeier
@@ -67,6 +67,7 @@ int ut, hz, stathz;
char hostname[HOST_NAME_MAX+1];
WINDOW *wnd;
int CMDLINE;
+char hostbuf[26];
char timebuf[26];
char uloadbuf[TIMEPOS];
@@ -101,14 +102,20 @@ 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);
+
time(&now);
- strlcpy(timebuf, ctime(&now), sizeof(timebuf));
+ ctim = ctime(&now);
+ ctim[11+8] = '\0';
+ strlcpy(timebuf, ctim + 11, sizeof(timebuf));
}
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), "%-45s%25.25s %s", tmpbuf, hostbuf, timebuf);
if (rawmode)
printf("\n\n%s\n", header);