* Fix a display buglet: if the process list is exhausted before the window's
bottom is reached, clear the remaining lines, lest there be stale process entries if the process list shrinks. * Implement a top(1)-like `user' command in the ps display.
This commit is contained in:
parent
1a2a0445fa
commit
c23c312a55
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cmdtab.c,v 1.11 1999/12/20 03:45:02 jwise Exp $ */
|
||||
/* $NetBSD: cmdtab.c,v 1.12 1999/12/22 14:46:14 kleink Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1980, 1992, 1993
|
||||
@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
__RCSID("$NetBSD: cmdtab.c,v 1.11 1999/12/20 03:45:02 jwise Exp $");
|
||||
__RCSID("$NetBSD: cmdtab.c,v 1.12 1999/12/22 14:46:14 kleink Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include "systat.h"
|
||||
@ -82,6 +82,11 @@ struct command netstat_commands[] = {
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
struct command ps_commands[] = {
|
||||
{ "user", ps_user, "limit displayed processes to a user"},
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
struct command vmstat_commands[] = {
|
||||
{ "boot", vmstat_boot, "show total vm stats since boot"},
|
||||
{ "run", vmstat_run, "show running total vm stats"},
|
||||
@ -126,7 +131,7 @@ struct mode modes[] = {
|
||||
initnetstat, opennetstat, closenetstat, netstat_commands,
|
||||
CF_LOADAV },
|
||||
{ "ps", showps, fetchpigs, labelps,
|
||||
initpigs, openpigs, closepigs, 0,
|
||||
initpigs, openpigs, closepigs, ps_commands,
|
||||
CF_LOADAV },
|
||||
{ "swap", showswap, fetchswap, labelswap,
|
||||
initswap, openswap, closeswap, 0,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: extern.h,v 1.16 1999/12/20 04:06:25 jwise Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.17 1999/12/22 14:46:15 kleink Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
@ -145,6 +145,7 @@ WINDOW *opennetstat __P((void));
|
||||
WINDOW *openpigs __P((void));
|
||||
WINDOW *openswap __P((void));
|
||||
WINDOW *opentcp __P((void));
|
||||
void ps_user __P((char *));
|
||||
void redraw __P((int));
|
||||
void showbufcache __P((void));
|
||||
void showicmp __P((void));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ps.c,v 1.11 1999/12/20 19:31:47 jwise Exp $ */
|
||||
/* $NetBSD: ps.c,v 1.12 1999/12/22 14:46:15 kleink Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999
|
||||
@ -45,7 +45,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: ps.c,v 1.11 1999/12/20 19:31:47 jwise Exp $");
|
||||
__RCSID("$NetBSD: ps.c,v 1.12 1999/12/22 14:46:15 kleink Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -80,6 +80,9 @@ char *time2str __P((struct kinfo_proc *));
|
||||
|
||||
static time_t now;
|
||||
|
||||
#define SHOWUSER_ANY (uid_t)-1
|
||||
static uid_t showuser = SHOWUSER_ANY;
|
||||
|
||||
void
|
||||
labelps ()
|
||||
{
|
||||
@ -103,11 +106,13 @@ showps ()
|
||||
i = nproc + 1;
|
||||
if (i > getmaxy(wnd)-2)
|
||||
i = getmaxy(wnd)-1;
|
||||
for (k = 0; i > 0 ; i--, y++, k++) {
|
||||
for (k = 0; i > 0 ; k++) {
|
||||
if (pt[k].pt_kp == NULL) /* We're all the way down to the imaginary idle proc */
|
||||
return;
|
||||
break;
|
||||
|
||||
ep = &pt[k].pt_kp->kp_eproc;
|
||||
if (showuser != SHOWUSER_ANY && ep->e_ucred.cr_uid != showuser)
|
||||
continue;
|
||||
user = user_from_uid(ep->e_ucred.cr_uid, 0);
|
||||
pid = pt[k].pt_kp->kp_proc.p_pid;
|
||||
pctcpu = 100.0 * pt[k].pt_pctcpu;
|
||||
@ -123,9 +128,13 @@ showps ()
|
||||
|
||||
wmove(wnd, y, 0);
|
||||
wclrtoeol(wnd);
|
||||
mvwprintw(wnd, y, 0, "%-8.8s%5d %4.1f %4.1f %6d %5d %-3s %-4s %7s %10.10s %s",
|
||||
mvwprintw(wnd, y++, 0,
|
||||
"%-8.8s%5d %4.1f %4.1f %6d %5d %-3s %-4s %7s %10.10s %s",
|
||||
user, pid, pctcpu, pctmem, vsz, rss, tty, state, start, time, comm);
|
||||
i--;
|
||||
}
|
||||
wmove(wnd, y, 0);
|
||||
wclrtobot(wnd);
|
||||
}
|
||||
|
||||
int
|
||||
@ -384,3 +393,22 @@ time2str(kp)
|
||||
|
||||
return timestr;
|
||||
}
|
||||
|
||||
void
|
||||
ps_user(args)
|
||||
char *args;
|
||||
{
|
||||
uid_t uid;
|
||||
|
||||
if (args == NULL)
|
||||
args = "";
|
||||
if (strcmp(args, "+") == 0) {
|
||||
uid = SHOWUSER_ANY;
|
||||
} else if (uid_from_user(args, &uid) != 0) {
|
||||
error("%s: unknown user", args);
|
||||
return;
|
||||
}
|
||||
|
||||
showuser = uid;
|
||||
display(0);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: systat.1,v 1.16 1999/11/15 06:16:57 simonb Exp $
|
||||
.\" $NetBSD: systat.1,v 1.17 1999/12/22 14:46:15 kleink Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1985, 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -281,6 +281,19 @@ by the command
|
||||
.Xr ps 1
|
||||
with the flags
|
||||
.Fl aux .
|
||||
.Pp
|
||||
The following command is specific to the
|
||||
.Ic ps
|
||||
display; the minimum unambiguous prefix may be supplied.
|
||||
.Pp
|
||||
.Bl -tag -width Fl -compact
|
||||
.It Cm user Ar name
|
||||
Limit the list of processes displayed to those owned by user
|
||||
.Ar name .
|
||||
If
|
||||
.Ar name
|
||||
is specified as `+', processes owned by any user are displayed (default).
|
||||
.El
|
||||
.It Ic swap
|
||||
Show information about swap space usage on all the
|
||||
swap areas configured with
|
||||
|
Loading…
Reference in New Issue
Block a user