static char sccsid
[] = "@(#)main.c 1.4 (Lucasfilm) %G%";
static struct nlist nlst
[] = {
for (p
= cmdtab
; *p
->c_name
; p
++)
if (strcmp(p
->c_name
, &argv
[0][1]) == 0)
fprintf(stderr
, "%s: unknown request\n",
if (nlst
[X_CCPU
].n_type
== 0) {
fprintf(stderr
, "Couldn't namelist /vmunix.\n");
kmem
= open(kmemf
, O_RDONLY
);
mem
= open(memf
, O_RDONLY
);
swap
= open(swapf
, O_RDONLY
);
* Initialize display. Load average appears in standard
* window with current display's overlapping sub-window
* maintained by the display routines to minimize update
wnd
= (*curcmd
->c_open
)();
fprintf(stderr
, "Couldn't initialize display.\n");
gethostname(hostname
, sizeof (hostname
));
lseek(kmem
, nlst
[X_CCPU
].n_value
, 0);
read(kmem
, &ccpu
, sizeof (ccpu
));
strcpy(known
[0].k_name
, "<idle>");
signal(SIGALRM
, display
);
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
);
lseek(kmem
, nlst
[X_AVENRUN
].n_value
, L_SET
);
read(kmem
, &lave
, sizeof (lave
));
mvprintw(22, 0, "%4.1f", lave
);
mvprintw(22, 0, fmt
, a1
, a2
, a3
);