/*% cc -a % -lcurses -ltermlib -lm
static char sccsid
[] = "@(#)main.c 1.1 (Lucasfilm) %G%";
int showpigs(), openpigs(), fetchpigs(), labelpigs();
int showswap(), fetchswap(), labelswap();
int showuser(), openuser(), fetchuser(), labeluser();
int shownet(), opennet(), fetchnet(), labelnet();
{ "pigs", showpigs
, openpigs
, fetchpigs
,
{ "swap", showswap
, openpigs
, fetchswap
,
{ "user", showuser
, openuser
, fetchuser
,
{ "net", shownet
, opennet
, fetchnet
,
struct cmdtab
*curcmd
= &cmdtab
[0];
wnd
= newwin(20, 70, 3, 5);
lseek(kmem
, nlst
[X_CCPU
].n_value
, 0);
read(kmem
, &ccpu
, sizeof (ccpu
));
gethostname(hostname
, sizeof (hostname
));
strcpy(known
[0].k_name
, "<idle>");
signal(SIGALRM
, display
);
signal(SIGTSTP
, suspend
);
if (ch
== 0177 && ferror(stdin
)) {
if (ch
>= 'A' && ch
<= 'Z')
if (ch
== _tty
.sg_erase
&& col
> 0) {
if (col
== 1 && line
[0] == ':')
if (ch
== CTRL(w
) && col
> 0) {
while (--col
>= 0 && isspace(line
[col
]))
while (--col
>= 0 && !isspace(line
[col
]))
if (col
== 0 && line
[0] == ':')
if (ch
== _tty
.sg_kill
&& col
> 0) {
} while (col
== 0 || (ch
!= '\r' && ch
!= '\n'));
register struct cmdtab
*p
;
for (cp
= cmd
; *cp
&& !isspace(*cp
); cp
++)
if (strcmp(cmd
, "quit") == 0)
if (strcmp(cmd
, "status") == 0 || strcmp(cmd
, "help") == 0) {
for (p
= cmdtab
; *p
->c_name
; p
++)
if (strcmp(cmd
, p
->c_name
) == 0)
if (strcmp(cmd
, "stop") == 0) {
mvaddstr(22, 0, "Refresh disabled.");
/* commands with arguments */
for (; *cp
&& isspace(*cp
); cp
++)
if (strcmp(cmd
, "start") == 0) {
mvprintw(22, 0, "%d: bad interval.", x
);
mvprintw(22, 0, "%s: Unknown command.", cmd
);
mvprintw(22, 0, "Showing %s, refresh every %d seconds.",
curcmd
->c_name
, naptime
);
signal(SIGTSTP
, SIG_DFL
);
signal(SIGTSTP
, suspend
);
"/0 /1 /2 /3 /4 /5 /6 /7 /8 /9 /10");
mvwaddstr(wnd
, 0, 0, "Load Average");
mvprintw(21, 25, "CPU usage on %s", hostname
);
/* Get the load average over the last minute. */
lseek(kmem
, nlst
[X_AVENRUN
].n_value
, L_SET
);
read(kmem
, &lave
, sizeof (lave
));
for (i
= (j
> 50)? 50 : j
; i
> 0; i
--)
wprintw(wnd
, " %4.1f", lave
);