summaryrefslogtreecommitdiff
path: root/usr.bin/systat
diff options
context:
space:
mode:
authorlum <lum@cvs.openbsd.org>2011-03-31 06:12:35 +0000
committerlum <lum@cvs.openbsd.org>2011-03-31 06:12:35 +0000
commita22b86fa19fb21bfa02387560a32eada7648740b (patch)
tree978b431430f47acd0d4b5730e00deed0d558dce1 /usr.bin/systat
parent1b7bc77cdd83eb15f5f7a9c25cd6069950dfe4c2 (diff)
Make the top line of systat stop updating, along with the rest of the data
when 'p' is pressed. ok nicm@
Diffstat (limited to 'usr.bin/systat')
-rw-r--r--usr.bin/systat/main.c48
-rw-r--r--usr.bin/systat/systat.h4
2 files changed, 33 insertions, 19 deletions
diff --git a/usr.bin/systat/main.c b/usr.bin/systat/main.c
index f4e0012b3b5..4f6662d0c06 100644
--- a/usr.bin/systat/main.c
+++ b/usr.bin/systat/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.57 2010/07/16 05:22:48 lum Exp $ */
+/* $Id: main.c,v 1.58 2011/03/31 06:12:34 lum Exp $ */
/*
* Copyright (c) 2001, 2007 Can Erkin Acar
* Copyright (c) 2001 Daniel Hartmeier
@@ -53,6 +53,8 @@
#include "engine.h"
#include "systat.h"
+#define TIMEPOS 55
+
double dellave;
kvm_t *kd;
@@ -66,8 +68,9 @@ int ut, hz, stathz;
char hostname[MAXHOSTNAMELEN];
WINDOW *wnd;
int CMDLINE;
+char timebuf[26];
+char uloadbuf[TIMEPOS];
-#define TIMEPOS 55
int ucount(void);
void usage(void);
@@ -90,32 +93,41 @@ print_header(void)
{
time_t now;
int start = dispstart + 1, end = dispstart + maxprint;
- char tbuf[26];
+ char tmpbuf[TIMEPOS];
+ char header[MAX_LINE_BUF];
if (end > num_disp)
end = num_disp;
tb_start();
- getloadavg(avenrun, sizeof(avenrun) / sizeof(avenrun[0]));
+ if (!paused) {
+ getloadavg(avenrun, sizeof(avenrun) / sizeof(avenrun[0]));
- time(&now);
- strlcpy(tbuf, ctime(&now), sizeof tbuf);
- tbprintf(" %d users", ucount());
- tbprintf(" Load %.2f %.2f %.2f", avenrun[0], avenrun[1], avenrun[2]);
- if (num_disp && (start > 1 || end != num_disp))
- tbprintf(" (%u-%u of %u)", start, end, num_disp);
-
- if (paused)
- tbprintf(" PAUSED");
+ snprintf(uloadbuf, sizeof(uloadbuf),
+ "%5d users Load %.2f %.2f %.2f",
+ ucount(), avenrun[0], avenrun[1], avenrun[2]);
- if (rawmode) {
- printf("\n\n%-55s%s\n", tmp_buf, tbuf);
- } else {
- mvprintw(0, 0, "%s", tmp_buf);
- mvprintw(0, TIMEPOS, "%s", tbuf);
+ time(&now);
+ strlcpy(timebuf, ctime(&now), sizeof(timebuf));
}
+ if (num_disp && (start > 1 || end != num_disp))
+ snprintf(tmpbuf, sizeof(tmpbuf),
+ "%s (%u-%u of %u) %s", uloadbuf, start, end, num_disp,
+ paused ? "PAUSED" : "");
+ else
+ snprintf(tmpbuf, sizeof(tmpbuf),
+ "%s %s", uloadbuf,
+ paused ? "PAUSED" : "");
+
+ snprintf(header, sizeof(header), "%-55s%s", tmpbuf, timebuf);
+
+ if (rawmode)
+ printf("\n\n%s\n", header);
+ else
+ mvprintw(0, 0, "%s", header);
+
return (1);
}
diff --git a/usr.bin/systat/systat.h b/usr.bin/systat/systat.h
index de41bc8ee9d..0ab1e28898f 100644
--- a/usr.bin/systat/systat.h
+++ b/usr.bin/systat/systat.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: systat.h,v 1.16 2011/03/02 06:48:17 jasper Exp $ */
+/* $OpenBSD: systat.h,v 1.17 2011/03/31 06:12:34 lum Exp $ */
/* $NetBSD: systat.h,v 1.2 1995/01/20 08:52:14 jtc Exp $ */
/*-
@@ -69,6 +69,8 @@ extern size_t nports;
extern int protos;
extern int verbose;
extern int nflag;
+extern char uloadbuf[];
+extern char timebuf[];
struct inpcb;